diff --git a/src/main/java/com/yipin/liuwanr/controller/StudentController.java b/src/main/java/com/yipin/liuwanr/controller/StudentController.java index 0b46d8c..d5451c7 100644 --- a/src/main/java/com/yipin/liuwanr/controller/StudentController.java +++ b/src/main/java/com/yipin/liuwanr/controller/StudentController.java @@ -1,14 +1,13 @@ package com.yipin.liuwanr.controller; -import com.yipin.liuwanr.entity.Response; -import com.yipin.liuwanr.entity.Student; -import com.yipin.liuwanr.entity.UserM; +import com.yipin.liuwanr.entity.*; import com.yipin.liuwanr.helper.QueryStudentUtils; import com.yipin.liuwanr.helper.RedisHelper; 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 com.yipin.liuwanr.vo.UserVO; -import org.apache.kafka.common.protocol.types.Field; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; @@ -27,6 +26,9 @@ public class StudentController { private StudentService studentService; @Autowired private UserService userService; + + @Autowired + private UserInfoService userInfoService; @Autowired RedisHelper redisHelper; @@ -58,42 +60,42 @@ public class StudentController { } - /** - * 添加学生 - */ - @Transactional - @PostMapping("/addStudent") - Response addStudent(@RequestBody UserVO vo) { - Response resp = new Response(); - Student student = vo.getStudent(); - UserM user = vo.getUser(); - if (student.getPhone()==null) { - resp.setStatus(300); - resp.setErrmessage("Parameter Invalid"); - } else { - HashMap ret = studentService.addStudent(student); - int status = (int) ret.get("retcode"); - if (200 == status) { - resp.setStatus(status); - resp.setMessage(ret.get("retvalue")); - HashMap ret1 = userService.addUser(user); - int status1 = (int)ret.get("retcode"); - if (status1 == 200){ - resp.setStatus(status1); - resp.setMessage(ret1.get("retvalue")); - }else { - resp.setStatus(status1); - resp.setErrmessage(ret1.get("retvalue").toString()); - throw new RuntimeException(); - } - } else { - resp.setStatus(status); - resp.setErrmessage(ret.get("retvalue").toString()); - throw new RuntimeException(); - } - } - return resp; - } +// /** +// * 添加学生 +// */ +// @Transactional +// @PostMapping("/addStudent") +// Response addStudent(@RequestBody UserVO vo) { +// Response resp = new Response(); +// Student student = vo.getStudent(); +// UserM user = vo.getUser(); +// if (student.getPhone()==null) { +// resp.setStatus(300); +// resp.setErrmessage("Parameter Invalid"); +// } else { +// HashMap ret = studentService.addStudent(student); +// int status = (int) ret.get("retcode"); +// if (200 == status) { +// resp.setStatus(status); +// resp.setMessage(ret.get("retvalue")); +// HashMap ret1 = userService.addUser(user); +// int status1 = (int)ret.get("retcode"); +// if (status1 == 200){ +// resp.setStatus(status1); +// resp.setMessage(ret1.get("retvalue")); +// }else { +// resp.setStatus(status1); +// resp.setErrmessage(ret1.get("retvalue").toString()); +// throw new RuntimeException(); +// } +// } else { +// resp.setStatus(status); +// resp.setErrmessage(ret.get("retvalue").toString()); +// throw new RuntimeException(); +// } +// } +// return resp; +// } /** @@ -118,102 +120,102 @@ public class StudentController { } return resp; } - - /** - * 根据professionalIds(专业id)查询所有学生 - * @param schoolId 必须 - * @param professionalId - * @param pageNo - * @param pageSize - * @return - */ - @GetMapping("queryStudent/byProfessionalIds") - Response queryStudentByProfessionalIds(@RequestParam Integer schoolId,@RequestParam Integer professionalId,Integer pageNo,Integer pageSize){ - Response resp = new Response(); - if (schoolId == null){ - resp.setMessage(300); - resp.setErrmessage("学校id为空,查询失败!"); - }else{ - HashMap ret = studentService.queryStudentByProfessionalIds(professionalId, pageNo, pageSize, schoolId); - QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue"); - } - return resp; - } - - /** - * 根据年级id查询所有学生信息 - * @param schoolId - * @param gradeId - * @param pageNo - * @param pageSize - * @return - */ - @GetMapping("queryStudent/byGradeId") - Response queryStudentByGradeId(@RequestParam Integer schoolId, @RequestParam Integer gradeId, Integer pageNo, Integer pageSize){ - Response resp = new Response(); - if (schoolId == null){ - resp.setMessage(300); - resp.setErrmessage("学校id为空,查询失败!"); - }else { - HashMap ret = studentService.queryStudentByGradeIds(gradeId, pageNo, pageSize, schoolId); - QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue"); - } - return resp; - } - /** - * 根据班级id查询所有学生信息 - * @param schoolId - * @param classId - * @param pageNo - * @param pageSize - * @return - */ - @GetMapping("queryStudent/byClassIds") - Response queryStudentByClassIds(@RequestParam Integer schoolId,@RequestParam Integer classId,Integer pageNo,Integer pageSize){ - - Response resp = new Response(); - if (schoolId == null){ - resp.setMessage(300); - resp.setErrmessage("学校id为空,查询失败!"); - }else { - HashMap ret = studentService.queryStudentByClassIds(classId, pageNo, pageSize, schoolId); - QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue"); - } - return resp; - } - - /** - * 删除学生 - */ - @PostMapping("/deleteStudent") - Response deleteStudent(@RequestBody List studentList) { - Response resp = new Response(); - int size = studentList.size(); - for (int i=0;i ret = studentService.deleteStudent(studentId,phone); - 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; - } +// +// /** +// * 根据professionalIds(专业id)查询所有学生 +// * @param schoolId 必须 +// * @param professionalId +// * @param pageNo +// * @param pageSize +// * @return +// */ +// @GetMapping("queryStudent/byProfessionalIds") +// Response queryStudentByProfessionalIds(@RequestParam Integer schoolId,@RequestParam Integer professionalId,Integer pageNo,Integer pageSize){ +// Response resp = new Response(); +// if (schoolId == null){ +// resp.setMessage(300); +// resp.setErrmessage("学校id为空,查询失败!"); +// }else{ +// HashMap ret = studentService.queryStudentByProfessionalIds(professionalId, pageNo, pageSize, schoolId); +// QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue"); +// } +// return resp; +// } +// +// /** +// * 根据年级id查询所有学生信息 +// * @param schoolId +// * @param gradeId +// * @param pageNo +// * @param pageSize +// * @return +// */ +// @GetMapping("queryStudent/byGradeId") +// Response queryStudentByGradeId(@RequestParam Integer schoolId, @RequestParam Integer gradeId, Integer pageNo, Integer pageSize){ +// Response resp = new Response(); +// if (schoolId == null){ +// resp.setMessage(300); +// resp.setErrmessage("学校id为空,查询失败!"); +// }else { +// HashMap ret = studentService.queryStudentByGradeIds(gradeId, pageNo, pageSize, schoolId); +// QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue"); +// } +// return resp; +// } +// /** +// * 根据班级id查询所有学生信息 +// * @param schoolId +// * @param classId +// * @param pageNo +// * @param pageSize +// * @return +// */ +// @GetMapping("queryStudent/byClassIds") +// Response queryStudentByClassIds(@RequestParam Integer schoolId,@RequestParam Integer classId,Integer pageNo,Integer pageSize){ +// +// Response resp = new Response(); +// if (schoolId == null){ +// resp.setMessage(300); +// resp.setErrmessage("学校id为空,查询失败!"); +// }else { +// HashMap ret = studentService.queryStudentByClassIds(classId, pageNo, pageSize, schoolId); +// QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue"); +// } +// return resp; +// } +// +// /** +// * 删除学生 +// */ +// @PostMapping("/deleteStudent") +// Response deleteStudent(@RequestBody List studentList) { +// Response resp = new Response(); +// int size = studentList.size(); +// for (int i=0;i ret = studentService.deleteStudent(studentId,phone); +// 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; +// } /** * 更新学生 @@ -244,4 +246,116 @@ public class StudentController { } return resp; } + + /** + * 添加学生信息 + * 接收参数: + * 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; + } + + /** + * 查询学生信息 + * @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 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; + } } diff --git a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java index 117ce33..bf73ad8 100644 --- a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java +++ b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java @@ -33,127 +33,116 @@ public class UserInfoController { RedisHelper redisHelper; - /** - * 接收参数: - * UserInfo:account,userName,roleId,uniqueIdentificationAccount,phone,email - * OrganizationRelationship:workNumber,professionalClassId,gradeId,classId - */ - - @PostMapping("/addStudent") - Response addUserInfo(@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")); - 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, Integer[] professionalIds, String searchContent, Integer[] gradeIds, Integer[] classIds, Integer pageNo, Integer pageSize) { - Response response = new Response(); - UserInfo userInfo = new UserInfo(); - OrganizationRelationship ship = new OrganizationRelationship(); - HashMap ids = new HashMap<>(8); - if (schoolId == null) { - response.setStatus(300); - response.setErrmessage("学校信息为空"); - } else { - if (searchContent != null && searchContent != "") { - userInfo.setSearchContent(searchContent); - } - if (professionalIds.length > 0) { -// List professionalList = Arrays.asList(professionalId); - for (Integer professionalId:professionalIds){ - ship.setProfessionalId(professionalId); - } - } - if (gradeIds.length > 0) { -// List gradeList = Arrays.asList(gradeIds); - for (Integer gradeId:gradeIds){ - ship.setGradeId(gradeId); - } - } - if (classIds.length > 0) { -// List classList = Arrays.asList(classIds); - for (Integer classId:classIds){ - ship.setClassId(classId); - } - } - userInfo.setSchoolId(schoolId); -// HashMap map = userInfoService.queryStudent(userInfo,ship,pageNo,pageSize); +// /** +// * 接收参数: +// * 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; - } +// } +// 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; +// } /** * 添加用户 diff --git a/src/main/java/com/yipin/liuwanr/entity/StudentInfo.java b/src/main/java/com/yipin/liuwanr/entity/StudentInfo.java new file mode 100644 index 0000000..2bf8a80 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/StudentInfo.java @@ -0,0 +1,85 @@ +package com.yipin.liuwanr.entity; + +public class StudentInfo { + private Integer schoolId; + private String professionalIds; + private String classIds; + private String gradeIds; + private String searchContent; + private String logInNumber; + private String userName; + private String lastLoginTime; + private Integer roleId; + + public Integer getSchoolId() { + return schoolId; + } + + public void setSchoolId(Integer schoolId) { + this.schoolId = schoolId; + } + + public String getProfessionalIds() { + return professionalIds; + } + + public void setProfessionalIds(String professionalIds) { + this.professionalIds = professionalIds; + } + + public String getClassIds() { + return classIds; + } + + public void setClassIds(String classIds) { + this.classIds = classIds; + } + + public String getGradeIds() { + return gradeIds; + } + + public void setGradeIds(String gradeIds) { + this.gradeIds = gradeIds; + } + + public String getSearchContent() { + return searchContent; + } + + public void setSearchContent(String searchContent) { + this.searchContent = searchContent; + } + + public String getLogInNumber() { + return logInNumber; + } + + public void setLogInNumber(String logInNumber) { + this.logInNumber = logInNumber; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getLastLoginTime() { + return lastLoginTime; + } + + public void setLastLoginTime(String lastLoginTime) { + this.lastLoginTime = lastLoginTime; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } +} diff --git a/src/main/java/com/yipin/liuwanr/mapper/OrganizationRelationshipMapper.java b/src/main/java/com/yipin/liuwanr/mapper/OrganizationRelationshipMapper.java index 1c74204..34002a9 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/OrganizationRelationshipMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/OrganizationRelationshipMapper.java @@ -13,8 +13,8 @@ import java.util.List; public interface OrganizationRelationshipMapper{ @Insert({""}) Integer insertOrganizationRelationship(OrganizationRelationship organizationRelationship); diff --git a/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java index 14f57aa..92a96b9 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java @@ -13,26 +13,33 @@ 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); - /** - * 批量查询学生信息 - * @param - * @return - */ - @Select({ ""}) -// List queryStudent(UserInfo userInfo,OrganizationRelationship organizationRelationship); - List queryStudent(String searchContent,Integer schoolId,Integer gradeId,Integer classId,Integer professionalId); + List queryStudent(StudentInfo studentInfo); @Update({""}) void update(User user); @@ -155,8 +162,8 @@ public interface UserInfoMapper{ //查询用户详情 @Select({" "}) + "SELECT * from hr_user_info where isdel = 0 and userId = #{userId}", + " "}) UserInfo queryUserInfoDetails(Integer userId); //查询用户详情 @@ -178,33 +185,33 @@ public interface UserInfoMapper{ List queryUserIdOR(Integer userId); //模糊查询客户 - @Select({" "}) - List queryCustomer(@Param("searchContent")String searchContent, @Param("customerIds")List customerIds); + + " #{customerIds}" + +"" + + "", + " "}) + 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); + void updateUserAvatars(@Param("userAvatars") String userAvatars, @Param("userId") Integer userId); //更新用户登录次数和最后一次登录时间 @Update({ "UPDATE user SET logInNumber=logInNumber+1, lastTimeOfLanding=now() WHERE userId=#{userId}"}) @@ -268,6 +275,6 @@ public interface UserInfoMapper{ //删除用户组织架构关系 @Update( {"" }) + "" }) void deleteOrganizationRelationship(Integer userId); } \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java index 23651f6..829dd34 100644 --- a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java +++ b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java @@ -84,18 +84,18 @@ public class UserInfoService { public HashMap addUserInfo(UserInfo userInfo){ HashMap resp = new HashMap<>(); try { - userInfo.setPassword("hanran999"); + userInfo.setPassword("hanran123"); int insert = userInfoMapper.insertUserInfo(userInfo); if (insert>0){ resp.put(RETCODE,200); }else{ resp.put(RETCODE,400); - resp.put(RETVALUE,"student/insert Invalid"); + resp.put(RETVALUE,"student/insertUSERINFO Invalid"); } }catch (RuntimeException e){ logger.error(e); resp.put(RETCODE,500); - resp.put(RETVALUE,"student/insert Invalid"); + resp.put(RETVALUE,"student/insertUSERINFO abnormal"); } return resp; } @@ -109,11 +109,11 @@ public class UserInfoService { resp.put(RETCODE,200); }else{ resp.put(RETCODE,400); - resp.put(RETVALUE,"student/insert Invalid"); + resp.put(RETVALUE,"student/insertORGANIZA Invalid"); } }catch (RuntimeException e){ resp.put(RETCODE,500); - resp.put(RETVALUE,"student/insert Invalid"); + resp.put(RETVALUE,"student/insertORGANIZA abnormal"); } return resp; } @@ -122,21 +122,13 @@ public class UserInfoService { * 批量查询学生信息 */ @Transactional - public HashMap queryStudent(UserInfo userInfo,OrganizationRelationship ship,Integer pageNo,Integer pageSize){ + public HashMap queryStudent(StudentInfo studentInfo,Integer pageNo,Integer pageSize){ HashMap resp = new HashMap(); -// UserInfo user = new UserInfo(); -// OrganizationRelationship organizationRelationship = new OrganizationRelationship(); - String searchContent = userInfo.getSearchContent(); - Integer schoolId = userInfo.getSchoolId(); - Integer gradeId = ship.getGradeId(); - Integer classId = ship.getClassId(); - Integer professionalId = ship.getProfessionalId(); - try { if(pageNo!=null&&pageSize!=null) { PageHelper.startPage(pageNo, pageSize); - List list = userInfoMapper.queryStudent(searchContent, schoolId, gradeId, classId, professionalId); - PageInfo info=new PageInfo(list); + List list = userInfoMapper.queryStudent(studentInfo); + PageInfo info=new PageInfo(list); int total1 = (int) info.getTotal(); int totalPages; totalPages = total1 / pageSize; @@ -147,7 +139,7 @@ public class UserInfoService { resp.put("retvalue", new PageResult(total, list,totalPages)); resp.put("retcode", 200); }else { - List list = userInfoMapper.queryStudent(searchContent,schoolId,gradeId,classId,professionalId); + List list = userInfoMapper.queryStudent(studentInfo); resp.put("retvalue", list); resp.put("retcode", 200); } diff --git a/src/test/java/com/yipin/liuwanr/service/StudentServiceTest.java b/src/test/java/com/yipin/liuwanr/service/StudentServiceTest.java index 95003ae..344d2c3 100644 --- a/src/test/java/com/yipin/liuwanr/service/StudentServiceTest.java +++ b/src/test/java/com/yipin/liuwanr/service/StudentServiceTest.java @@ -1,6 +1,7 @@ package com.yipin.liuwanr.service; import com.yipin.liuwanr.entity.OrganizationRelationship; +import com.yipin.liuwanr.entity.StudentInfo; import com.yipin.liuwanr.entity.UserInfo; import org.junit.Test; import org.junit.runner.RunWith; @@ -50,26 +51,16 @@ public class StudentServiceTest { */ @Test public void queryStudent(){ - UserInfo userInfo = new UserInfo(); + StudentInfo studentInfo = new StudentInfo(); + OrganizationRelationship organizationRelationship = new OrganizationRelationship(); - userInfo.setSchoolId(1); - userInfo.setSearchContent("1"); - Integer[] a = {1,2}; - Integer[] b = {1,2}; - Integer[] c = {1,2}; + studentInfo.setSchoolId(1); + studentInfo.setSearchContent("8"); + - for (Integer aa: a){ - organizationRelationship.setProfessionalId(aa); - } - for (Integer bb:b){ - organizationRelationship.setGradeId(bb); - } - for (Integer cc:c){ - organizationRelationship.setClassId(cc); - } Integer pageNo = 1; Integer pageSize = 3; - HashMap map = userInfoService.queryStudent(userInfo, organizationRelationship, pageNo, pageSize); + HashMap map = userInfoService.queryStudent(studentInfo, pageNo, pageSize); for (String s : map.keySet()) { System.out.println("key:" + s + "," + "value:" + map.get(s)); }