用户管理模块处理

master
yuqin 3 years ago
parent 8adb116246
commit ddce2cae6a
  1. 14
      src/main/java/com/yipin/liuwanr/AppConfig.java
  2. 48
      src/main/java/com/yipin/liuwanr/MybatisPlusConfiguration.java
  3. 75
      src/main/java/com/yipin/liuwanr/controller/HrUserAccountController.java
  4. 5
      src/main/java/com/yipin/liuwanr/entity/HrUserAccount.java
  5. 67
      src/main/java/com/yipin/liuwanr/entity/response/UserAccountListRes.java
  6. 36
      src/main/java/com/yipin/liuwanr/entity/response/UserSchoolDetailRes.java
  7. 50
      src/main/java/com/yipin/liuwanr/entity/response/UserSysDetailRes.java
  8. 7
      src/main/java/com/yipin/liuwanr/mapper/HrUserAccountMapper.java
  9. 10
      src/main/java/com/yipin/liuwanr/service/IHrUserAccountService.java
  10. 61
      src/main/java/com/yipin/liuwanr/service/impl/HrUserAccountServiceImpl.java
  11. 2
      src/main/java/com/yipin/liuwanr/util/MyBatisPlusCodeGenerator.java

@ -73,13 +73,13 @@ public class AppConfig {
return dataSource; return dataSource;
} }
@Bean // @Bean
public SqlSessionFactoryBean sqlSessionFactory() { // public SqlSessionFactoryBean sqlSessionFactory() {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean(); // SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(realDataSource()); // bean.setDataSource(realDataSource());
logger.info("SqlSessionFactoryBean Bean Created"); // logger.info("SqlSessionFactoryBean Bean Created");
return bean; // return bean;
} // }
@Bean @Bean
public HttpMessageConverters fastJsonConverters() { public HttpMessageConverters fastJsonConverters() {

@ -0,0 +1,48 @@
package com.yipin.liuwanr;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.core.config.GlobalConfig;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.sql.DataSource;
@Configuration
public class MybatisPlusConfiguration {
/**
* 将SqlSessionFactory配置为MybatisPlus的MybatisSqlSessionFactoryBean
*
* @param dataSource 默认配置文件中的数据源
* @return MybatisSqlSessionFactoryBean
*/
@Bean("mpSqlSessionFactory")
public MybatisSqlSessionFactoryBean setSqlSessionFactory(DataSource dataSource) {
MybatisSqlSessionFactoryBean bean = new MybatisSqlSessionFactoryBean();
// 设置数据源
bean.setDataSource(dataSource);
// 简化PO的引用
bean.setTypeAliasesPackage("com.yipin.liuwanr.entity.");
// 设置全局配置
bean.setGlobalConfig(this.globalConfig());
return bean;
}
/**
* 设置全局配置
*
* @return 全局配置
*/
public GlobalConfig globalConfig() {
GlobalConfig globalConfig = new GlobalConfig();
GlobalConfig.DbConfig dbConfig = new GlobalConfig.DbConfig();
// 设置逻辑删除字段
dbConfig.setLogicDeleteField("deleted");
// 设置更新策略
dbConfig.setUpdateStrategy(FieldStrategy.NOT_EMPTY);
globalConfig.setDbConfig(dbConfig);
return globalConfig;
}
}

@ -1,10 +1,22 @@
package com.yipin.liuwanr.controller; package com.yipin.liuwanr.controller;
import org.springframework.web.bind.annotation.RequestMapping; import com.github.pagehelper.PageInfo;
import com.yipin.liuwanr.entity.PageResult;
import com.yipin.liuwanr.entity.ServiceConfig;
import com.yipin.liuwanr.entity.response.ResponseResult;
import com.yipin.liuwanr.entity.response.UserSysDetailRes;
import com.yipin.liuwanr.entity.vo.UserInfoReq;
import com.yipin.liuwanr.service.IHrUserAccountService;
import com.yipin.liuwanr.service.UserInfoService;
import com.yipin.liuwanr.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import java.util.List;
/** /**
* <p> * <p>
* 各个平台账号表 前端控制器 * 各个平台账号表 前端控制器
@ -13,8 +25,67 @@ import org.springframework.stereotype.Controller;
* @author Qyq * @author Qyq
* @since 2021-06-18 * @since 2021-06-18
*/ */
@Controller @RestController
@RequestMapping("/hr-user-account") @RequestMapping("/hr-user-account")
public class HrUserAccountController { public class HrUserAccountController {
@Autowired
private UserInfoService userInfoService;
@Autowired
private IHrUserAccountService iHrUserAccountService;
/**
* 查询用户管理列表
*/
@PostMapping("/queryUserInfoList")
ResponseResult queryUserInfoList(@RequestBody UserInfoReq userInfoReq) {
List data = iHrUserAccountService.queryPage(userInfoReq.getPage(), userInfoReq.getSize(), userInfoReq);
//单独的分页操作
PageInfo<ServiceConfig> info = new PageInfo<ServiceConfig>(data);
int total1 = (int) info.getTotal();
int totalPages;
totalPages = total1 / userInfoReq.getSize();
if (total1 % userInfoReq.getSize() != 0) {
totalPages++;
}
long total = total1;
return ResponseResult.SUCCESS(new PageResult(total, data, totalPages));
}
/**
* 密码重置以手机号的维度重置所有账号密码为111aaa
*/
@GetMapping("/resetPwd")
ResponseResult resetPwd(@RequestParam("userId") Integer userId) {
int result = iHrUserAccountService.resetPwd(userId);
return result>0 ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
/**
* 删除用户以及账号
*/
@GetMapping("/delUserAccount")
ResponseResult delUserAccount(@RequestParam("userId") Integer userId,@RequestParam("isdel")Integer isdel) {
int result = iHrUserAccountService.delUserAccount(userId,isdel);
return result>0 ? ResponseResult.SUCCESS() : ResponseResult.FAIL();
}
/**
* 查看用户系统绑定详情
*/
@GetMapping("/selectUserSysBind")
ResponseResult selectUserSysBind(@RequestParam("userId") Integer userId,@RequestParam("platformId")Integer platformId) {
UserSysDetailRes result = iHrUserAccountService.selectUserSysBind(userId,platformId);
return ResponseResult.SUCCESS(result);
}
/**
* 查询用户管理列表(不可用)
*/
@PostMapping("/queryUserInfoList2")
ResponseResult queryUserInfoList2(@RequestBody UserInfoReq userInfoReq) {
PageUtils data = iHrUserAccountService.queryPage2(userInfoReq.getPage(), userInfoReq.getSize(), userInfoReq);
return ResponseResult.SUCCESS(data);
}
} }

@ -68,6 +68,11 @@ public class HrUserAccount implements Serializable {
*/ */
private Integer type; private Integer type;
/**
* 是否删除(0未删除 1已删除)
*/
private Integer isdel;
/** /**
* 创建时间 * 创建时间
*/ */

@ -0,0 +1,67 @@
package com.yipin.liuwanr.entity.response;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.yipin.liuwanr.entity.HrUserAccount;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* <p>
* 用户管理列表
* </p>
*
* @author Qyq
* @since 2021-03-17
*/
@Data
@ToString
public class UserAccountListRes implements Serializable {
@TableId(value = "id", type = IdType.ID_WORKER)
private Integer id;
/**
* 用户表id
*/
private Integer userId;
/**
* 账号
*/
private String account;
/**
* 工号
*/
private String workNumber;
/**
* 绑定的角色id
*/
private String roleId;
/**
* 绑定院校id
*/
private Integer schoolId;
private String schoolName;
/**
* 所属平台1->职站 2->数据平台
*/
private Integer platformId;
private String platformName;
/**
* 平台端区分0->教师端 1->学生端
*/
private Integer type;
}

@ -0,0 +1,36 @@
package com.yipin.liuwanr.entity.response;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.yipin.liuwanr.entity.HrUserAccount;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
/**
* <p>
* 用户管理列表
* </p>
*
* @author Qyq
* @since 2021-03-17
*/
@Data
@ToString
public class UserSchoolDetailRes implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 院校id
*/
private Integer schoolId;
/**
* 账号集合
*/
private List<HrUserAccount> accountList;
}

@ -0,0 +1,50 @@
package com.yipin.liuwanr.entity.response;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.yipin.liuwanr.entity.HrUserAccount;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* <p>
* 用户管理列表
* </p>
*
* @author Qyq
* @since 2021-03-17
*/
@Data
@ToString
public class UserSysDetailRes implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 用户id
*/
@TableId(value = "userId", type = IdType.AUTO)
private Integer userId;
/**
* 所属平台
*/
private Integer platformId;
/**
* 组织关系
*/
private Integer organizationalRelation;
/**
* 集合层
*/
private List<UserSchoolDetailRes> bigList;
private Map map;
}

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yipin.liuwanr.entity.HrUserAccount; import com.yipin.liuwanr.entity.HrUserAccount;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yipin.liuwanr.entity.response.UserAccountListRes;
import com.yipin.liuwanr.entity.response.UserInfoListRes; import com.yipin.liuwanr.entity.response.UserInfoListRes;
import com.yipin.liuwanr.entity.vo.UserInfoReq; import com.yipin.liuwanr.entity.vo.UserInfoReq;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -38,9 +39,9 @@ public interface HrUserAccountMapper extends BaseMapper<HrUserAccount> {
" hr_user_info ui\n" + " hr_user_info ui\n" +
" INNER JOIN hr_user_account ua ON ui.userId = ua.user_id\n" + " INNER JOIN hr_user_account ua ON ui.userId = ua.user_id\n" +
" LEFT JOIN school s on s.schoolId=ua.school_id\n" + " LEFT JOIN school s on s.schoolId=ua.school_id\n" +
" LEFT JOIN hr_platform p on p.platformId=ua.platform_id where\n" + " LEFT JOIN hr_platform p on p.platformId=ua.platform_id where ui.isdel=0 and ua.isdel=0\n" +
" <if test='userInfoReq.creationTime!=null and userInfoReq.endTime!=null and userInfoReq.endTime!=\"\" and userInfoReq.creationTime!=\"\" '> " + " <if test='userInfoReq.creationTime!=null and userInfoReq.endTime!=null and userInfoReq.endTime!=\"\" and userInfoReq.creationTime!=\"\" '> " +
"ui.creationTime between #{userInfoReq.creationTime} and #{userInfoReq.endTime}" + "AND ui.creationTime between #{userInfoReq.creationTime} and #{userInfoReq.endTime}" +
"</if>\n"+ "</if>\n"+
" <if test='userInfoReq.month !=null'> " + " <if test='userInfoReq.month !=null'> " +
"AND ui.creationTime &gt; date_sub(curdate(),interval #{userInfoReq.month} MONTH) " + "AND ui.creationTime &gt; date_sub(curdate(),interval #{userInfoReq.month} MONTH) " +
@ -60,4 +61,6 @@ public interface HrUserAccountMapper extends BaseMapper<HrUserAccount> {
IPage<UserInfoListRes> pageByCondition2(Page page); IPage<UserInfoListRes> pageByCondition2(Page page);
@Select("select ua.*,s.schoolName from hr_user_account ua left join school s on s.schoolId = ua.school_id where user_id=#{userId} and platform_id=#{platformId}")
List<UserAccountListRes> selectUserSysBindById(Integer userId, Integer platformId);
} }

@ -2,9 +2,12 @@ package com.yipin.liuwanr.service;
import com.yipin.liuwanr.entity.HrUserAccount; import com.yipin.liuwanr.entity.HrUserAccount;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.yipin.liuwanr.entity.response.UserSysDetailRes;
import com.yipin.liuwanr.entity.vo.UserInfoReq; import com.yipin.liuwanr.entity.vo.UserInfoReq;
import com.yipin.liuwanr.util.PageUtils; import com.yipin.liuwanr.util.PageUtils;
import java.util.List;
/** /**
* <p> * <p>
* 各个平台账号表 服务类 * 各个平台账号表 服务类
@ -14,6 +17,13 @@ import com.yipin.liuwanr.util.PageUtils;
* @since 2021-06-18 * @since 2021-06-18
*/ */
public interface IHrUserAccountService extends IService<HrUserAccount> { public interface IHrUserAccountService extends IService<HrUserAccount> {
List queryPage(Integer page, Integer size, UserInfoReq userInfoReq);
PageUtils queryPage2(Integer page, Integer size, UserInfoReq userInfoReq); PageUtils queryPage2(Integer page, Integer size, UserInfoReq userInfoReq);
int resetPwd(Integer userId);
int delUserAccount(Integer userId,Integer isdel);
UserSysDetailRes selectUserSysBind(Integer userId, Integer platformId);
} }

@ -1,16 +1,28 @@
package com.yipin.liuwanr.service.impl; package com.yipin.liuwanr.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yipin.liuwanr.entity.HrUserAccount; import com.yipin.liuwanr.entity.HrUserAccount;
import com.yipin.liuwanr.entity.HrUserInfo;
import com.yipin.liuwanr.entity.UserInfo;
import com.yipin.liuwanr.entity.response.UserAccountListRes;
import com.yipin.liuwanr.entity.response.UserInfoListRes; import com.yipin.liuwanr.entity.response.UserInfoListRes;
import com.yipin.liuwanr.entity.response.UserSysDetailRes;
import com.yipin.liuwanr.entity.vo.UserInfoReq; import com.yipin.liuwanr.entity.vo.UserInfoReq;
import com.yipin.liuwanr.mapper.HrUserAccountMapper; import com.yipin.liuwanr.mapper.HrUserAccountMapper;
import com.yipin.liuwanr.mapper.HrUserInfoMapper;
import com.yipin.liuwanr.service.IHrUserAccountService; import com.yipin.liuwanr.service.IHrUserAccountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yipin.liuwanr.util.MD5;
import com.yipin.liuwanr.util.PageUtils; import com.yipin.liuwanr.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/** /**
* <p> * <p>
@ -24,6 +36,20 @@ import org.springframework.stereotype.Service;
public class HrUserAccountServiceImpl extends ServiceImpl<HrUserAccountMapper, HrUserAccount> implements IHrUserAccountService { public class HrUserAccountServiceImpl extends ServiceImpl<HrUserAccountMapper, HrUserAccount> implements IHrUserAccountService {
@Autowired @Autowired
private HrUserAccountMapper hrUserAccountMapper; private HrUserAccountMapper hrUserAccountMapper;
@Autowired
private HrUserInfoMapper hrUserInfoMapper;
public List queryPage(Integer page, Integer size, UserInfoReq userInfoReq) {
//分页参数
if (page <= 0) {
page = 1;
}
if (size <= 0) {
size = 10;
}
List<UserInfoListRes> positionVO = hrUserAccountMapper.pageByCondition(new Page(page, size),userInfoReq);
return positionVO;
}
public PageUtils queryPage2(Integer page, Integer size, UserInfoReq userInfoReq) { public PageUtils queryPage2(Integer page, Integer size, UserInfoReq userInfoReq) {
//分页参数 //分页参数
@ -37,4 +63,39 @@ public class HrUserAccountServiceImpl extends ServiceImpl<HrUserAccountMapper, H
return new PageUtils(positionVO); return new PageUtils(positionVO);
} }
@Override
public int resetPwd(Integer userId) {
HrUserAccount hrUserAccount = new HrUserAccount();
hrUserAccount.setPassword(MD5.encrypt("111aaa"));
return this.getBaseMapper().update(hrUserAccount,new QueryWrapper<HrUserAccount>().eq("user_id",userId));
}
@Override
@Transactional
public int delUserAccount(Integer userId,Integer isdel) {
//设置用户表用户为已删除
HrUserInfo hrUserInfo = new HrUserInfo();
hrUserInfo.setIsdel(isdel);
hrUserInfoMapper.update(hrUserInfo,new QueryWrapper<HrUserInfo>().eq("userId",userId));
//设置账号表与用户相关的所有账号都设置为已删除
HrUserAccount hrUserAccount = new HrUserAccount();
hrUserAccount.setIsdel(isdel);
int userId1 = hrUserAccountMapper.update(hrUserAccount, new QueryWrapper<HrUserAccount>().eq("user_id", userId));
return userId1;
}
@Override
public UserSysDetailRes selectUserSysBind(Integer userId, Integer platformId) {
//根据用户id以及平台id将对应的用户及账号信息查询出来
List<UserAccountListRes> list = hrUserAccountMapper.selectUserSysBindById(userId,platformId);
//先根据院校分组,再根据平台端分组
Map<String, Map<Integer, List<UserAccountListRes>>> group2 = list.stream().collect(Collectors.groupingBy(UserAccountListRes::getSchoolName, Collectors.groupingBy(UserAccountListRes::getType)));
UserSysDetailRes res = new UserSysDetailRes();
res.setUserId(userId);
res.setPlatformId(platformId);
res.setMap(group2);
return res;
}
} }

@ -25,7 +25,7 @@ public class MyBatisPlusCodeGenerator {
public static final String PACKAGE_NAME = "com.yipin.liuwanr"; public static final String PACKAGE_NAME = "com.yipin.liuwanr";
public static void main(String[] args) { public static void main(String[] args) {
String[] tables = new String[] {"hr_user_account"};//表名数组 String[] tables = new String[] {"hr_user_info"};//表名数组
String[] tablePrefixs = new String[] {""};//去掉前缀 String[] tablePrefixs = new String[] {""};//去掉前缀
executeCode(PACKAGE_NAME,tables,tablePrefixs); executeCode(PACKAGE_NAME,tables,tablePrefixs);
} }

Loading…
Cancel
Save