diff --git a/src/main/java/com/yipin/liuwanr/AppConfig.java b/src/main/java/com/yipin/liuwanr/AppConfig.java
index 7878f03..fd5889c 100644
--- a/src/main/java/com/yipin/liuwanr/AppConfig.java
+++ b/src/main/java/com/yipin/liuwanr/AppConfig.java
@@ -73,13 +73,13 @@ public class AppConfig {
return dataSource;
}
- @Bean
- public SqlSessionFactoryBean sqlSessionFactory() {
- SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
- bean.setDataSource(realDataSource());
- logger.info("SqlSessionFactoryBean Bean Created");
- return bean;
- }
+// @Bean
+// public SqlSessionFactoryBean sqlSessionFactory() {
+// SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
+// bean.setDataSource(realDataSource());
+// logger.info("SqlSessionFactoryBean Bean Created");
+// return bean;
+// }
@Bean
public HttpMessageConverters fastJsonConverters() {
diff --git a/src/main/java/com/yipin/liuwanr/MybatisPlusConfiguration.java b/src/main/java/com/yipin/liuwanr/MybatisPlusConfiguration.java
new file mode 100644
index 0000000..a7ec477
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/MybatisPlusConfiguration.java
@@ -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;
+ }
+
+}
\ No newline at end of file
diff --git a/src/main/java/com/yipin/liuwanr/controller/HrUserAccountController.java b/src/main/java/com/yipin/liuwanr/controller/HrUserAccountController.java
index 82b0eb3..aec31e3 100644
--- a/src/main/java/com/yipin/liuwanr/controller/HrUserAccountController.java
+++ b/src/main/java/com/yipin/liuwanr/controller/HrUserAccountController.java
@@ -1,10 +1,22 @@
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 java.util.List;
+
/**
*
* 各个平台账号表 前端控制器
@@ -13,8 +25,67 @@ import org.springframework.stereotype.Controller;
* @author Qyq
* @since 2021-06-18
*/
-@Controller
+@RestController
@RequestMapping("/hr-user-account")
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 info = new PageInfo(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);
+ }
}
diff --git a/src/main/java/com/yipin/liuwanr/entity/HrUserAccount.java b/src/main/java/com/yipin/liuwanr/entity/HrUserAccount.java
index cc1352c..4113494 100644
--- a/src/main/java/com/yipin/liuwanr/entity/HrUserAccount.java
+++ b/src/main/java/com/yipin/liuwanr/entity/HrUserAccount.java
@@ -68,6 +68,11 @@ public class HrUserAccount implements Serializable {
*/
private Integer type;
+ /**
+ * 是否删除(0、未删除 1、已删除)
+ */
+ private Integer isdel;
+
/**
* 创建时间
*/
diff --git a/src/main/java/com/yipin/liuwanr/entity/response/UserAccountListRes.java b/src/main/java/com/yipin/liuwanr/entity/response/UserAccountListRes.java
new file mode 100644
index 0000000..c0b0632
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/entity/response/UserAccountListRes.java
@@ -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;
+
+/**
+ *
+ * 用户管理列表
+ *
+ *
+ * @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;
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/entity/response/UserSchoolDetailRes.java b/src/main/java/com/yipin/liuwanr/entity/response/UserSchoolDetailRes.java
new file mode 100644
index 0000000..a132135
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/entity/response/UserSchoolDetailRes.java
@@ -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;
+
+/**
+ *
+ * 用户管理列表
+ *
+ *
+ * @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 accountList;
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/entity/response/UserSysDetailRes.java b/src/main/java/com/yipin/liuwanr/entity/response/UserSysDetailRes.java
new file mode 100644
index 0000000..e87b2c9
--- /dev/null
+++ b/src/main/java/com/yipin/liuwanr/entity/response/UserSysDetailRes.java
@@ -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;
+
+/**
+ *
+ * 用户管理列表
+ *
+ *
+ * @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 bigList;
+
+ private Map map;
+
+}
diff --git a/src/main/java/com/yipin/liuwanr/helper/CookieUtils.java b/src/main/java/com/yipin/liuwanr/helper/CookieUtils.java
index be24b13..12dff1b 100644
--- a/src/main/java/com/yipin/liuwanr/helper/CookieUtils.java
+++ b/src/main/java/com/yipin/liuwanr/helper/CookieUtils.java
@@ -11,7 +11,7 @@ import java.net.URLDecoder;
import java.net.URLEncoder;
/**
- *
+ *
* Cookie 工具类
*
*/
@@ -21,7 +21,7 @@ public final class CookieUtils {
/**
* 得到Cookie的值, 不编码
- *
+ *
* @param request
* @param cookieName
* @return
@@ -32,7 +32,7 @@ public final class CookieUtils {
/**
* 得到Cookie的值,
- *
+ *
* @param request
* @param cookieName
* @return
@@ -62,7 +62,7 @@ public final class CookieUtils {
/**
* 得到Cookie的值,
- *
+ *
* @param request
* @param cookieName
* @return
@@ -136,7 +136,7 @@ public final class CookieUtils {
/**
* 设置Cookie的值,并使其在指定时间内生效
- *
+ *
* @param cookieMaxage cookie生效的最大秒数
*/
private static final void doSetCookie(HttpServletRequest request, HttpServletResponse response,
@@ -161,7 +161,7 @@ public final class CookieUtils {
/**
* 设置Cookie的值,并使其在指定时间内生效
- *
+ *
* @param cookieMaxage cookie生效的最大秒数
*/
private static final void doSetCookie(HttpServletRequest request, HttpServletResponse response,
diff --git a/src/main/java/com/yipin/liuwanr/mapper/HrUserAccountMapper.java b/src/main/java/com/yipin/liuwanr/mapper/HrUserAccountMapper.java
index 2cb21a4..24496dd 100644
--- a/src/main/java/com/yipin/liuwanr/mapper/HrUserAccountMapper.java
+++ b/src/main/java/com/yipin/liuwanr/mapper/HrUserAccountMapper.java
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yipin.liuwanr.entity.HrUserAccount;
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.vo.UserInfoReq;
import org.apache.ibatis.annotations.Mapper;
@@ -38,9 +39,9 @@ public interface HrUserAccountMapper extends BaseMapper {
" hr_user_info ui\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 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" +
" " +
- "ui.creationTime between #{userInfoReq.creationTime} and #{userInfoReq.endTime}" +
+ "AND ui.creationTime between #{userInfoReq.creationTime} and #{userInfoReq.endTime}" +
"\n"+
" " +
"AND ui.creationTime > date_sub(curdate(),interval #{userInfoReq.month} MONTH) " +
@@ -60,4 +61,6 @@ public interface HrUserAccountMapper extends BaseMapper {
IPage 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 selectUserSysBindById(Integer userId, Integer platformId);
}
diff --git a/src/main/java/com/yipin/liuwanr/service/IHrUserAccountService.java b/src/main/java/com/yipin/liuwanr/service/IHrUserAccountService.java
index 6fb04ac..c73e81c 100644
--- a/src/main/java/com/yipin/liuwanr/service/IHrUserAccountService.java
+++ b/src/main/java/com/yipin/liuwanr/service/IHrUserAccountService.java
@@ -2,9 +2,12 @@ package com.yipin.liuwanr.service;
import com.yipin.liuwanr.entity.HrUserAccount;
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.util.PageUtils;
+import java.util.List;
+
/**
*
* 各个平台账号表 服务类
@@ -14,6 +17,13 @@ import com.yipin.liuwanr.util.PageUtils;
* @since 2021-06-18
*/
public interface IHrUserAccountService extends IService {
+ List queryPage(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);
}
diff --git a/src/main/java/com/yipin/liuwanr/service/impl/HrUserAccountServiceImpl.java b/src/main/java/com/yipin/liuwanr/service/impl/HrUserAccountServiceImpl.java
index 0636af0..b65db85 100644
--- a/src/main/java/com/yipin/liuwanr/service/impl/HrUserAccountServiceImpl.java
+++ b/src/main/java/com/yipin/liuwanr/service/impl/HrUserAccountServiceImpl.java
@@ -1,16 +1,28 @@
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.extension.plugins.pagination.Page;
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.UserSysDetailRes;
import com.yipin.liuwanr.entity.vo.UserInfoReq;
import com.yipin.liuwanr.mapper.HrUserAccountMapper;
+import com.yipin.liuwanr.mapper.HrUserInfoMapper;
import com.yipin.liuwanr.service.IHrUserAccountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yipin.liuwanr.util.MD5;
import com.yipin.liuwanr.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
/**
*
@@ -24,6 +36,20 @@ import org.springframework.stereotype.Service;
public class HrUserAccountServiceImpl extends ServiceImpl implements IHrUserAccountService {
@Autowired
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 positionVO = hrUserAccountMapper.pageByCondition(new Page(page, size),userInfoReq);
+ return positionVO;
+ }
public PageUtils queryPage2(Integer page, Integer size, UserInfoReq userInfoReq) {
//分页参数
@@ -37,4 +63,39 @@ public class HrUserAccountServiceImpl extends ServiceImpl().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().eq("userId",userId));
+ //设置账号表与用户相关的所有账号都设置为已删除
+ HrUserAccount hrUserAccount = new HrUserAccount();
+ hrUserAccount.setIsdel(isdel);
+ int userId1 = hrUserAccountMapper.update(hrUserAccount, new QueryWrapper().eq("user_id", userId));
+ return userId1;
+ }
+
+ @Override
+ public UserSysDetailRes selectUserSysBind(Integer userId, Integer platformId) {
+ //根据用户id以及平台id将对应的用户及账号信息查询出来
+ List list = hrUserAccountMapper.selectUserSysBindById(userId,platformId);
+
+ //先根据院校分组,再根据平台端分组
+ Map>> 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;
+ }
}
diff --git a/src/main/java/com/yipin/liuwanr/util/MyBatisPlusCodeGenerator.java b/src/main/java/com/yipin/liuwanr/util/MyBatisPlusCodeGenerator.java
index e2d0b9e..c8cde07 100644
--- a/src/main/java/com/yipin/liuwanr/util/MyBatisPlusCodeGenerator.java
+++ b/src/main/java/com/yipin/liuwanr/util/MyBatisPlusCodeGenerator.java
@@ -25,7 +25,7 @@ public class MyBatisPlusCodeGenerator {
public static final String PACKAGE_NAME = "com.yipin.liuwanr";
public static void main(String[] args) {
- String[] tables = new String[] {"hr_user_account"};//表名数组
+ String[] tables = new String[] {"hr_user_info"};//表名数组
String[] tablePrefixs = new String[] {""};//去掉前缀
executeCode(PACKAGE_NAME,tables,tablePrefixs);
}