diff --git a/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java b/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java index 47b21a8..91f037a 100644 --- a/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java +++ b/src/main/java/com/yipin/liuwanr/controller/ExperimentalClassController.java @@ -52,13 +52,20 @@ public class ExperimentalClassController { * @return */ @GetMapping("/queryExperimentalClass") - Response queryExperimentalClass(@RequestParam Integer schoolId,@RequestParam Integer courseId) { + Response queryExperimentalClass(@RequestParam Integer schoolId,@RequestParam Integer courseId,@RequestParam Integer userId) { Response resp = new Response(); if(StringUtils.isEmpty(schoolId)){ resp.setStatus(300); resp.setErrmessage("学校信息为空"); - }else{ - HashMap ret=classService.queryExperimentalClass(schoolId,courseId); + }else if(StringUtils.isEmpty(courseId)){ + resp.setStatus(300); + resp.setErrmessage("课程信息为空"); + }else if (StringUtils.isEmpty(userId)){ + resp.setStatus(300); + resp.setErrmessage("用户信息为空"); + } + else{ + HashMap ret=classService.queryExperimentalClass(schoolId,courseId,userId); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); @@ -190,20 +197,20 @@ public class ExperimentalClassController { * @param experimentalClassId * @return */ - @GetMapping("/queryExperimentalClassSP") - Response queryExperimentalClassSP(@RequestParam Integer experimentalClassId) { - Response resp = new Response(); - HashMap ret=classService.queryExperimentalClassSP(experimentalClassId); - 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; - } +// @GetMapping("/queryExperimentalClassSP") +// Response queryExperimentalClassSP(@RequestParam Integer experimentalClassId) { +// Response resp = new Response(); +// HashMap ret=classService.queryExperimentalClassSP(experimentalClassId); +// 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; +// } /** * 专业下拉框 @@ -248,10 +255,10 @@ public class ExperimentalClassController { //新增学生显示数据 - @GetMapping("/queryexperimentalClass") - Response queryexperimentalClass(@RequestParam Integer experimentalClassId) { + @GetMapping("/queryExperimentalClass") + Response queryExperimentalClass(@RequestParam Integer experimentalClassId) { Response resp = new Response(); - HashMap ret=classService.queryexperimentalClass(experimentalClassId); + HashMap ret=classService.queryExperimentalClass(experimentalClassId); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); @@ -269,20 +276,20 @@ public class ExperimentalClassController { * @param experimentalClassId * @return */ - @GetMapping("/queryStudentClass") - Response queryStudentClass(@RequestParam Integer experimentalClassId) { - Response resp = new Response(); - HashMap ret=classService.queryStudentClass(experimentalClassId); - 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; - } +// @GetMapping("/queryStudentClass") +//// Response queryStudentClass(@RequestParam Integer experimentalClassId) { +//// Response resp = new Response(); +//// HashMap ret=classService.queryStudentClass(experimentalClassId); +//// 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; +//// } /** * 添加实验班级 diff --git a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java index f90d850..40efd6a 100644 --- a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java +++ b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java @@ -1,13 +1,11 @@ package com.yipin.liuwanr.controller; -import com.yipin.liuwanr.entity.Staff; -import com.yipin.liuwanr.entity.Student; -import com.yipin.liuwanr.entity.UserInfo; -import com.yipin.liuwanr.entity.UserM; +import com.yipin.liuwanr.entity.*; import com.yipin.liuwanr.helper.RedisHelper; import com.yipin.liuwanr.service.StaffService; import com.yipin.liuwanr.service.StudentService; -import com.yipin.liuwanr.service.UserService; +import com.yipin.liuwanr.service.UserInfoService; +import com.yipin.liuwanr.vo.UserInfoVO; import com.yipin.liuwanr.vo.UserVO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.transaction.annotation.Transactional; @@ -23,15 +21,15 @@ import java.util.List; @RequestMapping("/userInfo") public class UserInfoController { - @Autowired - private UserService userService; - @Autowired private StudentService studentService; @Autowired private StaffService staffService; + @Autowired + private UserInfoService userInfoService; + @Autowired RedisHelper redisHelper; @@ -40,36 +38,33 @@ public class UserInfoController { */ @Transactional @PostMapping("/addUser") - Response addUser(@RequestBody UserVO vo) { + public Response addUser(@RequestBody UserInfoVO vo) { Response resp = new Response(); + //个人档案实体 + List userProfilesList = vo.getUserProfilesList(); + //学生员工实体list + List stuStaffList = vo.getStuStaffList(); //用户实体 - UserM user = vo.getUser(); - //学生实体 - Student student = vo.getStudent(); - //员工实体 - Staff staff = vo.getStaff(); + UserInfo user = vo.getUserInfo(); //用户手机号 String phone = user.getPhone(); //用户名称 - String name = user.getName(); + String name = user.getUserName(); //省份id Integer provinceId = user.getProvinceId(); //用户角色id - Integer accountRole = user.getAccountRole(); + Integer roleId = user.getRoleId(); //城市id Integer cityId = user.getCityId(); //学校id Integer schoolId = user.getSchoolId(); - if (phone==null||phone=="") { - resp.setStatus(300); - resp.setErrmessage("电话不能为空!"); - }else if(name==null||name==""){ + if(name==null||name==""){ resp.setStatus(300); resp.setErrmessage("姓名不能为空!"); }else if(provinceId==null){ resp.setStatus(300); resp.setErrmessage("省份不能为空!"); - }else if(accountRole==null){ + }else if(roleId==null){ resp.setStatus(300); resp.setErrmessage("用户角色不能为空!"); }else if(cityId==null){ @@ -79,13 +74,13 @@ public class UserInfoController { resp.setStatus(300); resp.setErrmessage("学校不能为空!"); }else { - HashMap ret = userService.addUser(user); + HashMap ret = userInfoService.addUser(user); + Integer userId = user.getUserId(); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); resp.setMessage(ret.get("retvalue")); - if (accountRole == 4){ - HashMap stu = studentService.addStudent(student); + HashMap stu = userInfoService.addPersonalFile(userProfilesList,userId); int stuStatus = (int) stu.get("retcode"); if (stuStatus == 200){ resp.setStatus(stuStatus); @@ -95,9 +90,7 @@ public class UserInfoController { resp.setErrmessage(stu.get("retvalue").toString()); throw new RuntimeException(); } - } - if(accountRole == 3||accountRole==2){ - HashMap sta = staffService.addStaff(staff); + HashMap sta = userInfoService.addStuStaff(stuStaffList,userId); int staStatus = (int) sta.get("retcode"); if (staStatus == 200){ resp.setStatus(staStatus); @@ -107,7 +100,6 @@ public class UserInfoController { resp.setErrmessage(sta.get("retvalue").toString()); throw new RuntimeException(); } - } } else { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); @@ -160,7 +152,7 @@ public class UserInfoController { if (endTime!=null&&endTime!="") { userInfo.setEndTime(endTime); } - HashMap ret = userService.queryUserInfo(userInfo,pageNo,pageSize); + HashMap ret = userInfoService.queryUserInfo(userInfo,pageNo,pageSize); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); @@ -177,54 +169,47 @@ public class UserInfoController { */ @Transactional @PostMapping("/deleteUserInfo") - Response deleteUser(@RequestBody List userList) { + public Response deleteUserInfo(@RequestBody List userList) { Response resp = new Response(); int size = userList.size(); for(int i=0;i ret = userService.deleteUser(userId); + HashMap ret = userInfoService.deleteUserInfo(userId); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); resp.setMessage(ret.get("retvalue")); - if (roleId==3||roleId==2){ - HashMap sta = userService.deleteStaff(user); - int staStatus = (int) ret.get("retcode"); + HashMap sta = userInfoService.deleteStaff(user); + int staStatus = (int) sta.get("retcode"); if (200 == staStatus) { resp.setStatus(staStatus); resp.setMessage(sta.get("retvalue")); + HashMap stu = userInfoService.deleteStudent(user); + int stuStatus = (int) stu.get("retcode"); + if (200 == stuStatus) { + resp.setStatus(stuStatus); + resp.setMessage(stu.get("retvalue")); + }else{ + resp.setStatus(stuStatus); + resp.setErrmessage(stu.get("retvalue").toString()); + throw new RuntimeException(); + } }else{ resp.setStatus(staStatus); resp.setErrmessage(sta.get("retvalue").toString()); throw new RuntimeException(); } - } - if (roleId==4){ - HashMap stu = userService.deleteStudent(user); - int stuStatus = (int) stu.get("retcode"); - if (200 == stuStatus) { - resp.setStatus(stuStatus); - resp.setMessage(stu.get("retvalue")); - }else{ - resp.setStatus(stuStatus); - resp.setErrmessage(stu.get("retvalue").toString()); - throw new RuntimeException(); - } - } - } else { + }else { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); throw new RuntimeException(); @@ -239,50 +224,41 @@ public class UserInfoController { */ @Transactional @PostMapping("/updateUser") - Response updateUser(@RequestBody UserVO vo) { + public Response updateUser(@RequestBody UserInfoVO vo) { Response resp = new Response(); - UserM user = vo.getUser(); + UserInfo user = vo.getUserInfo(); Staff staff = vo.getStaff(); Student student = vo.getStudent(); Integer userId = user.getUserId(); - Integer roleId = user.getAccountRole(); if (userId==null) { resp.setStatus(300); resp.setErrmessage("用户ID为空,修改用户失败!"); - }else if (roleId==null){ - resp.setStatus(300); - resp.setErrmessage("角色ID为空,修改用户失败!"); - } - else { - HashMap ret = userService.updateUser(user); + } else { + HashMap ret = userInfoService.updateUser(user); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); resp.setMessage(ret.get("retvalue")); - if (roleId ==3||roleId==2){ - HashMap sta = userService.updateStaff(staff); + HashMap sta = userInfoService.updateStaff(staff); int staStatus = (int) sta.get("retcode"); if (200 == status) { resp.setStatus(staStatus); resp.setMessage(sta.get("retvalue")); + HashMap stu = userInfoService.updateStudent(student); + int stuStatus = (int) stu.get("retcode"); + if (200 == status) { + resp.setStatus(stuStatus); + resp.setMessage(stu.get("retvalue")); + }else{ + resp.setStatus(stuStatus); + resp.setErrmessage(stu.get("retvalue").toString()); + throw new RuntimeException("修改学生失败!"); + } }else{ resp.setStatus(staStatus); resp.setErrmessage(sta.get("retvalue").toString()); throw new RuntimeException("修改员工失败!"); } - } - if (roleId ==4){ - HashMap stu = userService.updateStudent(student); - int stuStatus = (int) stu.get("retcode"); - if (200 == status) { - resp.setStatus(stuStatus); - resp.setMessage(stu.get("retvalue")); - }else{ - resp.setStatus(stuStatus); - resp.setErrmessage(stu.get("retvalue").toString()); - throw new RuntimeException("修改学生失败!"); - } - } } else { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); @@ -297,23 +273,27 @@ public class UserInfoController { * 登陆(前台传来的key必须是phone、password) */ @GetMapping("/logins") - Response logins(@RequestParam("phone") String phone, @RequestParam("password") String password, - HttpServletRequest req, HttpServletResponse res) { + Response logins(@RequestParam("account") String account, @RequestParam("password") String password, HttpServletRequest req, HttpServletResponse res) { Response resp = new Response(); - UserM user = new UserM(); - if (phone != null) { - user.setPhone(phone); - }if(password!=null) { + UserInfo user = new UserInfo(); + if (account == null || account=="") { + resp.setStatus(300); + resp.setErrmessage("用户账号为空,登录失败!"); + }else if(password ==null || password=="") { + resp.setStatus(300); + resp.setErrmessage("用户密码为空,登录失败!"); + }else{ + user.setAccount(account); user.setPassword(password); - } - HashMap ret = userService.logins(user); - 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()); + HashMap ret = userInfoService.logins(user); + 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; } @@ -322,17 +302,37 @@ public class UserInfoController { /** * 查询用户详情(ID) */ - @GetMapping("/queryUserDetails") - Response queryUserDetails(@RequestParam Integer userId, Integer roleId) { + @GetMapping("/queryUserInfoDetails") + Response queryUserInfoDetails(@RequestParam Integer userId) { Response resp = new Response(); - if (roleId == null){ + if (userId==null) { resp.setStatus(300); - resp.setErrmessage("用户角色id为空!查询失败!"); - }else if (userId==null) { + resp.setErrmessage("用户id为空!查询失败!"); + }else { + HashMap ret = userInfoService.queryUserInfoDetails(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; + } + + /** + * 查询用户详情(ID) + */ + @GetMapping("/queryUserProfiles") + Response queryUserProfiles(@RequestParam Integer userId) { + Response resp = new Response(); + if (userId==null) { resp.setStatus(300); resp.setErrmessage("用户id为空!查询失败!"); }else { - HashMap ret = userService.queryUserDetails(userId,roleId); + HashMap ret = userInfoService.queryUserProfiles(userId); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); @@ -352,7 +352,7 @@ public class UserInfoController { resp.setStatus(300); resp.setErrmessage("Parameter Invalid"); }else { - HashMap ret = userService.uploadUserAvatars(file,userId); + HashMap ret = userInfoService.uploadUserAvatars(file,userId); int status = (int) ret.get("retcode"); if (200 == status) { @@ -385,7 +385,7 @@ public class UserInfoController { resp.setStatus(300); resp.setErrmessage("用户角色不能为空!"); } else { - HashMap ret = userService.updateLogInNumber(user); + HashMap ret = userInfoService.updateLogInNumber(user); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); @@ -410,7 +410,7 @@ public class UserInfoController { resp.setStatus(300); resp.setErrmessage("城市id为空!查询失败!"); }else { - HashMap ret = userService.queryCustomer(cityId,provinceId); + HashMap ret = userInfoService.queryCustomer(cityId,provinceId); resp.setStatus(200); resp.setErrmessage("查询成功!"); int status = (int) ret.get("retcode"); @@ -429,13 +429,13 @@ public class UserInfoController { * 查询账号是否存在 */ @GetMapping("/queryAccountIsExist") - Response queryAccountIsExist(@RequestParam String userAccount) { + Response queryAccountIsExist(@RequestParam String account) { Response resp = new Response(); - if (userAccount==null) { + if (account==null) { resp.setStatus(300); resp.setErrmessage("账号为空!"); }else { - HashMap ret = userService.queryAccountIsExist(userAccount); + HashMap ret = userInfoService.queryAccountIsExist(account); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); @@ -458,7 +458,7 @@ public class UserInfoController { resp.setStatus(300); resp.setErrmessage("账号为空!"); }else { - HashMap ret = userService.queryWorkNumberIsExist(workNumber); + HashMap ret = userInfoService.queryWorkNumberIsExist(workNumber); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); diff --git a/src/main/java/com/yipin/liuwanr/entity/OrganizationRelationship.java b/src/main/java/com/yipin/liuwanr/entity/OrganizationRelationship.java new file mode 100644 index 0000000..1be7df7 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/OrganizationRelationship.java @@ -0,0 +1,164 @@ +package com.yipin.liuwanr.entity; + +public class OrganizationRelationship { + //用户id + private Integer userId; + //平台ID + private Integer platformId; + //学校id + private Integer schoolId; + //学校名称 + private String schoolName; + //角色ID + private Integer roleId; + //工号学号 + private String workNumber; + //一级部门ID + private Integer oneDepartmentId; + //二级部门ID + private Integer twoDepartmentId; + //一级部门名称 + private String oneDepartmentName; + //二级部门名称 + private String twoDepartmentName; + //绑定专业ID + private Integer professionalId; + //绑定专业名称 + private String professionalName; + //年级ID + private Integer gradeId; + //年级名称 + private String gradeName; + //班级ID + private Integer classId; + //班级名称 + private String className; + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getPlatformId() { + return platformId; + } + + public void setPlatformId(Integer platformId) { + this.platformId = platformId; + } + + public Integer getSchoolId() { + return schoolId; + } + + public void setSchoolId(Integer schoolId) { + this.schoolId = schoolId; + } + + public String getSchoolName() { + return schoolName; + } + + public void setSchoolName(String schoolName) { + this.schoolName = schoolName; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public String getWorkNumber() { + return workNumber; + } + + public void setWorkNumber(String workNumber) { + this.workNumber = workNumber; + } + + public Integer getOneDepartmentId() { + return oneDepartmentId; + } + + public void setOneDepartmentId(Integer oneDepartmentId) { + this.oneDepartmentId = oneDepartmentId; + } + + public Integer getTwoDepartmentId() { + return twoDepartmentId; + } + + public void setTwoDepartmentId(Integer twoDepartmentId) { + this.twoDepartmentId = twoDepartmentId; + } + + public String getOneDepartmentName() { + return oneDepartmentName; + } + + public void setOneDepartmentName(String oneDepartmentName) { + this.oneDepartmentName = oneDepartmentName; + } + + public String getTwoDepartmentName() { + return twoDepartmentName; + } + + public void setTwoDepartmentName(String twoDepartmentName) { + this.twoDepartmentName = twoDepartmentName; + } + + public Integer getProfessionalId() { + return professionalId; + } + + public void setProfessionalId(Integer professionalId) { + this.professionalId = professionalId; + } + + public String getProfessionalName() { + return professionalName; + } + + public void setProfessionalName(String professionalName) { + this.professionalName = professionalName; + } + + public Integer getGradeId() { + return gradeId; + } + + public void setGradeId(Integer gradeId) { + this.gradeId = gradeId; + } + + public String getGradeName() { + return gradeName; + } + + public void setGradeName(String gradeName) { + this.gradeName = gradeName; + } + + public Integer getClassId() { + return classId; + } + + public void setClassId(Integer classId) { + this.classId = classId; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } +} diff --git a/src/main/java/com/yipin/liuwanr/entity/PersonalFile.java b/src/main/java/com/yipin/liuwanr/entity/PersonalFile.java new file mode 100644 index 0000000..ac26428 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/PersonalFile.java @@ -0,0 +1,94 @@ +package com.yipin.liuwanr.entity; + +import java.util.List; + +/** + * 用户信息实体 + * + * @author Ning + */ +public class PersonalFile { + //个人档案id + private Integer personalFileId; + //个人职业id(1、学生 2、老师) + private Integer personalCareerId; + //绑定学校id + private Integer schoolId; + //绑定学科id + private Integer disciplineId; + //绑定专业类id + private Integer professionalClassId; + //绑定专业id + private Integer professionalId; + //用户id + private Integer userId; + + public Integer getPersonalFileId() { + return personalFileId; + } + + public void setPersonalFileId(Integer personalFileId) { + this.personalFileId = personalFileId; + } + + public Integer getPersonalCareerId() { + return personalCareerId; + } + + public void setPersonalCareerId(Integer personalCareerId) { + this.personalCareerId = personalCareerId; + } + + public Integer getSchoolId() { + return schoolId; + } + + public void setSchoolId(Integer schoolId) { + this.schoolId = schoolId; + } + + public Integer getDisciplineId() { + return disciplineId; + } + + public void setDisciplineId(Integer disciplineId) { + this.disciplineId = disciplineId; + } + + public Integer getProfessionalClassId() { + return professionalClassId; + } + + public void setProfessionalClassId(Integer professionalClassId) { + this.professionalClassId = professionalClassId; + } + + public Integer getProfessionalId() { + return professionalId; + } + + public void setProfessionalId(Integer professionalId) { + this.professionalId = professionalId; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + @Override + public String toString() { + return "PersonalFile{" + + "personalFileId=" + personalFileId + + ", personalCareerId=" + personalCareerId + + ", schoolId=" + schoolId + + ", disciplineId=" + disciplineId + + ", professionalClassId=" + professionalClassId + + ", professionalId=" + professionalId + + ", userId=" + userId + + '}'; + } +} diff --git a/src/main/java/com/yipin/liuwanr/entity/Staff.java b/src/main/java/com/yipin/liuwanr/entity/Staff.java index 3265d61..543df60 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Staff.java +++ b/src/main/java/com/yipin/liuwanr/entity/Staff.java @@ -1,7 +1,8 @@ package com.yipin.liuwanr.entity; public class Staff { - + //账号 + private String account; //员工主键ID private Integer staffId; //员工名称 @@ -36,7 +37,15 @@ public class Staff { private String staffProfessionalArchitectureIds; //绑定学校id private Integer schoolId; - + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + public Integer getSchoolId() { return schoolId; } diff --git a/src/main/java/com/yipin/liuwanr/entity/StuStaff.java b/src/main/java/com/yipin/liuwanr/entity/StuStaff.java new file mode 100644 index 0000000..47538a4 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/StuStaff.java @@ -0,0 +1,207 @@ +package com.yipin.liuwanr.entity; + +import java.util.List; + +//学生和老师管理员组织关系信息实体 +public class StuStaff { + //主键ID + private Integer id; + //账号 + private String account; + //用户id + private Integer userId; + //名字 + private String name; + //角色Id + private Integer roleId; + //工号 + private String workNumber; + //电话 + private String phone; + //邮件 + private String email; + //绑定员工年级架构ID + private Integer staffGradeId; + //绑定专业ID + private Integer staffProfessionalArchitectureId; + //绑定专业名称 + private String staffProfessionalArchitectureName; + //绑定员工年级名称 + private String staffGradeName; + //唯一标示性账号 + private String uniqueIdentificationAccount; + //绑定学校id + private Integer schoolId; + //绑定专业ID + private Integer professionalId; + //绑定年级ID + private Integer gradeId; + //绑定班级ID + private Integer classId; + //专业名称 + private String professionalName; + //年级名称 + private String gradeName; + //绑定班级名称 + private String className; + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getWorkNumber() { + return workNumber; + } + + public void setWorkNumber(String workNumber) { + this.workNumber = workNumber; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public Integer getStaffGradeId() { + return staffGradeId; + } + + public void setStaffGradeId(Integer staffGradeId) { + this.staffGradeId = staffGradeId; + } + + public Integer getStaffProfessionalArchitectureId() { + return staffProfessionalArchitectureId; + } + + public void setStaffProfessionalArchitectureId(Integer staffProfessionalArchitectureId) { + this.staffProfessionalArchitectureId = staffProfessionalArchitectureId; + } + + public String getStaffProfessionalArchitectureName() { + return staffProfessionalArchitectureName; + } + + public void setStaffProfessionalArchitectureName(String staffProfessionalArchitectureName) { + this.staffProfessionalArchitectureName = staffProfessionalArchitectureName; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public String getStaffGradeName() { + return staffGradeName; + } + + public void setStaffGradeName(String staffGradeName) { + this.staffGradeName = staffGradeName; + } + + public String getUniqueIdentificationAccount() { + return uniqueIdentificationAccount; + } + + public void setUniqueIdentificationAccount(String uniqueIdentificationAccount) { + this.uniqueIdentificationAccount = uniqueIdentificationAccount; + } + + public Integer getSchoolId() { + return schoolId; + } + + public void setSchoolId(Integer schoolId) { + this.schoolId = schoolId; + } + + public Integer getProfessionalId() { + return professionalId; + } + + public void setProfessionalId(Integer professionalId) { + this.professionalId = professionalId; + } + + public Integer getGradeId() { + return gradeId; + } + + public void setGradeId(Integer gradeId) { + this.gradeId = gradeId; + } + + public Integer getClassId() { + return classId; + } + + public void setClassId(Integer classId) { + this.classId = classId; + } + + public String getProfessionalName() { + return professionalName; + } + + public void setProfessionalName(String professionalName) { + this.professionalName = professionalName; + } + + public String getGradeName() { + return gradeName; + } + + public void setGradeName(String gradeName) { + this.gradeName = gradeName; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } +} diff --git a/src/main/java/com/yipin/liuwanr/entity/Student.java b/src/main/java/com/yipin/liuwanr/entity/Student.java index 849fa02..237b72b 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 { + //账号 + private String account; //学生主键ID private Integer studentId; //学生名称 @@ -57,6 +59,14 @@ public class Student { //学生专业组织架构名称 private String stuProfessionalArchitectureName; + public String getAccount() { + return account; + } + + public void setAccount(String account) { + this.account = account; + } + public String getStuProfessionalArchitectureName() { return stuProfessionalArchitectureName; } diff --git a/src/main/java/com/yipin/liuwanr/entity/UserProfiles.java b/src/main/java/com/yipin/liuwanr/entity/UserProfiles.java new file mode 100644 index 0000000..ee10a6d --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/UserProfiles.java @@ -0,0 +1,138 @@ +package com.yipin.liuwanr.entity; + +import java.util.List; + +/** + * 用户档案实体 + * + * @author Ning + */ +public class UserProfiles { + //个人档案id + private Integer personalFileId; + //个人职业id + private Integer personalCareerId; + //绑定学校id + private Integer schoolId; + //学校名称 + private String schoolName; + //绑定学科id + private Integer disciplineId; + //学科名称 + private String disciplineName; + //绑定专业类id + private Integer professionalClassId; + //专业类名称 + private String professionalClassName; + //绑定专业id + private Integer professionalId; + //专业名称 + private String professionalName; + //绑定用户id + private Integer userId; + + public String getSchoolName() { + return schoolName; + } + + public void setSchoolName(String schoolName) { + this.schoolName = schoolName; + } + + public String getDisciplineName() { + return disciplineName; + } + + public void setDisciplineName(String disciplineName) { + this.disciplineName = disciplineName; + } + + public String getProfessionalClassName() { + return professionalClassName; + } + + public void setProfessionalClassName(String professionalClassName) { + this.professionalClassName = professionalClassName; + } + + public String getProfessionalName() { + return professionalName; + } + + public void setProfessionalName(String professionalName) { + this.professionalName = professionalName; + } + + public Integer getPersonalFileId() { + return personalFileId; + } + + public void setPersonalFileId(Integer personalFileId) { + this.personalFileId = personalFileId; + } + + public Integer getPersonalCareerId() { + return personalCareerId; + } + + public void setPersonalCareerId(Integer personalCareerId) { + this.personalCareerId = personalCareerId; + } + + public Integer getSchoolId() { + return schoolId; + } + + public void setSchoolId(Integer schoolId) { + this.schoolId = schoolId; + } + + public Integer getDisciplineId() { + return disciplineId; + } + + public void setDisciplineId(Integer disciplineId) { + this.disciplineId = disciplineId; + } + + public Integer getProfessionalClassId() { + return professionalClassId; + } + + public void setProfessionalClassId(Integer professionalClassId) { + this.professionalClassId = professionalClassId; + } + + public Integer getProfessionalId() { + return professionalId; + } + + public void setProfessionalId(Integer professionalId) { + this.professionalId = professionalId; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + @Override + public String toString() { + return "UserProfiles{" + + "personalFileId=" + personalFileId + + ", personalCareerId=" + personalCareerId + + ", schoolId=" + schoolId + + ", schoolName='" + schoolName + '\'' + + ", disciplineId=" + disciplineId + + ", disciplineName='" + disciplineName + '\'' + + ", professionalClassId=" + professionalClassId + + ", professionalClassName='" + professionalClassName + '\'' + + ", professionalId=" + professionalId + + ", professionalName='" + professionalName + '\'' + + ", userId=" + userId + + '}'; + } +} diff --git a/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java b/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java index 2762d03..69ecd94 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/ExperimentalClassMapper.java @@ -16,10 +16,12 @@ import com.yipin.liuwanr.entity.Student; public interface ExperimentalClassMapper { + //实验班级添加学生 @Insert("INSERT INTO experimental_class_student(studentId,experimentalClassId)" + "VALUES(#{studentId},#{experimentalClassId})") void experimentClassAddStudent(Student student); - + + //实验班级删除学生 @Delete("DELETE from experimental_class_student where studentId = #{studentId} and experimentalClassId = #{experimentalClassId}") void experimentClassDeleteStudent(Student student); @@ -29,11 +31,12 @@ public interface ExperimentalClassMapper { @Options(useGeneratedKeys=true, keyProperty="experimentalClassId", keyColumn="experimentalClassId") void addExperimentalClass(ExperimentalClass experimentalClass); + //查询实验班级 @Select({" "}) - List queryExperimentalClass(Integer schoolId,Integer courseId); + List queryExperimentalClass(Integer schoolId,Integer courseId,Integer userId); //查询实验班级学生专业 @Select({" "}) List queryStudentClass(Integer experimentalClassId); - + + //查询实验班级详情 @Select({" "}) List queryExperimentalClassDetails(Student student); - + + //查询实验班级详情1 @Select({" "}) List queryExperimentalClassDetails1(Integer experimentalClassId); - + + //删除实验班级 @Update("UPDATE experimental_class_ning SET isdel = 1 where experimentalClassId = #{experimentalClassId}") void deleteExperimentalClass(Integer experimentalClassId); + //删除实验班级学生 @Delete("Delete from experimental_class_student where experimentalClassId = #{experimentalClassId}") void deleteExperimentalClassStu(Integer experimentalClassId); + //修改实验班级 @Update("UPDATE experimental_class_ning SET experimentalClassName = #{experimentalClassName},classSize = #{classSize},practiceNumber = #{practiceNumber},inspectionNumber = #{inspectionNumber},courseSchedule = #{courseSchedule},founder = #{founder},courseId = #{courseId} where experimentalClassId = #{experimentalClassId}") void updateExperimentalClass(ExperimentalClass experimentalClass); @@ -99,7 +107,7 @@ public interface ExperimentalClassMapper { @Select("select s.studentId,studentName from student s left join experimental_class_student exs on s.studentId=exs.studentId " + " where exs.experimentalClassId=#{experimentalClassId} GROUP BY s.studentId") - List querystudent(Integer experimentalClassId); + List queryStudent(Integer experimentalClassId); /** diff --git a/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java index ece79a1..bf87f38 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java @@ -2,6 +2,7 @@ package com.yipin.liuwanr.mapper; import java.util.List; +import com.yipin.liuwanr.entity.UserInfo; import com.yipin.liuwanr.entity.UserM; import com.yipin.liuwanr.vo.UserVO; import org.apache.ibatis.annotations.*; @@ -109,7 +110,7 @@ public interface StaffMapper { "and staffWorkNumber=#{workNumber} ", "and uniqueIdentificationAccount=#{uniqueIdentificationAccount} ", ""}) - Staff queryStaffQ(UserM user); + Staff queryStaffQ(UserInfo user); @Update("update staff set lastTimeOfLanding=#{lastTime},logNumber=#{logNumber} where staffId=#{staffId}") diff --git a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java index c2ecad6..d438b7b 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java @@ -2,6 +2,7 @@ package com.yipin.liuwanr.mapper; import java.util.List; +import com.yipin.liuwanr.entity.UserInfo; import com.yipin.liuwanr.entity.UserM; import com.yipin.liuwanr.vo.UserVO; import org.apache.ibatis.annotations.*; @@ -112,7 +113,7 @@ public interface StudentMapper { "and studentNumber=#{workNumber} ", "and uniqueIdentificationAccount=#{uniqueIdentificationAccount} ", ""}) - Student queryStudentQ(UserM user); + Student queryStudentQ(UserInfo user); @Update("update student set lastLoginTime=#{lastTime},loginNumber=#{loginNumber} where studentId=#{studentId}") diff --git a/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java new file mode 100644 index 0000000..962a189 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java @@ -0,0 +1,181 @@ +package com.yipin.liuwanr.mapper; + +import com.yipin.liuwanr.entity.*; +import com.yipin.liuwanr.vo.UserInfoVO; +import com.yipin.liuwanr.vo.UserVO; +import org.apache.ibatis.annotations.*; +import org.apache.ibatis.mapping.FetchType; + +import java.util.List; + +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(),#{logInNumber},#{sex},#{userAvatars},0)") + @Options(useGeneratedKeys=true, keyProperty="userId", keyColumn="userId") + void addUser(UserInfo user); + + @Select({" "}) + List queryUserInfo(UserInfo userInfo); + + @Update("UPDATE hr_user_info SET isdel = 1 where userId = #{userId}") + void deleteUser(Integer userId); + + //批量删除员工 + @Update({ "" }) + void deleteStaff(UserInfo user); + + //批量删除学生 + @Update({ "" }) + void deleteStudent(UserInfo user); + + //修改用户 + @Update("UPDATE user SET name = #{name},sex = #{sex},documentType = #{documentType},countries = #{countries},educationDegree = #{educationDegree}," + + "IDNumber = #{IDNumber},accountRole = #{accountRole},provinceId = #{provinceId},subjectsTaught = #{subjectsTaught},cityId = #{cityId}," + + "phone = #{phone},teachingProfessional = #{teachingProfessional},WeChatID = #{WeChatID},dateBirth = #{dateBirth},email = #{email},schoolId = #{schoolId},disciplineId = #{disciplineId},professionalId = #{professionalId},professionalClassId = #{professionalClassId} where userId = #{userId}") + void updateUser(UserInfo user); + + //修改员工 + @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 * from hr_user_info where isdel=0 and account = #{account} and password = #{password}") + UserInfo logins(UserInfo userInfo); + + //查询用户roleId + @Select("SELECT schoolId,roleId from hr_organization_relationship where userId = #{userId}") + OrganizationRelationship queryOrganizationRelationship(Integer userId); + + //查询用户手机 + @Select("SELECT u.* from user u where isdel=0 and phone = #{phone}") + List queryPhone(String phone); + + //查询用户详情 + @Select({" "}) + List queryUserInfoDetails(Integer userId); + + //查询用户详情 + @Select({" "}) + List queryUserProfiles(Integer userId); + + @Select({" "}) + List queryCustomer(Integer cityId, Integer provinceId); + + /** + * 批量插入用户 + * @param user + */ + @Insert({ + "" + }) + void addUserM(@Param("users") List users); + + //修改用户头像 + @Update("update user 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 userId,account from user where isdel = 0 and account = #{account}") + List queryAccountIsExist(String account); + + //查询学号、工号是否存在 + @Select("SELECT userId,workNumber from user where isdel = 0 and workNumber = #{workNumber}") + List queryWorkNumberIsExist(String workNumber); + + //========全承珠 + @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(List list); + + //添加学生 + @Insert("INSERT INTO student(account,userId,studentName,roleId,studentNumber,phone,email,professionalId,gradeId,classId,professionalName,gradeName,className,uniqueIdentificationAccount,schoolId,isdel)" + + " VALUES(#{account},#{userId},#{name},#{roleId},#{workNumber},#{phone},#{email},#{professionalId},#{gradeId},#{classId},#{professionalName},#{gradeName},#{className},#{uniqueIdentificationAccount},#{schoolId},0)") + void addStudent(StuStaff stuStaff); + + //添加员工 + @Insert("INSERT INTO staff(account,userId,staffName,roleId,staffWorkNumber,phone,email,staffGradeId,staffProfessionalArchitectureId,staffProfessionalArchitectureName,staffGradeName,uniqueIdentificationAccount,schoolId,isdel)" + + " VALUES(#{account},#{userId},#{name},#{roleId},#{workNumber},#{phone},#{email},#{staffGradeId},#{staffProfessionalArchitectureId},#{staffProfessionalArchitectureName},#{staffGradeName},#{uniqueIdentificationAccount},#{schoolId},0)") + void addStaff(StuStaff stuStaff); + +} \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java b/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java index ce3f75d..89e1d3d 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java @@ -147,7 +147,7 @@ public interface UserMapper { " "}) List queryUserInfo(UserInfo userInfo); - @Update("UPDATE user SET isdel = 1 where userId = #{userId}") + @Update("UPDATE hr_userInfo SET isdel = 1 where userId = #{userId}") void deleteUser(Integer userId); //批量删除员工 diff --git a/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java b/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java index 69dc22f..55981e6 100644 --- a/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java +++ b/src/main/java/com/yipin/liuwanr/service/ExperimentalClassService.java @@ -98,11 +98,11 @@ public class ExperimentalClassService { return resp; } - public HashMap queryExperimentalClass(Integer schoolId,Integer courseId) { + public HashMap queryExperimentalClass(Integer schoolId,Integer courseId,Integer userId) { HashMap resp = new HashMap(); try { if(!StringUtils.isEmpty(courseId)){ - resp.put("retvalue", experimentalClassMapper.queryExperimentalClass(schoolId,courseId)); + resp.put("retvalue", experimentalClassMapper.queryExperimentalClass(schoolId,courseId,userId)); resp.put("retcode", 200); } } catch (RuntimeException e) { @@ -179,12 +179,12 @@ public class ExperimentalClassService { //新增学生显示数据 - public HashMap queryexperimentalClass(Integer experimentalClassId) { + public HashMap queryExperimentalClass(Integer experimentalClassId) { HashMap resp = new HashMap(); HashMap obj = new HashMap(); try { List classes = experimentalClassMapper.queryExperimentalClassDetails1(experimentalClassId); - List students = experimentalClassMapper.querystudent(experimentalClassId); + List students = experimentalClassMapper.queryStudent(experimentalClassId); obj.put("experimentalClass", classes); obj.put("students", students); diff --git a/src/main/java/com/yipin/liuwanr/service/StudentService.java b/src/main/java/com/yipin/liuwanr/service/StudentService.java index 62458ce..d3d4751 100644 --- a/src/main/java/com/yipin/liuwanr/service/StudentService.java +++ b/src/main/java/com/yipin/liuwanr/service/StudentService.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import com.yipin.liuwanr.entity.PersonalFile; import com.yipin.liuwanr.vo.UserVO; import org.jboss.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -37,6 +38,7 @@ public class StudentService { @Autowired private UserMapper userMapper; + //添加学生 public HashMap addStudent(Student student) { HashMap resp = new HashMap(); try { diff --git a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java new file mode 100644 index 0000000..ba06e3b --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java @@ -0,0 +1,454 @@ +package com.yipin.liuwanr.service; + +import com.aliyun.oss.OSSClient; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.yipin.liuwanr.AliyunOssConfig; +import com.yipin.liuwanr.entity.*; +import com.yipin.liuwanr.helper.OssConfigUtil; +import com.yipin.liuwanr.helper.RandomUtil; +import com.yipin.liuwanr.mapper.StaffMapper; +import com.yipin.liuwanr.mapper.StudentMapper; +import com.yipin.liuwanr.mapper.UserInfoMapper; +import org.jboss.logging.Logger; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; +import redis.clients.jedis.JedisCluster; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.List; + + +@Service +public class UserInfoService { + + private static Logger logger = Logger.getLogger(UserInfoService.class); + + @Autowired + private StaffMapper staffMapper; + @Autowired + private StudentMapper studentMapper; + @Autowired + private UserInfoMapper userInfoMapper; + @Autowired + private JedisCluster jedis; + @Autowired + private AliyunOssConfig config; + @Autowired + private BeanFactory beanFactory; + + public HashMap login(String id, String password){ + HashMap resp = new HashMap(); + User user = null; + if(null == password || password.isEmpty()){ +// user = userInfoMapper.getSelfBy3rdId(id); + }else{ + String storedPassword = RandomUtil.parsePassword(password); +// user = userInfoMapper.getSelfByAccount(id); + if( null != user){ + logger.info(user.toString()); + logger.info(user.getPassword()); + logger.info(storedPassword); + if(0 == user.getPassword().compareToIgnoreCase(storedPassword)){ + user.setPassword(null); + resp.put("retcode", 200); + resp.put("retvalue", user); + } + else{ + resp.put("retcode",500); + resp.put("retvalue","User/Password Invalid"); + } + } + } + if(null == user){ + resp.put("retcode",400); + resp.put("retvalue","Account Invalid"); + } + return resp; + } + + //查询手机号 + public HashMapqueryPhone(String phone) { + HashMap resp = new HashMap(); + try { + resp.put("retvalue", userInfoMapper.queryPhone(phone)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询手机号失败!"); + return resp; + } + return resp; + } + + //添加用户 + public HashMap addUser(UserInfo user){ + HashMap resp = new HashMap(); + try { + user.setPassword("huoran123");//设置默认密码 + userInfoMapper.addUser(user); + Integer userId = user.getUserId(); + resp.put("userId",userId); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "添加用户失败!"); + return resp; + } + return resp; + } + + //查询用户信息 + public HashMap queryUserInfo(UserInfo userInfo,Integer pageNo,Integer pageSize){ + HashMap resp = new HashMap(); + try { + if(pageNo!=null&&pageSize!=null) { + PageHelper.startPage(pageNo, pageSize); + List list = userInfoMapper.queryUserInfo(userInfo); + 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.queryUserInfo(userInfo); + 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 deleteUserInfo(Integer userId){ + HashMap resp = new HashMap(); + try { + userInfoMapper.deleteUser(userId); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "删除用户失败"); + return resp; + } + return resp; + } + + //批量删除员工 + public HashMap deleteStaff(UserInfo user){ + HashMap resp = new HashMap(); + try { + userInfoMapper.deleteStaff(user); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "删除员工失败"); + return resp; + } + return resp; + } + + //批量删除学生 + public HashMap deleteStudent(UserInfo user){ + HashMap resp = new HashMap(); + try { + userInfoMapper.deleteStudent(user); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "删除学生失败"); + return resp; + } + return resp; + } + + //更新用户 + @Transactional + public HashMap updateUser(UserInfo user){ + HashMap resp = new HashMap(); + try { + userInfoMapper.updateUser(user); + 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 updateStudent(Student student){ + HashMap resp = new HashMap(); + try { + userInfoMapper.updateStudent(student); + 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 updateStaff(Staff staff){ + HashMap resp = new HashMap(); + try { + userInfoMapper.updateStaff(staff); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "更新员工失败!"); + throw new RuntimeException(); + } + return resp; + } + + //登陆 + public HashMap logins(UserInfo userInfo){ + HashMap resp = new HashMap(); + HashMap obj = new HashMap(); + Student student; + Staff staff; + try { + UserInfo user=userInfoMapper.logins(userInfo); + if(user!=null) { + Integer userId = user.getUserId(); + OrganizationRelationship organizationRelationship = userInfoMapper.queryOrganizationRelationship(userId); +// user.setRoleId(roleId); +// int loginNumber=user.getLogInNumber()+1; +// long time=System.currentTimeMillis(); +// Date date = new Date(time); +// SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); +// String lastTime=sd.format(date); +// if(roleId.equals(4)) { +// student=studentMapper.queryStudentQ(user); +// if(student!=null) { +// Integer studentId=student.getStudentId(); +// studentMapper.updateStudentQ(lastTime,loginNumber, studentId); +// obj.put("student",student); +// } +// }else if(roleId.equals(3)) { +// staff =staffMapper.queryStaffQ(user); +// if(staff!=null) { +// Integer staffId=staff.getStaffId(); +// staffMapper.updateStaffQ(lastTime,loginNumber, staffId); +// obj.put("staff",staff); +// } +// } +// user.setPassword(null); +// obj.put("user",user); +// userInfoMapper.updateUserQ(lastTime,loginNumber, userId); + resp.put("retcode", 200); + resp.put("retvalue", obj); + }else { + resp.put("retcode", 300); + resp.put("retvalue", "登录失败,账号密码有误或不存在!"); + } + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "登录异常,请稍后再试!"); + return resp; + } + return resp; + } + + //查询用户详情 + public HashMap queryUserInfoDetails(Integer userId){ + HashMap resp = new HashMap(); + try { + resp.put("retvalue", userInfoMapper.queryUserInfoDetails(userId)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询用户详情失败!"); + return resp; + } + return resp; + } + + //查询用户详情 + public HashMap queryUserProfiles(Integer userId){ + HashMap resp = new HashMap(); + try { + resp.put("retvalue", userInfoMapper.queryUserProfiles(userId)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询用户详情失败!"); + return resp; + } + return resp; + } + + //查询客户 + public HashMap queryCustomer(Integer cityId,Integer provinceId){ + HashMap resp = new HashMap(); + try { + resp.put("retvalue", userInfoMapper.queryCustomer(cityId,provinceId)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "查询客户失败!"); + return resp; + } + return resp; + } + + //修改用户头像 + public HashMap uploadUserAvatars(MultipartFile file,Integer userId){ + HashMap resp = new HashMap(); + try { + OSSClient client=beanFactory.getBean(OSSClient.class); + FilesResult result=OssConfigUtil.uploadUserAvatars(file, client, config); + + //用户图片路径 + String userAvatars=result.getFileUrl(); + userInfoMapper.updateUserAvatars(userAvatars,userId); + resp.put("retcode", 200); + resp.put("retvalue", userAvatars); + } catch (Exception e) { + logger.info(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "修改头像失败!"); + return resp; + } + return resp; + } + + //更新登录次数和时间 + public HashMap updateLogInNumber(UserM user){ + HashMap resp = new HashMap(); + try { + Integer accountRole = user.getAccountRole(); + userInfoMapper.updateLogInNumber(user); + if (accountRole==3){ + //更新员工登录次数和时间 + userInfoMapper.updateStaffLogInNumber(user); + } + if (accountRole==4){ + //更新学生登录次数和时间 + userInfoMapper.updateStudentLogInNumber(user); + } + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "更新登录次数失败!"); + return resp; + } + return resp; + } + + //查询账号是否存在 + public HashMap queryAccountIsExist(String account){ + HashMap resp = new HashMap(); + try { + resp.put("retvalue", userInfoMapper.queryAccountIsExist(account)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + //查询学号、工号是否存在 + public HashMap queryWorkNumberIsExist(String workNumber){ + HashMap resp = new HashMap(); + try { + resp.put("retvalue", userInfoMapper.queryWorkNumberIsExist(workNumber)); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + //添加个人档案 + public HashMap addPersonalFile(List userProfilesList,Integer userId) { + HashMap resp = new HashMap(); + try { + Integer size = userProfilesList.size(); + for (int i = 0; i < size; i++){ + UserProfiles userProfiles = userProfilesList.get(i); + userProfiles.setUserId(userId); + } + userInfoMapper.addPersonalFile(userProfilesList); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "添加个人档案失败"); + return resp; + } + return resp; + } + + //添加学生和员工信息 + @Transactional + public HashMap addStuStaff(List stuStaffList,Integer userId) { + HashMap resp = new HashMap(); + try { + int size = stuStaffList.size(); + for (int i=0;i queryUserInfo(UserInfo userInfo,Integer pageNo,Integer pageSize){ - HashMap resp = new HashMap(); - try { - if(pageNo!=null&&pageSize!=null) { - PageHelper.startPage(pageNo, pageSize); - List list = userMapper.queryUserInfo(userInfo); - 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 = userMapper.queryUserInfo(userInfo); - 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 deleteUser(Integer userId){ HashMap resp = new HashMap(); @@ -309,21 +278,21 @@ public class UserService { Date date = new Date(time); SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String lastTime=sd.format(date); - if(user.getAccountRole().equals(4)) { - student=studentMapper.queryStudentQ(user); - if(student!=null) { - Integer studentId=student.getStudentId(); - studentMapper.updateStudentQ(lastTime,loginNumber, studentId); - obj.put("student",student); - } - }else if(user.getAccountRole().equals(3)) { - staff =staffMapper.queryStaffQ(user); - if(staff!=null) { - Integer staffId=staff.getStaffId(); - staffMapper.updateStaffQ(lastTime,loginNumber, staffId); - obj.put("staff",staff); - } - } +// if(user.getAccountRole().equals(4)) { +// student=studentMapper.queryStudentQ(user); +// if(student!=null) { +// Integer studentId=student.getStudentId(); +// studentMapper.updateStudentQ(lastTime,loginNumber, studentId); +// obj.put("student",student); +// } +// }else if(user.getAccountRole().equals(3)) { +// staff =staffMapper.queryStaffQ(user); +// if(staff!=null) { +// Integer staffId=staff.getStaffId(); +// staffMapper.updateStaffQ(lastTime,loginNumber, staffId); +// obj.put("staff",staff); +// } +// } user.setPassword(null); obj.put("user",user); userMapper.updateUserQ(lastTime,loginNumber, userId); diff --git a/src/main/java/com/yipin/liuwanr/vo/StuStaffVO.java b/src/main/java/com/yipin/liuwanr/vo/StuStaffVO.java new file mode 100644 index 0000000..0a48313 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/vo/StuStaffVO.java @@ -0,0 +1,46 @@ +package com.yipin.liuwanr.vo; + +import com.yipin.liuwanr.entity.Staff; +import com.yipin.liuwanr.entity.Student; +import com.yipin.liuwanr.entity.UserM; + +import java.util.List; + +/** + * 用户信息实体 + * @author Ning + * + */ +public class StuStaffVO { + //学生 + private Student student; + //员工 + private Staff staff; + private List studentList; + private List staffList; + + public Student getStudent() { + return student; + } + public void setStudent(Student student) { + this.student = student; + } + public Staff getStaff() { + return staff; + } + public void setStaff(Staff staff) { + this.staff = staff; + } + public List getStudentList() { + return studentList; + } + public void setStudentList(List studentList) { + this.studentList = studentList; + } + public List getStaffList() { + return staffList; + } + public void setStaffList(List staffList) { + this.staffList = staffList; + } +} diff --git a/src/main/java/com/yipin/liuwanr/vo/UserInfoVO.java b/src/main/java/com/yipin/liuwanr/vo/UserInfoVO.java new file mode 100644 index 0000000..8a406c3 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/vo/UserInfoVO.java @@ -0,0 +1,118 @@ +package com.yipin.liuwanr.vo; + +import com.yipin.liuwanr.entity.*; + +import java.util.List; + +/** + * 用户信息实体 + * @author Ning + * + */ +public class UserInfoVO { + //用户 + private UserInfo userInfo; + //学生 + private Student student; + //员工 + private Staff staff; + //个人档案 + private UserProfiles userProfiles; + //组织架构关系 + private OrganizationRelationship organizationRelationship; + + private List organizationRelationshipList; + private List userInfoList; + private List studentList; + private List staffList; + private List userProfilesList; + private List stuStaffList; + + public OrganizationRelationship getOrganizationRelationship() { + return organizationRelationship; + } + + public void setOrganizationRelationship(OrganizationRelationship organizationRelationship) { + this.organizationRelationship = organizationRelationship; + } + + public List getOrganizationRelationshipList() { + return organizationRelationshipList; + } + + public void setOrganizationRelationshipList(List organizationRelationshipList) { + this.organizationRelationshipList = organizationRelationshipList; + } + + public List getStuStaffList() { + return stuStaffList; + } + + public void setStuStaffList(List stuStaffList) { + this.stuStaffList = stuStaffList; + } + + public UserProfiles getUserProfiles() { + return userProfiles; + } + + public void setUserProfiles(UserProfiles userProfiles) { + this.userProfiles = userProfiles; + } + + public List getUserProfilesList() { + return userProfilesList; + } + + public void setUserProfilesList(List userProfilesList) { + this.userProfilesList = userProfilesList; + } + + public UserInfo getUserInfo() { + return userInfo; + } + + public void setUserInfo(UserInfo userInfo) { + this.userInfo = userInfo; + } + + public Student getStudent() { + return student; + } + + public void setStudent(Student student) { + this.student = student; + } + + public Staff getStaff() { + return staff; + } + + public void setStaff(Staff staff) { + this.staff = staff; + } + + public List getUserInfoList() { + return userInfoList; + } + + public void setUserInfoList(List userInfoList) { + this.userInfoList = userInfoList; + } + + public List getStudentList() { + return studentList; + } + + public void setStudentList(List studentList) { + this.studentList = studentList; + } + + public List getStaffList() { + return staffList; + } + + public void setStaffList(List staffList) { + this.staffList = staffList; + } +} diff --git a/src/test/java/com/yipin/liuwanr/ExperimentalClassServiceTest.java b/src/test/java/com/yipin/liuwanr/ExperimentalClassServiceTest.java index d24ba9f..3e32a7c 100644 --- a/src/test/java/com/yipin/liuwanr/ExperimentalClassServiceTest.java +++ b/src/test/java/com/yipin/liuwanr/ExperimentalClassServiceTest.java @@ -65,7 +65,8 @@ public class ExperimentalClassServiceTest { public void queryExperimentalClass() { Integer schoolId = 1; Integer courseId = 2; - HashMap map = experimentalClassService.queryExperimentalClass(schoolId, courseId); + Integer userId = 1; + HashMap map = experimentalClassService.queryExperimentalClass(schoolId, courseId,userId); map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); }