From f22e354b0ccd56858c5f5ce8f5ef29d9ace13fce Mon Sep 17 00:00:00 2001 From: "zhiyong.ning" <354350178@qq.com> Date: Mon, 21 Sep 2020 10:17:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liuwanr/controller/StaffController.java | 104 ++-- .../liuwanr/controller/StudentController.java | 214 +++---- .../controller/UserInfoController.java | 229 +++---- .../java/com/yipin/liuwanr/entity/Staff.java | 44 +- .../com/yipin/liuwanr/entity/Student.java | 42 +- .../com/yipin/liuwanr/entity/UserInfo.java | 16 +- .../liuwanr/helper/ExcelImportHelper.java | 4 +- .../yipin/liuwanr/mapper/AssesmentMapper.java | 6 +- .../com/yipin/liuwanr/mapper/StaffMapper.java | 12 +- .../yipin/liuwanr/mapper/StudentMapper.java | 18 +- .../yipin/liuwanr/mapper/UserInfoMapper.java | 568 +++++++++--------- .../yipin/liuwanr/service/StaffService.java | 2 +- .../yipin/liuwanr/service/StudentService.java | 8 +- .../liuwanr/service/UserInfoService.java | 247 ++++---- .../liuwanr/service/StaffServiceTest.java | 4 +- .../liuwanr/service/StudentServiceTest.java | 98 +-- 16 files changed, 796 insertions(+), 820 deletions(-) diff --git a/src/main/java/com/yipin/liuwanr/controller/StaffController.java b/src/main/java/com/yipin/liuwanr/controller/StaffController.java index 1380f26..1d2de8b 100644 --- a/src/main/java/com/yipin/liuwanr/controller/StaffController.java +++ b/src/main/java/com/yipin/liuwanr/controller/StaffController.java @@ -289,58 +289,58 @@ public class StaffController { /** * 添加员工 */ - @Transactional - @PostMapping("/addStaff") - Response addStaff(@RequestBody UserInfoVO vo) { - Response resp = new Response(); - //组织架构list - List ORList = vo.getOrganizationRelationshipList(); - UserInfo userInfo = vo.getUserInfo(); - Integer userId = userInfo.getUserId(); - String account = userInfo.getAccount(); - Integer isNewUser = userInfo.getIsNewUser(); - if (account==null||account=="") { - resp.setStatus(300); - resp.setErrmessage("账号为空添加失败!"); - } else { - if (isNewUser==0){ - HashMap sta = userInfoService.addStuStaff(ORList,userId); - int status = (int) sta.get("retcode"); - if (status == 200){ - resp.setStatus(status); - resp.setMessage(sta.get("retvalue")); - }else{ - resp.setStatus(status); - resp.setErrmessage(sta.get("retvalue").toString()); - throw new RuntimeException(); - } - }else if(isNewUser==1){ - HashMap ret = userInfoService.addUser(userInfo); - userId = (int) ret.get("userId"); - int status = (int) ret.get("retcode"); - if (status == 200){ - HashMap sta = userInfoService.addStuStaff(ORList,userId); - int status1 = (int) sta.get("retcode"); - if (status1 == 200){ - resp.setStatus(status1); - resp.setMessage(sta.get("retvalue")); - }else{ - resp.setStatus(status1); - resp.setErrmessage(sta.get("retvalue").toString()); - throw new RuntimeException(); - } - }else{ - resp.setStatus(status); - resp.setErrmessage(ret.get("retvalue").toString()); - throw new RuntimeException(); - } - }else{ - resp.setStatus(300); - resp.setErrmessage("新老用户为空添加失败!"); - } - } - return resp; - } +// @Transactional +// @PostMapping("/addStaff") +// Response addStaff(@RequestBody UserInfoVO vo) { +// Response resp = new Response(); +// //组织架构list +// List ORList = vo.getOrganizationRelationshipList(); +// UserInfo userInfo = vo.getUserInfo(); +// Integer userId = userInfo.getUserId(); +// String account = userInfo.getAccount(); +// Integer isNewUser = userInfo.getIsNewUser(); +// if (account==null||account=="") { +// resp.setStatus(300); +// resp.setErrmessage("账号为空添加失败!"); +// } else { +// if (isNewUser==0){ +// HashMap sta = userInfoService.addStuStaff(ORList,userId); +// int status = (int) sta.get("retcode"); +// if (status == 200){ +// resp.setStatus(status); +// resp.setMessage(sta.get("retvalue")); +// }else{ +// resp.setStatus(status); +// resp.setErrmessage(sta.get("retvalue").toString()); +// throw new RuntimeException(); +// } +// }else if(isNewUser==1){ +// HashMap ret = userInfoService.addUser(userInfo); +// userId = (int) ret.get("userId"); +// int status = (int) ret.get("retcode"); +// if (status == 200){ +// HashMap sta = userInfoService.addStuStaff(ORList,userId); +// int status1 = (int) sta.get("retcode"); +// if (status1 == 200){ +// resp.setStatus(status1); +// resp.setMessage(sta.get("retvalue")); +// }else{ +// resp.setStatus(status1); +// resp.setErrmessage(sta.get("retvalue").toString()); +// throw new RuntimeException(); +// } +// }else{ +// resp.setStatus(status); +// resp.setErrmessage(ret.get("retvalue").toString()); +// throw new RuntimeException(); +// } +// }else{ +// resp.setStatus(300); +// resp.setErrmessage("新老用户为空添加失败!"); +// } +// } +// return resp; +// } /** * 更新员工 */ diff --git a/src/main/java/com/yipin/liuwanr/controller/StudentController.java b/src/main/java/com/yipin/liuwanr/controller/StudentController.java index d5451c7..864b4b3 100644 --- a/src/main/java/com/yipin/liuwanr/controller/StudentController.java +++ b/src/main/java/com/yipin/liuwanr/controller/StudentController.java @@ -29,25 +29,26 @@ public class StudentController { @Autowired private UserInfoService userInfoService; - + @Autowired RedisHelper redisHelper; - - + + /** * 批量导入学生 + * * @param file * @return */ @PostMapping("/readStudent") - Response readStudent(MultipartFile file,@RequestParam Integer schoolId){ - Response resp = new Response(); - if(StringUtils.isEmpty(schoolId)) { + Response readStudent(MultipartFile file, @RequestParam Integer schoolId) { + Response resp = new Response(); + if (StringUtils.isEmpty(schoolId)) { resp.setStatus(300); resp.setMessage("schoolId is not empty"); return resp; } - HashMap ret =studentService.readStudent(schoolId,file); + HashMap ret = studentService.readStudent(schoolId, file); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); @@ -56,9 +57,9 @@ public class StudentController { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); } - return resp; - } - + return resp; + } + // /** // * 添加学生 @@ -99,15 +100,15 @@ public class StudentController { /** - * 查询学生详情 + * 查询学生详情 */ @GetMapping("/queryStudentDetails") Response queryStudentDetails(@RequestParam Integer studentId) { Response resp = new Response(); - if (studentId==null) { + if (studentId == null) { resp.setStatus(300); resp.setErrmessage("学生id为空,查询失败!"); - }else { + } else { HashMap ret = studentService.queryStudentDetails(studentId); int status = (int) ret.get("retcode"); if (200 == status) { @@ -118,8 +119,8 @@ public class StudentController { resp.setErrmessage(ret.get("retvalue").toString()); } } - return resp; -} + return resp; + } // // /** // * 根据professionalIds(专业id)查询所有学生 @@ -216,9 +217,9 @@ public class StudentController { // } // return resp; // } - + /** - * 更新学生 + * 更新学生 */ @PostMapping("/updateStudent") Response updateStudent(@RequestBody UserVO vo) { @@ -227,10 +228,10 @@ public class StudentController { UserM user = vo.getUser(); Integer studentId = student.getStudentId(); String phone = user.getPhone(); - if (studentId==null) { + if (studentId == null) { resp.setStatus(300); resp.setErrmessage("学生id为空,修改失败!"); - }else if (phone==null||phone==""){ + } else if (phone == null || phone == "") { resp.setStatus(300); resp.setErrmessage("电话为空,修改失败!"); } else { @@ -246,6 +247,7 @@ public class StudentController { } return resp; } +} /** * 添加学生信息 @@ -253,54 +255,54 @@ public class StudentController { * UserInfo:account,userName,roleId,uniqueIdentificationAccount,phone,email,schoolId * OrganizationRelationship:workNumber,professionalClassId,gradeId,classId,schoolId */ - @Transactional - @PostMapping("/addStudent") - Response addStudent(@RequestBody UserInfoVO vo) { - Response response = new Response(); -// Student student = vo.getStudent(); - UserInfo userInfo = vo.getUserInfo(); - OrganizationRelationship organizationRelationship = vo.getOrganizationRelationship(); - String account = userInfo.getAccount(); - String userName = userInfo.getUserName(); - Integer roleId = userInfo.getRoleId(); - String uniqueIdentificationAccount = userInfo.getUniqueIdentificationAccount(); - String phone = userInfo.getPhone(); - String email = userInfo.getEmail(); - String workNumber = organizationRelationship.getWorkNumber(); - Integer professionalId = organizationRelationship.getProfessionalId(); - Integer gradeId = organizationRelationship.getGradeId(); - Integer classId = organizationRelationship.getClassId(); - -// UserM user = vo.getUser(); - if (account==null||userName==null||roleId!=4||uniqueIdentificationAccount==null||workNumber==null||professionalId<=0||gradeId<=0||classId<=0) { - response.setStatus(300); - response.setErrmessage("Parameter Invalid"); - } else { - HashMap ret = userInfoService.addUserInfo(userInfo); - int status = (int) ret.get("retcode"); - if (200 == status) { - response.setStatus(status); - response.setMessage(ret.get("retvalue")); - Integer userId = userInfo.getUserId(); - organizationRelationship.setUserId(userId); - HashMap ret1 = userInfoService.addOrganizationRelationship(organizationRelationship); - int status1 = (int)ret.get("retcode"); - if (status1 == 200){ - response.setStatus(status1); - response.setMessage(ret1.get("retvalue")); - }else { - response.setStatus(status1); - response.setErrmessage(ret1.get("retvalue").toString()); - throw new RuntimeException(); - } - } else { - response.setStatus(status); - response.setErrmessage(ret.get("retvalue").toString()); - throw new RuntimeException(); - } - } - return response; - } +// @Transactional +// @PostMapping("/addStudent") +// Response addStudent(@RequestBody UserInfoVO vo) { +// Response response = new Response(); +//// Student student = vo.getStudent(); +// UserInfo userInfo = vo.getUserInfo(); +// OrganizationRelationship organizationRelationship = vo.getOrganizationRelationship(); +// String account = userInfo.getAccount(); +// String userName = userInfo.getUserName(); +// Integer roleId = userInfo.getRoleId(); +// String uniqueIdentificationAccount = userInfo.getUniqueIdentificationAccount(); +// String phone = userInfo.getPhone(); +// String email = userInfo.getEmail(); +// String workNumber = organizationRelationship.getWorkNumber(); +// Integer professionalId = organizationRelationship.getProfessionalId(); +// Integer gradeId = organizationRelationship.getGradeId(); +// Integer classId = organizationRelationship.getClassId(); +// +//// UserM user = vo.getUser(); +// if (account==null||userName==null||roleId!=4||uniqueIdentificationAccount==null||workNumber==null||professionalId<=0||gradeId<=0||classId<=0) { +// response.setStatus(300); +// response.setErrmessage("Parameter Invalid"); +// } else { +// HashMap ret = userInfoService.addUserInfo(userInfo); +// int status = (int) ret.get("retcode"); +// if (200 == status) { +// response.setStatus(status); +// response.setMessage(ret.get("retvalue")); +// Integer userId = userInfo.getUserId(); +// organizationRelationship.setUserId(userId); +// HashMap ret1 = userInfoService.addOrganizationRelationship(organizationRelationship); +// int status1 = (int)ret.get("retcode"); +// if (status1 == 200){ +// response.setStatus(status1); +// response.setMessage(ret1.get("retvalue")); +// }else { +// response.setStatus(status1); +// response.setErrmessage(ret1.get("retvalue").toString()); +// throw new RuntimeException(); +// } +// } else { +// response.setStatus(status); +// response.setErrmessage(ret.get("retvalue").toString()); +// throw new RuntimeException(); +// } +// } +// return response; +// } /** * 查询学生信息 @@ -313,32 +315,32 @@ public class StudentController { * @param pageSize * @return */ - @GetMapping("/queryStudent") - Response queryStudent(@RequestParam Integer schoolId, String professionalIds, String searchContent, String gradeIds, String classIds, Integer pageNo, Integer pageSize) { - Response response = new Response(); - StudentInfo studentInfo = new StudentInfo(); - if (schoolId == null) { - response.setStatus(300); - response.setErrmessage("学校信息为空"); - } else { - if (searchContent != null && searchContent != "") { - studentInfo.setSearchContent(searchContent); - } - if (professionalIds!=null&&professionalIds!="") { - studentInfo.setProfessionalIds(professionalIds); - } - if (gradeIds!=null&&gradeIds!="") { - studentInfo.setGradeIds(gradeIds); - } - if (classIds!=null&&classIds!="") { - studentInfo.setClassIds(classIds); - } - studentInfo.setSchoolId(schoolId); - HashMap map = userInfoService.queryStudent(studentInfo,pageNo,pageSize); - QueryStudentUtils.statusInformationController(response,map, "retcode", "retvalue"); - } - return response; - } +// @GetMapping("/queryStudent") +// Response queryStudent(@RequestParam Integer schoolId, String professionalIds, String searchContent, String gradeIds, String classIds, Integer pageNo, Integer pageSize) { +// Response response = new Response(); +// StudentInfo studentInfo = new StudentInfo(); +// if (schoolId == null) { +// response.setStatus(300); +// response.setErrmessage("学校信息为空"); +// } else { +// if (searchContent != null && searchContent != "") { +// studentInfo.setSearchContent(searchContent); +// } +// if (professionalIds!=null&&professionalIds!="") { +// studentInfo.setProfessionalIds(professionalIds); +// } +// if (gradeIds!=null&&gradeIds!="") { +// studentInfo.setGradeIds(gradeIds); +// } +// if (classIds!=null&&classIds!="") { +// studentInfo.setClassIds(classIds); +// } +// studentInfo.setSchoolId(schoolId); +// HashMap map = userInfoService.queryStudent(studentInfo,pageNo,pageSize); +// QueryStudentUtils.statusInformationController(response,map, "retcode", "retvalue"); +// } +// return response; +// } /** * 批量删除学生 @@ -346,16 +348,16 @@ public class StudentController { * @param userId 用户id * @return */ - @GetMapping("/deleteStudent") - Response deleteStudent(Integer[] userId) { - Response response = new Response(); - if (userId!=null&&userId.length > 0) { - userInfoService.deleteStudent(userId); - response.setStatus(200); - } else { - response.setStatus(500); - response.setErrmessage("学生id不能为空"); - } - return response; - } -} +// @GetMapping("/deleteStudent") +// Response deleteStudent(Integer[] userId) { +// Response response = new Response(); +// if (userId!=null&&userId.length > 0) { +// userInfoService.deleteStudent(userId); +// response.setStatus(200); +// } else { +// response.setStatus(500); +// response.setErrmessage("学生id不能为空"); +// } +// return response; +// } +//} diff --git a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java index bf73ad8..7c8dd0e 100644 --- a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java +++ b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java @@ -5,6 +5,7 @@ import com.yipin.liuwanr.helper.RedisHelper; import com.yipin.liuwanr.service.StaffService; import com.yipin.liuwanr.service.StudentService; import com.yipin.liuwanr.service.UserInfoService; +import com.yipin.liuwanr.service.UserService; import com.yipin.liuwanr.vo.UserInfoVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -30,119 +31,11 @@ public class UserInfoController { private UserInfoService userInfoService; @Autowired - RedisHelper redisHelper; + private UserService userService; + @Autowired + RedisHelper redisHelper; -// /** -// * 接收参数: -// * UserInfo:account,userName,roleId,uniqueIdentificationAccount,phone,email -// * OrganizationRelationship:workNumber,professionalClassId,gradeId,classId -// */ -// @Transactional -// @PostMapping("/addStudent") -// Response addStudent(@RequestBody UserInfoVO vo) { -// Response response = new Response(); -//// Student student = vo.getStudent(); -// UserInfo userInfo = vo.getUserInfo(); -// OrganizationRelationship organizationRelationship = vo.getOrganizationRelationship(); -// String account = userInfo.getAccount(); -// String userName = userInfo.getUserName(); -// Integer roleId = userInfo.getRoleId(); -// String uniqueIdentificationAccount = userInfo.getUniqueIdentificationAccount(); -// String phone = userInfo.getPhone(); -// String email = userInfo.getEmail(); -// String workNumber = organizationRelationship.getWorkNumber(); -// Integer professionalId = organizationRelationship.getProfessionalId(); -// Integer gradeId = organizationRelationship.getGradeId(); -// Integer classId = organizationRelationship.getClassId(); -// -//// UserM user = vo.getUser(); -// if (account==null||userName==null||roleId!=4||uniqueIdentificationAccount==null||workNumber==null||professionalId<=0||gradeId<=0||classId<=0) { -// response.setStatus(300); -// response.setErrmessage("Parameter Invalid"); -// } else { -// HashMap ret = userInfoService.addUserInfo(userInfo); -// int status = (int) ret.get("retcode"); -// if (200 == status) { -// response.setStatus(status); -// response.setMessage(ret.get("retvalue")); -// Integer userId = userInfo.getUserId(); -// organizationRelationship.setUserId(userId); -// HashMap ret1 = userInfoService.addOrganizationRelationship(organizationRelationship); -// int status1 = (int)ret.get("retcode"); -// if (status1 == 200){ -// response.setStatus(status1); -// response.setMessage(ret1.get("retvalue")); -// }else { -// response.setStatus(status1); -// response.setErrmessage(ret1.get("retvalue").toString()); -// throw new RuntimeException(); -// } -// } else { -// response.setStatus(status); -// response.setErrmessage(ret.get("retvalue").toString()); -// throw new RuntimeException(); -// } -// } -// return response; -// } -// -// /** -// * 查询学生信息 -// * @param schoolId -// * @param professionalIds -// * @param searchContent -// * @param gradeIds -// * @param classIds -// * @param pageNo -// * @param pageSize -// * @return -// */ -// @GetMapping("/queryStudent") -// Response queryStudent(@RequestParam Integer schoolId, String professionalIds, String searchContent, String gradeIds, String classIds, Integer pageNo, Integer pageSize) { -// Response response = new Response(); -// StudentInfo studentInfo = new StudentInfo(); -// if (schoolId == null) { -// response.setStatus(300); -// response.setErrmessage("学校信息为空"); -// } else { -// if (searchContent != null && searchContent != "") { -// studentInfo.setSearchContent(searchContent); -// } -// if (professionalIds!=null&&professionalIds!="") { -// studentInfo.setProfessionalIds(professionalIds); -// } -// if (gradeIds!=null&&gradeIds!="") { -// studentInfo.setGradeIds(gradeIds); -// } -// if (classIds!=null&&classIds!="") { -// studentInfo.setClassIds(classIds); -// } -// studentInfo.setSchoolId(schoolId); -// HashMap map = userInfoService.queryStudent(studentInfo,pageNo,pageSize); -// QueryStudentUtils.statusInformationController(response,map, "retcode", "retvalue"); -// } -// return response; -// } -// -// /** -// * 批量删除学生 -// * -// * @param ids 用户id -// * @return -// */ -// @GetMapping("/deleteStudent") -// Response deleteStudent(Integer[] ids) { -// Response response = new Response(); -// if (ids.length > 0) { -// userInfoService.deleteStudent(ids); -// response.setStatus(200); -// } else { -// response.setStatus(500); -// response.setErrmessage("学生id不能为空"); -// } -// return response; -// } /** * 添加用户 @@ -153,16 +46,16 @@ public class UserInfoController { Response resp = new Response(); //个人档案实体 List userProfilesList = vo.getUserProfilesList(); - //组织架构list - List ORList = vo.getOrganizationRelationshipList(); + //员工list + List staffList = vo.getStaffList(); + //学生实体 + Student student = vo.getStudent(); //用户实体 UserInfo user = vo.getUserInfo(); - //用户手机号 + //用户账号 String account = user.getAccount(); //用户名称 String name = user.getUserName(); - //用户角色id - Integer roleId = user.getRoleId(); //学校id Integer schoolId = user.getSchoolId(); if(name==null||name==""){ @@ -175,32 +68,11 @@ public class UserInfoController { resp.setStatus(300); resp.setErrmessage("学校不能为空!"); }else { - HashMap ret = userInfoService.addUser(user); - Integer userId = user.getUserId(); + HashMap ret = userInfoService.addUser(user,student,staffList,userProfilesList); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); resp.setMessage(ret.get("retvalue")); - HashMap stu = userInfoService.addPersonalFile(userProfilesList,userId); - int stuStatus = (int) stu.get("retcode"); - if (stuStatus == 200){ - resp.setStatus(stuStatus); - resp.setMessage(stu.get("retvalue")); - }else { - resp.setStatus(stuStatus); - resp.setErrmessage(stu.get("retvalue").toString()); - throw new RuntimeException(); - } - HashMap sta = userInfoService.addStuStaff(ORList,userId); - int staStatus = (int) sta.get("retcode"); - if (staStatus == 200){ - resp.setStatus(staStatus); - resp.setMessage(sta.get("retvalue")); - }else { - resp.setStatus(staStatus); - resp.setErrmessage(sta.get("retvalue").toString()); - throw new RuntimeException(); - } } else { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); @@ -214,7 +86,7 @@ public class UserInfoController { * 查询用户(根据国家、省份、城市) */ @GetMapping("/queryUserInfo") - Response queryUserInfo(@RequestParam String countries, Integer provinceId, Integer cityId, Integer pageNo, Integer pageSize, Integer schoolId, Integer roleId, String searchContent, Integer month, String creationTime, String endTime) { + Response queryUserInfo(@RequestParam String countries, Integer provinceId, Integer cityId, Integer pageNo, Integer pageSize, Integer schoolId, String roleId, String searchContent, Integer month, String creationTime, String endTime) { Response resp = new Response(); UserInfo userInfo = new UserInfo(); //设置国家 @@ -272,7 +144,7 @@ public class UserInfoController { @PostMapping("/deleteUserInfo") public Response deleteUserInfo(@RequestBody List userIdList) { Response resp = new Response(); - if (userIdList==null) { + if (userIdList.isEmpty()) { resp.setStatus(300); resp.setErrmessage("用户id为空,删除用户失败!"); } else { @@ -281,17 +153,7 @@ public class UserInfoController { if (200 == status) { resp.setStatus(status); resp.setMessage(ret.get("retvalue")); - HashMap sta = userInfoService.deleteOrganizationRelationship(userIdList); - int staStatus = (int) sta.get("retcode"); - if (200 == staStatus) { - resp.setStatus(staStatus); - resp.setMessage(sta.get("retvalue")); - }else{ - resp.setStatus(staStatus); - resp.setErrmessage(sta.get("retvalue").toString()); - throw new RuntimeException(); - } - }else { + }else { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); throw new RuntimeException(); @@ -326,6 +188,36 @@ public class UserInfoController { return resp; } + /** + * 更新用户角色id + */ + @Transactional + @PostMapping("/updateUserRoleId") + public Response updateUserRoleId(@RequestBody UserInfo userInfo) { + Response resp = new Response(); + Integer userId = userInfo.getUserId(); + String roleId = userInfo.getRoleId(); + if (userId==null) { + resp.setStatus(300); + resp.setErrmessage("用户ID为空,修改用户失败!"); + }else if (roleId==null){ + resp.setStatus(300); + resp.setErrmessage("用户ID为空,修改用户失败!"); + } else { + HashMap ret = userInfoService.updateUserRoleId(userId,roleId); + int status = (int) ret.get("retcode"); + if (200 == status) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + throw new RuntimeException("修改用户失败!"); + } + } + return resp; + } + /** * 更新用户个人档案 */ @@ -357,13 +249,15 @@ public class UserInfoController { */ @Transactional @PostMapping("/updateOR") - public Response updateOrganizationRelationship(@RequestBody List OrganizationRelationshipList) { + public Response updateOrganizationRelationship(@RequestBody UserInfoVO vo) { Response resp = new Response(); - if (OrganizationRelationshipList.isEmpty()) { + List staffList = vo.getStaffList(); + List studentList = vo.getStudentList(); + if (staffList.isEmpty()&&studentList.isEmpty()) { resp.setStatus(300); resp.setErrmessage("用户组织关系为空,修改组织关系失败!"); } else { - HashMap ret = userInfoService.updateOrganizationRelationship(OrganizationRelationshipList); + HashMap ret = userInfoService.updateOR(staffList,studentList); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); @@ -410,7 +304,7 @@ public class UserInfoController { * 登陆 */ @GetMapping("/logins") - Response logins(@RequestParam("userId") Integer userId, @RequestParam("schoolId") Integer schoolId,@RequestParam("roleId") Integer roleId, HttpServletRequest req, HttpServletResponse res) { + Response logins(@RequestParam("userId") Integer userId, @RequestParam("schoolId") Integer schoolId,@RequestParam("roleId") String roleId, HttpServletRequest req, HttpServletResponse res) { Response resp = new Response(); UserInfo userInfo = new UserInfo(); if (userId == null) { @@ -742,4 +636,29 @@ public class UserInfoController { } return resp; } + + /** + * 查询平台 + */ + @GetMapping("/queryStuAndSta") + Response queryStuAndSta(@RequestParam Integer platformId,Integer userId) { + Response resp = new Response(); + UserInfo userInfo = new UserInfo(); + //平台id + if (platformId==null) { + resp.setStatus(300); + resp.setErrmessage("平台id为空!"); + }else{ + HashMap ret = userInfoService.queryStuAndSta(platformId,userId); + int status = (int) ret.get("retcode"); + if (200 == status) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + } + return resp; + } } \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/entity/Staff.java b/src/main/java/com/yipin/liuwanr/entity/Staff.java index bc97962..d35be27 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Staff.java +++ b/src/main/java/com/yipin/liuwanr/entity/Staff.java @@ -1,6 +1,8 @@ package com.yipin.liuwanr.entity; public class Staff { + //绑定用户id + private Integer userId; //账号 private String account; //员工主键ID @@ -8,7 +10,7 @@ public class Staff { //员工名称 private String staffName; //员工工号 - private String staffWorkNumber; + private String workNumber; //电话 private String phone; //邮件 @@ -37,7 +39,26 @@ public class Staff { private String staffProfessionalArchitectureIds; //绑定学校id private Integer schoolId; + //绑定学校名称 + private String schoolName; + //平台id + private Integer platformId; + public String getSchoolName() { + return schoolName; + } + + public void setSchoolName(String schoolName) { + this.schoolName = schoolName; + } + + public Integer getPlatformId() { + return platformId; + } + + public void setPlatformId(Integer platformId) { + this.platformId = platformId; + } public String getAccount() { return account; } @@ -46,6 +67,14 @@ public class Staff { this.account = account; } + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + public Integer getSchoolId() { return schoolId; } @@ -106,12 +135,15 @@ public class Staff { public void setStaffName(String staffName) { this.staffName = staffName; } - public String getStaffWorkNumber() { - return staffWorkNumber; + + public String getWorkNumber() { + return workNumber; } - public void setStaffWorkNumber(String staffWorkNumber) { - this.staffWorkNumber = staffWorkNumber; + + public void setWorkNumber(String workNumber) { + this.workNumber = workNumber; } + public String getPhone() { return phone; } @@ -154,7 +186,7 @@ public class Staff { return "Staff{" + "staffId=" + staffId + ", staffName='" + staffName + '\'' + - ", staffWorkNumber='" + staffWorkNumber + '\'' + + ", workNumber='" + workNumber + '\'' + ", phone='" + phone + '\'' + ", email='" + email + '\'' + ", logNumber=" + logNumber + diff --git a/src/main/java/com/yipin/liuwanr/entity/Student.java b/src/main/java/com/yipin/liuwanr/entity/Student.java index 72b765b..809cb96 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Student.java +++ b/src/main/java/com/yipin/liuwanr/entity/Student.java @@ -2,6 +2,8 @@ package com.yipin.liuwanr.entity; public class Student { + //绑定用户id + private Integer userId; //账号 private String account; //学生主键ID @@ -9,7 +11,7 @@ public class Student { //学生名称 private String studentName; //学生学号 - private String studentNumber; + private String workNumber; //电话 private String phone; //邮箱 @@ -18,6 +20,8 @@ public class Student { private Integer roleId; //绑定学校ID private Integer schoolId; + //绑定学校名称 + private String schoolName; //绑定专业ID private Integer professionalId; //绑定年级ID @@ -58,6 +62,32 @@ public class Student { private String attendance; //学生专业组织架构名称 private String stuProfessionalArchitectureName; + //平台id + private Integer platformId; + + public String getSchoolName() { + return schoolName; + } + + public void setSchoolName(String schoolName) { + this.schoolName = schoolName; + } + + public Integer getPlatformId() { + return platformId; + } + + public void setPlatformId(Integer platformId) { + this.platformId = platformId; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } public String getAccount() { return account; @@ -163,11 +193,11 @@ public class Student { public void setStudentName(String studentName) { this.studentName = studentName; } - public String getStudentNumber() { - return studentNumber; + public String getWorkNumber() { + return workNumber; } - public void setStudentNumber(String studentNumber) { - this.studentNumber = studentNumber; + public void setWorkNumber(String workNumber) { + this.workNumber = workNumber; } public String getPhone() { return phone; @@ -235,7 +265,7 @@ public class Student { return "Student{" + "studentId=" + studentId + ", studentName='" + studentName + '\'' + - ", studentNumber='" + studentNumber + '\'' + + ", workNumber='" + workNumber + '\'' + ", phone='" + phone + '\'' + ", email='" + email + '\'' + ", roleId=" + roleId + diff --git a/src/main/java/com/yipin/liuwanr/entity/UserInfo.java b/src/main/java/com/yipin/liuwanr/entity/UserInfo.java index f52795a..bfc0aba 100644 --- a/src/main/java/com/yipin/liuwanr/entity/UserInfo.java +++ b/src/main/java/com/yipin/liuwanr/entity/UserInfo.java @@ -11,7 +11,7 @@ public class UserInfo { //用户id private Integer userId; //角色id - private Integer roleId; + private String roleId; //用户姓名 private String userName; //用户账号 @@ -92,8 +92,6 @@ public class UserInfo { private String oneDepartmentName; //二级部门名称 private String twoDepartmentName; - //是否新用户 - private Integer isNewUser; //组织架构id private Integer organizationRelationshipId; @@ -105,14 +103,6 @@ public class UserInfo { this.organizationRelationshipId = organizationRelationshipId; } - public Integer getIsNewUser() { - return isNewUser; - } - - public void setIsNewUser(Integer isNewUser) { - this.isNewUser = isNewUser; - } - public String getWorkNumber() { return workNumber; } @@ -441,11 +431,11 @@ public class UserInfo { this.professionalName = professionalName; } - public Integer getRoleId() { + public String getRoleId() { return roleId; } - public void setRoleId(Integer roleId) { + public void setRoleId(String roleId) { this.roleId = roleId; } diff --git a/src/main/java/com/yipin/liuwanr/helper/ExcelImportHelper.java b/src/main/java/com/yipin/liuwanr/helper/ExcelImportHelper.java index c3bdea6..5d6c01b 100644 --- a/src/main/java/com/yipin/liuwanr/helper/ExcelImportHelper.java +++ b/src/main/java/com/yipin/liuwanr/helper/ExcelImportHelper.java @@ -147,7 +147,7 @@ public class ExcelImportHelper { // 角色id student.setRoleId(4); // 学生学号 - student.setStudentNumber(studentNumber.getStringCellValue()); + student.setWorkNumber(studentNumber.getStringCellValue()); //专业 student.setProfessionalName(professionalName.getStringCellValue()); //年级 @@ -209,7 +209,7 @@ public class ExcelImportHelper { // 角色id staff.setRoleId(3); // 职工工号 - staff.setStaffWorkNumber(staffWorkNumber.getStringCellValue()); + staff.setWorkNumber(staffWorkNumber.getStringCellValue()); // 专业 staff.setStaffProfessionalArchitectureName(staffProfessionalArchitectureName.getStringCellValue()); //部门 diff --git a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java index 0df67f5..6acf638 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java @@ -41,9 +41,9 @@ public interface AssesmentMapper { */ @Select({"" }) @@ -110,9 +110,9 @@ public interface StaffMapper { //=======全承珠 @Select({""}) Staff queryStaffQ(UserM user); diff --git a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java index ba090e0..b083055 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java @@ -14,8 +14,8 @@ import io.lettuce.core.dynamic.annotation.Param; public interface StudentMapper { //添加学生 - @Insert("INSERT INTO student(studentName,studentNumber,phone,email,roleId,schoolId,professionalId,gradeId,classId,isdel,uniqueIdentificationAccount)" - + "VALUES(#{studentName},#{studentNumber},#{phone},#{email},#{roleId},#{schoolId},#{professionalId},#{gradeId},#{classId},0,#{uniqueIdentificationAccount})") + @Insert("INSERT INTO student(studentName,workNumber,phone,email,roleId,schoolId,professionalId,gradeId,classId,isdel,uniqueIdentificationAccount)" + + "VALUES(#{studentName},#{workNumber},#{phone},#{email},#{roleId},#{schoolId},#{professionalId},#{gradeId},#{classId},0,#{uniqueIdentificationAccount})") void addStudent(Student student); //通过专业id查询所有学生信息 @@ -47,7 +47,7 @@ public interface StudentMapper { //查询学生详情 @Select({ " " }) List queryStudentDetails(Integer studentId); @@ -63,12 +63,12 @@ public interface StudentMapper { //查询学生详情 @Select({ " " }) List queryStudentDetailsU(Integer studentId); //修改学生 - @Update("UPDATE student SET studentName = #{studentName},studentNumber = #{studentNumber},phone = #{phone},email = #{email},roleId = #{roleId}" + @Update("UPDATE student SET studentName = #{studentName},workNumber = #{workNumber},phone = #{phone},email = #{email},roleId = #{roleId}" + ",schoolId = #{schoolId},professionalId = #{professionalId},gradeId = #{gradeId},classId = #{classId} where studentId = #{studentId}") void updateStudent(Student student); @@ -95,9 +95,9 @@ public interface StudentMapper { @Insert({ "" }) void bacthAddStudent(@Param("students") List students); @@ -111,9 +111,9 @@ public interface StudentMapper { //========全承珠 @Select({""}) Student queryStudentQ(UserM user); diff --git a/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java index 015d212..209505d 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java @@ -9,272 +9,304 @@ import org.apache.ibatis.mapping.FetchType; import java.util.List; -public interface UserInfoMapper{ - - @Insert("INSERT INTO hr_user_info(userName,uniqueIdentificationAccount,documentType,IDNumber,provinceId,cityId,countries,dateBirth,educationDegree,schoolId,phone,weChatID,email,account,password,creationTime,logInNumber,sex,userAvatars,isdel)" - + " VALUES(#{userName},#{uniqueIdentificationAccount},#{documentType},#{IDNumber},#{provinceId},#{cityId},#{countries},#{dateBirth},#{educationDegree},#{schoolId},#{phone},#{weChatID},#{email},#{account},#{password},now(),#{logInNumber},#{sex},#{userAvatars},0)") - @Options(useGeneratedKeys=true, keyProperty="userId", keyColumn="userId") - Integer insertUserInfo(UserInfo userInfo); - - @Select({""}) - List queryStudent(StudentInfo studentInfo); - - @Update({""}) - Integer updateStudentInfo(List list); - - @Update({ ""}) - void update(User user); - - @Insert("INSERT INTO hr_user_info(userName,uniqueIdentificationAccount,documentType,IDNumber,provinceId,cityId,countries,dateBirth,educationDegree,schoolId,phone,weChatID,email,account,password,creationTime,logInNumber,sex,userAvatars,isdel)" - + " VALUES(#{userName},#{uniqueIdentificationAccount},#{documentType},#{IDNumber},#{provinceId},#{cityId},#{countries},#{dateBirth},#{educationDegree},#{schoolId},#{phone},#{weChatID},#{email},#{account},#{password},now(),0,#{sex},#{userAvatars},0)") - @Options(useGeneratedKeys=true, keyProperty="userId", keyColumn="userId") - void addUser(UserInfo user); - - @Select({" "}) - List queryUserInfo(UserInfo userInfo); - - @Update( {"" }) - void deleteUser(Integer userId); - - //修改用户 - @Update("UPDATE hr_user_info SET userName = #{userName},uniqueIdentificationAccount = #{uniqueIdentificationAccount},documentType = #{documentType},IDNumber = #{IDNumber},provinceId = #{provinceId}," - + "cityId = #{cityId},countries = #{countries},dateBirth = #{dateBirth},educationDegree = #{educationDegree},schoolId = #{schoolId}," - + "phone = #{phone},weChatID = #{weChatID},email = #{email},account = #{account},sex = #{sex},userAvatars = #{userAvatars} where userId = #{userId}") - void updateUser(UserInfo user); - - //修改个人档案添加功能(删除后添加用户个人档案) - @Insert({ "" }) - void updateUserProfiles(UserProfiles userProfiles); - - //修改个人档案删除功能 - @Delete( {"" }) - void deleteUserProfiles(Integer userId); - - //修改用户组织关系添加功能 - @Insert({ "" }) - void updateOrganizationRelationship(OrganizationRelationship organizationRelationship); - - //修改用户组织架构删除功能 - @Delete( {"" }) - void deleteOR(Integer userId,Integer platformId); - - //修改员工 - @Update("UPDATE staff SET staffName = #{staffName},staffWorkNumber = #{staffWorkNumber},phone = #{phone},email = #{email},staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}," - + "staffProfessionalArchitectureId = #{staffProfessionalArchitectureId},staffGradeId = #{staffGradeId},roleId = #{roleId} where phone = #{phone}") - void updateStaff(Staff staff); - - //修改学生 - @Update("UPDATE student SET studentName = #{studentName},studentNumber = #{studentNumber},phone = #{phone},email = #{email},roleId = #{roleId}" - + ",schoolId = #{schoolId},professionalId = #{professionalId},gradeId = #{gradeId},classId = #{classId} where phone = #{phone}") - void updateStudent(Student student); - - //登陆 - @Select("SELECT hui.schoolId,hui.account,hui.cityId,hui.countries,hui.creationTime,hui.dateBirth,hui.documentType,hui.educationDegree,hui.email,hui.iDNumber,hui.logInNumber,hui.phone,hui.provinceId,hui.sex,hui.uniqueIdentificationAccount,hui.userAvatars,hui.userId,hui.userName,hui.weChatID from hr_user_info hui where hui.isdel=0 and hui.userId = #{userId} ") - UserInfo logins(UserInfo userInfo); - - //登陆账号密码 - @Select("SELECT hui.schoolId,hui.account,hui.cityId,hui.countries,hui.creationTime,hui.dateBirth,hui.documentType,hui.educationDegree,hui.email,hui.iDNumber,hui.logInNumber,hui.phone,hui.provinceId,hui.sex,hui.uniqueIdentificationAccount,hui.userAvatars,hui.userId,hui.userName,hui.weChatID from hr_user_info hui where hui.isdel=0 and hui.account = #{account} and password = #{password} ") - UserInfo loginsAP(UserInfo userInfo); - - //查询用户角色 - @Select("SELECT userId,roleId from hr_organization_relationship where userId = #{userId} and schoolId = #{schoolId}") - List loginRole(Integer userId,Integer schoolId); - - //查询用户组织关系 - @Select("SELECT schoolId,schoolName,userId from hr_organization_relationship where userId = #{userId} GROUP BY schoolId") - List queryOrganizationRelationship(Integer userId); - - //查询用户组织关系 - @Select("SELECT * from hr_organization_relationship where userId = #{userId} and roleId = #{roleId} and schoolId = #{schoolId}") - List queryOrganizationRelationshipAll(Integer userId,Integer roleId,Integer schoolId); - - //查询用户绑定平台信息 - @Select("SELECT hp.* FROM hr_platform hp,hr_organization_relationship hor WHERE hor.platformId = hp.platformId and hor.userId = #{userId} and hor.isdel = 0 GROUP BY platformId") - List queryUserPlatform(Integer userId); - - //查询用户手机 - @Select("SELECT userId from hr_user_info where isdel=0 and phone = #{phone}") - List queryPhone(String phone); - - //查询用户详情 - @Select({" "}) - UserInfo queryUserInfoDetails(Integer userId); - - //查询用户详情 - @Select({" "}) - List queryUserProfiles(Integer userId); - - //查询用户组织架构详情 - @Select({" "}) - List queryUserOR(Integer userId,Integer platformId); - - //查询用户组织架构详情 - @Select({" "}) - List queryUserIdOR(Integer userId); - - //模糊查询客户 - @Select({" "}) - List queryCustomer(@Param("searchContent")String searchContent, @Param("customerIds")List customerIds); - - /** - * 批量插入用户 - * @param users - */ - @Insert({ - "" - }) - void addUserM(@Param("users") List users); - - //修改用户头像 - @Update("update hr_user_info set userAvatars=#{userAvatars} where userId=#{userId}") - void updateUserAvatars(@Param("userAvatars") String userAvatars, @Param("userId") Integer userId); - - //更新用户登录次数和最后一次登录时间 - @Update({ "UPDATE user SET logInNumber=logInNumber+1, lastTimeOfLanding=now() WHERE userId=#{userId}"}) - void updateLogInNumber(UserM user); - - //更新学生登录次数和最后一次登录时间 - @Update({ "UPDATE student SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE phone=#{phone}"}) - void updateStudentLogInNumber(UserM user); - - //更新员工登录次数和最后一次登录时间 - @Update({ "UPDATE staff SET logNumber=logNumber+1, lastTimeOfLanding=now() WHERE phone=#{phone}"}) - void updateStaffLogInNumber(UserM user); - - //查询账号是否存在 - @Select("SELECT account,email,userName,userId,uniqueIdentificationAccount,phone from hr_user_info where isdel = 0 and account = #{account}") - List queryAccountIsExist(String account); - - //查询账号是否存在 - @Select("SELECT hor.* from hr_organization_relationship hor,hr_user_info hui where hor.isdel = 0 and hui.account = #{account} and hor.userId = hui.userId and hor.schoolId = #{schoolId}") - List queryAccountIsExistOR(String account,Integer schoolId); - - //查询学号、工号是否存在 - @Select("SELECT userId,workNumber,schoolId,roleId from hr_organization_relationship where workNumber = #{workNumber} and roleId = #{roleId} and schoolId = #{schoolId}") - List queryWorkNumberIsExist(String workNumber,Integer roleId,Integer schoolId); - - //查询平台 - @Select("SELECT platformId,platformName,domainName,createTime from hr_platform where FIND_IN_SET (platformId,#{platformId})") - List queryPlatform(String platformId); - - //删除平台 - @Select("Update hr_organization_relationship set isdel = 1 where platformId = #{platformId} and userId = #{userId}") - void deletePlatform(Integer platformId,Integer userId); - - //========全承珠 - @Select("select userId,password,accountRole,logInNumber,workNumber,phone,uniqueIdentificationAccount,schoolId from user " - + " where isdel=0 and password=#{password} and (phone=#{userAccount} or workNumber=#{userAccount} or uniqueIdentificationAccount=#{userAccount})") - UserM loginsQ(@Param("userAccount") String userAccount, @Param("password") String password); - - - @Update("update user set lastTimeOfLanding=#{time},logInNumber=#{logInNumber} where userId=#{userId}") - void updateUserQ(@Param("time") String time, @Param("logInNumber") Integer logInNumber, @Param("userId") Integer userId); - - /** - * 批量插入个人档案 - */ - @Insert({ - "" - }) - void addPersonalFile(UserProfiles userProfiles); - - //添加用户组织关系 - @Insert({ "" }) - void addOrganizationRelationship(OrganizationRelationship organizationRelationship); - - //删除用户组织架构关系 - @Update( {"" }) - void deleteOrganizationRelationship(Integer userId); +public interface UserInfoMapper { + @Update({""}) + void update(User user); + + @Insert("INSERT INTO hr_user_info(userName,uniqueIdentificationAccount,documentType,IDNumber,provinceId,cityId,countries,dateBirth,educationDegree,schoolId,phone,weChatID,email,account,password,creationTime,logInNumber,sex,userAvatars,isdel)" + + " VALUES(#{userName},#{uniqueIdentificationAccount},#{documentType},#{IDNumber},#{provinceId},#{cityId},#{countries},#{dateBirth},#{educationDegree},#{schoolId},#{phone},#{weChatID},#{email},#{account},#{password},now(),0,#{sex},#{userAvatars},0)") + @Options(useGeneratedKeys = true, keyProperty = "userId", keyColumn = "userId") + void addUser(UserInfo user); + + @Insert("INSERT INTO student(workNumber,schoolId,professionalId,gradeId,classId,professionalName,gradeName,className,userId,platformId,roleId,isdel)" + + " VALUES(#{workNumber},#{schoolId},#{professionalId},#{gradeId},#{classId},#{professionalName},#{gradeName},#{className},#{userId},#{platformId},#{roleId},0)") + void userAddStudent(Student student); + + @Insert("INSERT INTO staff(workNumber,schoolId,staffProfessionalArchitectureId,staffGradeId,staffProfessionalArchitectureName,staffGradeName,roleId,userId,platformId,isdel)" + + " VALUES(#{workNumber},#{schoolId},#{staffProfessionalArchitectureId},#{staffGradeId},#{staffProfessionalArchitectureName},#{staffGradeName},#{roleId},#{userId},#{platformId},0)") + void userAddStaff(Staff staff); + + @Select({" "}) + List queryUserInfo(UserInfo userInfo); + + @Update({""}) + void deleteUser(Integer userId); + + @Update({""}) + void deleteStaff(Integer userId); + + @Update({""}) + void deleteStudent(Integer userId); + + //修改用户 + @Update("UPDATE hr_user_info SET userName = #{userName},uniqueIdentificationAccount = #{uniqueIdentificationAccount},documentType = #{documentType},IDNumber = #{IDNumber},provinceId = #{provinceId}," + + "cityId = #{cityId},countries = #{countries},dateBirth = #{dateBirth},educationDegree = #{educationDegree},schoolId = #{schoolId}," + + "phone = #{phone},weChatID = #{weChatID},email = #{email},account = #{account},sex = #{sex},userAvatars = #{userAvatars} where userId = #{userId}") + void updateUser(UserInfo user); + + //修改用户 + @Update("UPDATE hr_user_info SET roleId = #{roleId} where userId = #{userId}") + void updateUserRoleId(Integer userId,String roleId); + + //修改个人档案添加功能(删除后添加用户个人档案) + @Insert({""}) + void updateUserProfiles(UserProfiles userProfiles); + + //修改个人档案删除功能 + @Delete({""}) + void deleteUserProfiles(Integer userId); + + //修改用户组织关系添加功能 + @Insert({""}) + void updateOrganizationRelationship(OrganizationRelationship organizationRelationship); + + //修改员工组织架构删除功能 + @Delete({""}) + void deleteStaffOR(Integer userId, Integer platformId); + + //修改学生组织架构删除功能 + @Delete({""}) + void deleteStudentOR(Integer userId, Integer platformId); + + //修改员工 + @Update("UPDATE staff SET staffName = #{staffName},staffWorkNumber = #{staffWorkNumber},phone = #{phone},email = #{email},staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}," + + "staffProfessionalArchitectureId = #{staffProfessionalArchitectureId},staffGradeId = #{staffGradeId},roleId = #{roleId} where phone = #{phone}") + void updateStaff(Staff staff); + + //修改学生 + @Update("UPDATE student SET studentName = #{studentName},studentNumber = #{studentNumber},phone = #{phone},email = #{email},roleId = #{roleId}" + + ",schoolId = #{schoolId},professionalId = #{professionalId},gradeId = #{gradeId},classId = #{classId} where phone = #{phone}") + void updateStudent(Student student); + + //登陆 + @Select("SELECT hui.schoolId,hui.account,hui.cityId,hui.countries,hui.creationTime,hui.dateBirth,hui.documentType,hui.educationDegree,hui.email,hui.iDNumber,hui.logInNumber,hui.phone,hui.provinceId,hui.sex,hui.uniqueIdentificationAccount,hui.userAvatars,hui.userId,hui.userName,hui.weChatID from hr_user_info hui where hui.isdel=0 and hui.userId = #{userId} ") + UserInfo logins(UserInfo userInfo); + + //登陆账号密码 + @Select("SELECT hui.schoolId,hui.account,hui.cityId,hui.countries,hui.creationTime,hui.dateBirth,hui.documentType,hui.educationDegree,hui.email,hui.iDNumber,hui.logInNumber,hui.phone,hui.provinceId,hui.sex,hui.uniqueIdentificationAccount,hui.userAvatars,hui.userId,hui.userName,hui.weChatID from hr_user_info hui where hui.isdel=0 and hui.account = #{account} and password = #{password} ") + UserInfo loginsAP(UserInfo userInfo); + + //查询用户角色 + @Select("SELECT userId,roleId from hr_organization_relationship where userId = #{userId} and schoolId = #{schoolId}") + List loginRole(Integer userId, Integer schoolId); + + //查询用户组织关系 + @Select("SELECT schoolId,schoolName,userId from hr_organization_relationship where userId = #{userId} GROUP BY schoolId") + List queryOrganizationRelationship(Integer userId); + + //查询用户组织关系 + @Select("SELECT * from hr_organization_relationship where userId = #{userId} and roleId = #{roleId} and schoolId = #{schoolId}") + List queryOrganizationRelationshipAll(Integer userId, String roleId, Integer schoolId); + +// //查询用户绑定平台信息 +// @Select("SELECT hp.* FROM hr_platform hp,hr_organization_relationship hor WHERE hor.platformId = hp.platformId and hor.userId = #{userId} and hor.isdel = 0 GROUP BY platformId") +// List queryUserPlatform(Integer userId); + + //查询用户绑定学生的平台信息 + @Select("SELECT hp.* FROM hr_platform hp,student stu WHERE stu.platformId = hp.platformId and stu.userId = #{userId} and stu.isdel = 0 GROUP BY platformId") + List queryUserPlatformStudent(Integer userId); + + //查询用户绑定员工的平台信息 + @Select("SELECT hp.* FROM hr_platform hp,staff sta WHERE sta.platformId = hp.platformId and sta.userId = #{userId} and sta.isdel = 0 GROUP BY platformId") + List queryUserPlatformStaff(Integer userId); + + //查询用户手机 + @Select("SELECT userId from hr_user_info where isdel=0 and phone = #{phone}") + List queryPhone(String phone); + + //查询用户详情 + @Select({" "}) + UserInfo queryUserInfoDetails(Integer userId); + + //查询用户详情 + @Select({" "}) + List queryUserProfiles(Integer userId); + + //查询用户组织架构详情 + @Select({" "}) + List queryUserOR(Integer userId, Integer platformId); + + //查询员工组织架构详情 + @Select({" "}) + List queryStaffOR(Integer userId, Integer platformId); + + //查询学生组织架构详情 + @Select({" "}) + List queryStudentOR(Integer userId, Integer platformId); + + //查询用户组织架构详情 + @Select({" "}) + List queryUserIdOR(Integer userId); + + //查询用户员工详情 + @Select({" "}) + List queryUserStaff(Integer userId); + + //查询用户学生详情 + @Select({" "}) + List queryUserStudent(Integer userId); + + //模糊查询客户 + @Select({" "}) + List queryCustomer(@Param("searchContent") String searchContent, @Param("customerIds") List customerIds); + + /** + * 批量插入用户 + * + * @param users + */ + @Insert({ + "" + }) + void addUserM(@Param("users") List users); + + //修改用户头像 + @Update("update hr_user_info set userAvatars=#{userAvatars} where userId=#{userId}") + void updateUserAvatars(@Param("userAvatars") String userAvatars, @Param("userId") Integer userId); + + //更新用户登录次数和最后一次登录时间 + @Update({"UPDATE user SET logInNumber=logInNumber+1, lastTimeOfLanding=now() WHERE userId=#{userId}"}) + void updateLogInNumber(UserM user); + + //更新学生登录次数和最后一次登录时间 + @Update({"UPDATE student SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE phone=#{phone}"}) + void updateStudentLogInNumber(UserM user); + + //更新员工登录次数和最后一次登录时间 + @Update({"UPDATE staff SET logNumber=logNumber+1, lastTimeOfLanding=now() WHERE phone=#{phone}"}) + void updateStaffLogInNumber(UserM user); + + //查询账号是否存在 + @Select("SELECT account,email,userName,userId,uniqueIdentificationAccount,phone from hr_user_info where isdel = 0 and account = #{account}") + List queryAccountIsExist(String account); + + //查询账号是否存在 + @Select("SELECT hor.* from hr_organization_relationship hor,hr_user_info hui where hor.isdel = 0 and hui.account = #{account} and hor.userId = hui.userId and hor.schoolId = #{schoolId}") + List queryAccountIsExistOR(String account, Integer schoolId); + + //查询学号、工号是否存在 + @Select("SELECT userId,workNumber,schoolId,roleId from hr_organization_relationship where workNumber = #{workNumber} and roleId = #{roleId} and schoolId = #{schoolId}") + List queryWorkNumberIsExist(String workNumber, Integer roleId, Integer schoolId); + + //查询平台 + @Select("SELECT platformId,platformName,domainName,createTime from hr_platform where FIND_IN_SET (platformId,#{platformId})") + List queryPlatform(String platformId); + + //查询学生 + @Select("SELECT * from student where platformId = #{platformId} and userId = #{userId} and isdel=0") + List queryStudent1(Integer platformId, Integer userId); + + //查询员工 + @Select("SELECT * from staff where platformId = #{platformId} and userId = #{userId} and isdel=0") + List queryStaff(Integer platformId, Integer userId); + + //删除平台 + @Update("Update hr_organization_relationship set isdel = 1 where platformId = #{platformId} and userId = #{userId}") + void deletePlatform(Integer platformId, Integer userId); + + //========全承珠 + @Select("select userId,password,accountRole,logInNumber,workNumber,phone,uniqueIdentificationAccount,schoolId from user " + + " where isdel=0 and password=#{password} and (phone=#{userAccount} or workNumber=#{userAccount} or uniqueIdentificationAccount=#{userAccount})") + UserM loginsQ(@Param("userAccount") String userAccount, @Param("password") String password); + + + @Update("update user set lastTimeOfLanding=#{time},logInNumber=#{logInNumber} where userId=#{userId}") + void updateUserQ(@Param("time") String time, @Param("logInNumber") Integer logInNumber, @Param("userId") Integer userId); + + /** + * 批量插入个人档案 + */ + @Insert({ + "" + }) + void addPersonalFile(UserProfiles userProfiles); + + //添加用户组织关系 + @Insert({""}) + void addOrganizationRelationship(OrganizationRelationship organizationRelationship); + + //删除用户组织架构关系 + @Update({""}) + void deleteOrganizationRelationship(Integer userId); } \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/service/StaffService.java b/src/main/java/com/yipin/liuwanr/service/StaffService.java index 52580c4..d7a136a 100644 --- a/src/main/java/com/yipin/liuwanr/service/StaffService.java +++ b/src/main/java/com/yipin/liuwanr/service/StaffService.java @@ -64,7 +64,7 @@ public class StaffService { //用户角色 user.setAccountRole(staff.getRoleId()); //工号 - user.setWorkNumber(staff.getStaffWorkNumber()); + user.setWorkNumber(staff.getWorkNumber()); //手机号 user.setPhone(staff.getPhone()); //邮箱 diff --git a/src/main/java/com/yipin/liuwanr/service/StudentService.java b/src/main/java/com/yipin/liuwanr/service/StudentService.java index 666fb61..a672012 100644 --- a/src/main/java/com/yipin/liuwanr/service/StudentService.java +++ b/src/main/java/com/yipin/liuwanr/service/StudentService.java @@ -237,9 +237,9 @@ public class StudentService { Student student = students.get(i); // 学校id student.setSchoolId(schoolId); - + Student stu=studentMapper.getStudent(student); - + if(stu!=null) { // 专业id student.setProfessionalId(stu.getProfessionalId()); @@ -256,7 +256,7 @@ public class StudentService { // 用户角色 user.setAccountRole(student.getRoleId()); // 工号 - user.setWorkNumber(student.getStudentNumber()); + user.setWorkNumber(student.getWorkNumber()); // 手机号 user.setPhone(student.getPhone()); // 邮箱 @@ -267,7 +267,7 @@ public class StudentService { user.setSchoolId(schoolId); users.add(user); - + }else { students.remove(i); i--; diff --git a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java index 829dd34..3094a99 100644 --- a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java +++ b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java @@ -50,108 +50,6 @@ public class UserInfoService { @Autowired private OrganizationRelationshipMapper organizationRelationshipMapper; - /** - * 批量删除学生信息 - */ - @Transactional - public HashMap deleteStudent(Integer[] ids){ - HashMap resp = new HashMap(); -// UpdateWrapper updateWrapper = new UpdateWrapper(); -// UserInfo userInfo = new UserInfo(); -// for (Integer id:ids){ -// userInfo.setUserId(id); -// } -// //修改学生状态信息码为1 -// updateWrapper.eq("isdel",1); -// int update = userInfoMapper.update(userInfo, updateWrapper); - ArrayList list = new ArrayList<>(); - for (Integer id : ids){ - list.add(id); - } - int update = userInfoMapper.updateStudentInfo(list); - if (update>0){ - resp.put(RETCODE,200); - }else{ - resp.put(RETCODE,500); - resp.put(RETVALUE,"student/delete Invalid"); - } - return resp; - } - - /** - * 添加学生信息 - */ - public HashMap addUserInfo(UserInfo userInfo){ - HashMap resp = new HashMap<>(); - try { - userInfo.setPassword("hanran123"); - int insert = userInfoMapper.insertUserInfo(userInfo); - if (insert>0){ - resp.put(RETCODE,200); - }else{ - resp.put(RETCODE,400); - resp.put(RETVALUE,"student/insertUSERINFO Invalid"); - } - }catch (RuntimeException e){ - logger.error(e); - resp.put(RETCODE,500); - resp.put(RETVALUE,"student/insertUSERINFO abnormal"); - } - return resp; - } - public HashMap addOrganizationRelationship(OrganizationRelationship ship){ - HashMap resp = new HashMap<>(); - try { -// userInfoMapper.insert(userInfo); -// int insert = organizationRelationshipMapper.insert(ship); - int insert = organizationRelationshipMapper.insertOrganizationRelationship(ship); - if (insert>0){ - resp.put(RETCODE,200); - }else{ - resp.put(RETCODE,400); - resp.put(RETVALUE,"student/insertORGANIZA Invalid"); - } - }catch (RuntimeException e){ - resp.put(RETCODE,500); - resp.put(RETVALUE,"student/insertORGANIZA abnormal"); - } - return resp; - } - - /** - * 批量查询学生信息 - */ - @Transactional - public HashMap queryStudent(StudentInfo studentInfo,Integer pageNo,Integer pageSize){ - HashMap resp = new HashMap(); - try { - if(pageNo!=null&&pageSize!=null) { - PageHelper.startPage(pageNo, pageSize); - List list = userInfoMapper.queryStudent(studentInfo); - PageInfo info=new PageInfo(list); - int total1 = (int) info.getTotal(); - int totalPages; - totalPages = total1 / pageSize; - if (total1 % pageSize != 0){ - totalPages ++; - } - long total = total1; - resp.put("retvalue", new PageResult(total, list,totalPages)); - resp.put("retcode", 200); - }else { - List list = userInfoMapper.queryStudent(studentInfo); - resp.put("retvalue", list); - resp.put("retcode", 200); - } - } catch (RuntimeException e) { - logger.error(e.getMessage()); - resp.put("retcode", 500); - resp.put("retvalue", "查询用户失败!"); - return resp; - } - return resp; - } - public HashMap login(String id, String password){ HashMap resp = new HashMap(); User user = null; @@ -198,19 +96,33 @@ public class UserInfoService { } //添加用户 - public HashMap addUser(UserInfo user){ + @Transactional + public HashMap addUser(UserInfo user,Student student,List staffList,List userProfilesList){ HashMap resp = new HashMap(); try { user.setPassword("huoran123");//设置默认密码 userInfoMapper.addUser(user); Integer userId = user.getUserId(); - resp.put("userId",userId); + student.setUserId(userId); + userInfoMapper.userAddStudent(student); + int size = userProfilesList.size(); + for (int i = 0;i deleteUserInfo(List userIdList){ HashMap resp = new HashMap(); try { @@ -253,13 +166,15 @@ public class UserInfoService { for (int i=0;i updateUserRoleId(Integer userId,String roleId){ + HashMap resp = new HashMap(); + try { + userInfoMapper.updateUserRoleId(userId,roleId); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "更新用户失败!"); + throw new RuntimeException(); + } + return resp; + } + //更新个人档案 @Transactional public HashMap updateUserProfiles(List userProfilesList){ @@ -321,18 +252,53 @@ public class UserInfoService { return resp; } +// //更新用户组织架构 +// @Transactional +// public HashMap updateOrganizationRelationship(List OrganizationRelationshipList){ +// HashMap resp = new HashMap(); +// try { +// Integer size = OrganizationRelationshipList.size(); +// Integer userId = OrganizationRelationshipList.get(0).getUserId(); +// Integer platformId = OrganizationRelationshipList.get(0).getPlatformId(); +// userInfoMapper.deleteOR(userId,platformId); +// for (int i=0; i updateOrganizationRelationship(List OrganizationRelationshipList){ + public HashMap updateOR(List staffList,List studentList){ HashMap resp = new HashMap(); try { - Integer size = OrganizationRelationshipList.size(); - Integer userId = OrganizationRelationshipList.get(0).getUserId(); - Integer platformId = OrganizationRelationshipList.get(0).getPlatformId(); - userInfoMapper.deleteOR(userId,platformId); - for (int i=0; i resp = new HashMap(); HashMap obj = new HashMap(); Integer userId = userInfo.getUserId(); - Integer roleId = userInfo.getRoleId(); + String roleId = userInfo.getRoleId(); Integer schoolId = userInfo.getSchoolId(); try { UserInfo user=userInfoMapper.logins(userInfo); @@ -465,10 +431,14 @@ public class UserInfoService { if (userInfo!=null){ List userProfiles = userInfoMapper.queryUserProfiles(userId); obj.put("userProfilesList",userProfiles); - List platformList = userInfoMapper.queryUserPlatform(userId); - obj.put("platformList",platformList); - List ORList = userInfoMapper.queryUserIdOR(userId); - obj.put("ORList",ORList); + List staffPlatformList = userInfoMapper.queryUserPlatformStaff(userId); + obj.put("staffPlatformList",staffPlatformList); + List studentPlatformList= userInfoMapper.queryUserPlatformStudent(userId); + obj.put("studentPlatformList",studentPlatformList); + List staffList = userInfoMapper.queryUserStaff(userId); + obj.put("staffList",staffList); + List studentList = userInfoMapper.queryUserStudent(userId); + obj.put("studentList",studentList); resp.put("retvalue", obj); resp.put("retcode", 200); }else { @@ -488,8 +458,12 @@ public class UserInfoService { //查询用户组织架构详情 public HashMap queryUserOR(Integer userId,Integer platformId){ HashMap resp = new HashMap(); + HashMap obj = new HashMap(); try { - resp.put("retvalue", userInfoMapper.queryUserOR(userId,platformId)); +// resp.put("retvalue", userInfoMapper.queryUserOR(userId,platformId)); + obj.put("staff", userInfoMapper.queryStaffOR(userId,platformId)); + obj.put("student", userInfoMapper.queryStudentOR(userId,platformId)); + resp.put("retvalue",obj); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); @@ -643,32 +617,26 @@ public class UserInfoService { return resp; } - //添加学生和员工信息 - @Transactional - public HashMap addStuStaff(List ORList,Integer userId) { + //查询平台 + public HashMap queryPlatform(String platformId){ HashMap resp = new HashMap(); try { - int size = ORList.size(); - for (int i=0;i queryPlatform(String platformId){ + //删除平台 + public HashMap deletePlatform(Integer platformId,Integer userId){ HashMap resp = new HashMap(); try { - resp.put("retvalue", userInfoMapper.queryPlatform(platformId)); + userInfoMapper.deletePlatform(platformId,userId); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); @@ -680,10 +648,13 @@ public class UserInfoService { } //删除平台 - public HashMap deletePlatform(Integer platformId,Integer userId){ - HashMap resp = new HashMap(); + public HashMap queryStuAndSta(Integer platformId,Integer userId){ + HashMap resp = new HashMap(); + HashMap obj = new HashMap(); try { - userInfoMapper.deletePlatform(platformId,userId); + obj.put("Staff", userInfoMapper.queryStaff(platformId,userId)); + obj.put("Student", userInfoMapper.queryStudent1(platformId,userId)); + resp.put("retvalue", obj); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); diff --git a/src/test/java/com/yipin/liuwanr/service/StaffServiceTest.java b/src/test/java/com/yipin/liuwanr/service/StaffServiceTest.java index fdbc8ed..75599fa 100644 --- a/src/test/java/com/yipin/liuwanr/service/StaffServiceTest.java +++ b/src/test/java/com/yipin/liuwanr/service/StaffServiceTest.java @@ -104,7 +104,7 @@ public class StaffServiceTest { staff.setStaffGradeId(2050); staff.setStaffName("zha"); staff.setStaffProfessionalArchitectureId(2057); - staff.setStaffWorkNumber("1222"); + staff.setWorkNumber("1222"); staff.setUniqueIdentificationAccount("204312221598238094000"); HashMap addStaff = staffService.addStaff(staff); for (String s : addStaff.keySet()) { @@ -172,7 +172,7 @@ public class StaffServiceTest { staff.setStaffId(118); staff.setStaffName("世杰-教师"); staff.setStaffProfessionalArchitectureId(2057); - staff.setStaffWorkNumber("123"); + staff.setWorkNumber("123"); staff.setUniqueIdentificationAccount("20431231596424406000"); userVO.setStaff(staff); user.setAccountRole(3); diff --git a/src/test/java/com/yipin/liuwanr/service/StudentServiceTest.java b/src/test/java/com/yipin/liuwanr/service/StudentServiceTest.java index 344d2c3..6fa78b4 100644 --- a/src/test/java/com/yipin/liuwanr/service/StudentServiceTest.java +++ b/src/test/java/com/yipin/liuwanr/service/StudentServiceTest.java @@ -21,62 +21,62 @@ public class StudentServiceTest { /** * 新增学生 */ - @Test - public void addStudent(){ - UserInfo userInfo = new UserInfo(); - OrganizationRelationship ship = new OrganizationRelationship(); - userInfo.setAccount(""); - userInfo.setUniqueIdentificationAccount("huoran999"); - userInfo.setSchoolId(1); - userInfo.setUserName("michonne"); - userInfo.setRoleId(4); - userInfo.setPassword("123456"); - ship.setProfessionalId(1); - ship.setGradeId(1); - ship.setClassId(1); - ship.setWorkNumber("888"); - HashMap map = userInfoService.addUserInfo(userInfo); - userInfoService.addOrganizationRelationship(ship); - for (String s : map.keySet()) { - System.out.println("key:" + s + "," + "value:" + map.get(s)); - } - HashMap map1 = userInfoService.addOrganizationRelationship(ship); - for (String ss : map1.keySet()) { - System.out.println("key:" + ss + "," + "value:" + map.get(ss)); - } - } +// @Test +// public void addStudent(){ +// UserInfo userInfo = new UserInfo(); +// OrganizationRelationship ship = new OrganizationRelationship(); +// userInfo.setAccount(""); +// userInfo.setUniqueIdentificationAccount("huoran999"); +// userInfo.setSchoolId(1); +// userInfo.setUserName("michonne"); +// userInfo.setRoleId(4); +// userInfo.setPassword("123456"); +// ship.setProfessionalId(1); +// ship.setGradeId(1); +// ship.setClassId(1); +// ship.setWorkNumber("888"); +// HashMap map = userInfoService.addUserInfo(userInfo); +// userInfoService.addOrganizationRelationship(ship); +// for (String s : map.keySet()) { +// System.out.println("key:" + s + "," + "value:" + map.get(s)); +// } +// HashMap map1 = userInfoService.addOrganizationRelationship(ship); +// for (String ss : map1.keySet()) { +// System.out.println("key:" + ss + "," + "value:" + map.get(ss)); +// } +// } /** * 查询学生信息 */ - @Test - public void queryStudent(){ - StudentInfo studentInfo = new StudentInfo(); - - OrganizationRelationship organizationRelationship = new OrganizationRelationship(); - studentInfo.setSchoolId(1); - studentInfo.setSearchContent("8"); - - - Integer pageNo = 1; - Integer pageSize = 3; - HashMap map = userInfoService.queryStudent(studentInfo, pageNo, pageSize); - for (String s : map.keySet()) { - System.out.println("key:" + s + "," + "value:" + map.get(s)); - } - } +// @Test +// public void queryStudent(){ +// StudentInfo studentInfo = new StudentInfo(); +// +// OrganizationRelationship organizationRelationship = new OrganizationRelationship(); +// studentInfo.setSchoolId(1); +// studentInfo.setSearchContent("8"); +// +// +// Integer pageNo = 1; +// Integer pageSize = 3; +// HashMap map = userInfoService.queryStudent(studentInfo, pageNo, pageSize); +// for (String s : map.keySet()) { +// System.out.println("key:" + s + "," + "value:" + map.get(s)); +// } +// } /** * 测试删除学生信息 */ - @Test - public void deleteStudent(){ - Integer[] userInfo = new Integer[]{13,14,15}; - - HashMap map = userInfoService.deleteStudent(userInfo); - for (String s : map.keySet()) { - System.out.println("key:" + s + "," + "value:" + map.get(s)); - } - } +// @Test +// public void deleteStudent(){ +// Integer[] userInfo = new Integer[]{13,14,15}; +// +// HashMap map = userInfoService.deleteStudent(userInfo); +// for (String s : map.keySet()) { +// System.out.println("key:" + s + "," + "value:" + map.get(s)); +// } +// } }