From 431ae0e4f03b9a84459527d8c16d34054842f802 Mon Sep 17 00:00:00 2001 From: "zhiyong.ning" <354350178@qq.com> Date: Tue, 22 Sep 2020 11:33:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserInfoController.java | 15 +- .../liuwanr/entity/ExperimentalTeaching.java | 172 ++++++++++++++++++ .../yipin/liuwanr/mapper/UserInfoMapper.java | 41 +++-- .../liuwanr/service/UserInfoService.java | 96 ++++++---- 4 files changed, 268 insertions(+), 56 deletions(-) create mode 100644 src/main/java/com/yipin/liuwanr/entity/ExperimentalTeaching.java diff --git a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java index 7c8dd0e..4fadf4a 100644 --- a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java +++ b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java @@ -340,7 +340,8 @@ public class UserInfoController { @GetMapping("/loginRole") Response loginRole(@RequestParam("userId") Integer userId, @RequestParam("schoolId") Integer schoolId, HttpServletRequest req, HttpServletResponse res) { Response resp = new Response(); - OrganizationRelationship OR = new OrganizationRelationship(); + Staff staff = new Staff(); + Student student = new Student(); if (userId == null) { resp.setStatus(300); resp.setErrmessage("用户id为空,登录失败!"); @@ -348,9 +349,11 @@ public class UserInfoController { resp.setStatus(300); resp.setErrmessage("角色id为空,登录失败!"); }else{ - OR.setUserId(userId); - OR.setSchoolId(schoolId); - HashMap ret = userInfoService.loginRole(OR); +// staff.setUserId(userId); +// staff.setSchoolId(schoolId); +// staff.setUserId(userId); +// staff.setSchoolId(schoolId); + HashMap ret = userInfoService.loginRole(userId,schoolId); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); @@ -561,7 +564,7 @@ public class UserInfoController { @GetMapping("/queryWorkNumberIsExist") Response queryWorkNumberIsExist(@RequestParam String workNumber,Integer roleId,Integer schoolId) { Response resp = new Response(); - if (workNumber==null) { + if (workNumber==null){ resp.setStatus(300); resp.setErrmessage("学号、工号为空!"); }else if (roleId==null){ @@ -599,7 +602,7 @@ public class UserInfoController { if (200 == status) { resp.setStatus(status); resp.setMessage(ret.get("retvalue")); - } else { + }else{ resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); } diff --git a/src/main/java/com/yipin/liuwanr/entity/ExperimentalTeaching.java b/src/main/java/com/yipin/liuwanr/entity/ExperimentalTeaching.java new file mode 100644 index 0000000..59243d1 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/ExperimentalTeaching.java @@ -0,0 +1,172 @@ +package com.yipin.liuwanr.entity; + +import java.util.List; + +/** + * 实验教学实体 + * + * @author Ning + */ +public class ExperimentalTeaching { + + //实验教学主键ID + private Integer id; + //实验班级名称 + private String experimentalClassName; + //实验名称 + private String experimentalName; + //绑定项目id + private Integer projectId; + //绑定项目名称 + private String projectName; + //实验人数 + private Integer experimentalNumber; + //实验时长 + private String experimentDuration; + //发布类型 + private Integer type; + //启动时间 + private String startTime; + //结束时间 + private String stopTime; + //状态 + private Integer status; + //邀请码 + private String invitationCode; + //是否启用邀请码 + private Integer isCode; + //绑定用户Id + private Integer userId; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getExperimentalClassName() { + return experimentalClassName; + } + + public void setExperimentalClassName(String experimentalClassName) { + this.experimentalClassName = experimentalClassName; + } + + public String getExperimentalName() { + return experimentalName; + } + + public void setExperimentalName(String experimentalName) { + this.experimentalName = experimentalName; + } + + public Integer getProjectId() { + return projectId; + } + + public void setProjectId(Integer projectId) { + this.projectId = projectId; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public Integer getExperimentalNumber() { + return experimentalNumber; + } + + public void setExperimentalNumber(Integer experimentalNumber) { + this.experimentalNumber = experimentalNumber; + } + + public String getExperimentDuration() { + return experimentDuration; + } + + public void setExperimentDuration(String experimentDuration) { + this.experimentDuration = experimentDuration; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getStartTime() { + return startTime; + } + + public void setStartTime(String startTime) { + this.startTime = startTime; + } + + public String getStopTime() { + return stopTime; + } + + public void setStopTime(String stopTime) { + this.stopTime = stopTime; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getInvitationCode() { + return invitationCode; + } + + public void setInvitationCode(String invitationCode) { + this.invitationCode = invitationCode; + } + + public Integer getIsCode() { + return isCode; + } + + public void setIsCode(Integer isCode) { + this.isCode = isCode; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + @Override + public String toString() { + return "ExperimentalTeaching{" + + "id=" + id + + ", experimentalClassName='" + experimentalClassName + '\'' + + ", experimentalName='" + experimentalName + '\'' + + ", projectId=" + projectId + + ", projectName='" + projectName + '\'' + + ", experimentalNumber=" + experimentalNumber + + ", experimentDuration='" + experimentDuration + '\'' + + ", type=" + type + + ", startTime='" + startTime + '\'' + + ", stopTime='" + stopTime + '\'' + + ", status=" + status + + ", invitationCode='" + invitationCode + '\'' + + ", isCode=" + isCode + + ", userId=" + userId + + '}'; + } +} diff --git a/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java index 209505d..d8f7479 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java @@ -26,8 +26,8 @@ public interface UserInfoMapper { ""}) void update(User user); - @Insert("INSERT INTO hr_user_info(userName,uniqueIdentificationAccount,documentType,IDNumber,provinceId,cityId,countries,dateBirth,educationDegree,schoolId,phone,weChatID,email,account,password,creationTime,logInNumber,sex,userAvatars,isdel)" - + " VALUES(#{userName},#{uniqueIdentificationAccount},#{documentType},#{IDNumber},#{provinceId},#{cityId},#{countries},#{dateBirth},#{educationDegree},#{schoolId},#{phone},#{weChatID},#{email},#{account},#{password},now(),0,#{sex},#{userAvatars},0)") + @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,roleId)" + + " VALUES(#{userName},#{uniqueIdentificationAccount},#{documentType},#{IDNumber},#{provinceId},#{cityId},#{countries},#{dateBirth},#{educationDegree},#{schoolId},#{phone},#{weChatID},#{email},#{account},#{password},now(),0,#{sex},#{userAvatars},0,#{roleId})") @Options(useGeneratedKeys = true, keyProperty = "userId", keyColumn = "userId") void addUser(UserInfo user); @@ -132,17 +132,28 @@ public interface UserInfoMapper { UserInfo loginsAP(UserInfo userInfo); //查询用户角色 - @Select("SELECT userId,roleId from hr_organization_relationship where userId = #{userId} and schoolId = #{schoolId}") - List loginRole(Integer userId, Integer schoolId); + @Select("SELECT userId,roleId from staff where userId = #{userId} and schoolId = #{schoolId}") + List loginStaffRole(Integer userId, Integer schoolId); - //查询用户组织关系 - @Select("SELECT schoolId,schoolName,userId from hr_organization_relationship where userId = #{userId} GROUP BY schoolId") - List queryOrganizationRelationship(Integer userId); + //查询用户角色 + @Select("SELECT userId,roleId from student where userId = #{userId} and schoolId = #{schoolId}") + List loginStudentRole(Integer userId, Integer schoolId); + + //登陆查询学校 + @Select("SELECT sta.schoolId,sch.schoolName,sta.userId from staff sta,school sch where sta.userId = #{userId} and sta.schoolId = sch.schoolId GROUP BY sta.schoolId") + List loginGetStaffSchool(Integer userId); - //查询用户组织关系 - @Select("SELECT * from hr_organization_relationship where userId = #{userId} and roleId = #{roleId} and schoolId = #{schoolId}") - List queryOrganizationRelationshipAll(Integer userId, String roleId, Integer schoolId); + //登陆查询学校 + @Select("SELECT stu.schoolId,sch.schoolName,stu.userId from student stu,school sch where stu.userId = #{userId} and stu.schoolId = sch.schoolId GROUP BY stu.schoolId") + List loginGetStudentSchool(Integer userId); + //查询用户员工组织关系 + @Select("SELECT * from staff where userId = #{userId} and roleId = #{roleId} and schoolId = #{schoolId}") + List queryStaffAll(Integer userId, String roleId, Integer schoolId); + + //查询用户学生组织关系 + @Select("SELECT * from student where userId = #{userId} and roleId = #{roleId} and schoolId = #{schoolId}") + List queryStudentAll(Integer userId, String roleId, Integer schoolId); // //查询用户绑定平台信息 // @Select("SELECT hp.* FROM hr_platform hp,hr_organization_relationship hor WHERE hor.platformId = hp.platformId and hor.userId = #{userId} and hor.isdel = 0 GROUP BY platformId") // List queryUserPlatform(Integer userId); @@ -257,9 +268,13 @@ public interface UserInfoMapper { @Select("SELECT hor.* from hr_organization_relationship hor,hr_user_info hui where hor.isdel = 0 and hui.account = #{account} and hor.userId = hui.userId and hor.schoolId = #{schoolId}") List queryAccountIsExistOR(String account, Integer schoolId); - //查询学号、工号是否存在 - @Select("SELECT userId,workNumber,schoolId,roleId from hr_organization_relationship where workNumber = #{workNumber} and roleId = #{roleId} and schoolId = #{schoolId}") - List queryWorkNumberIsExist(String workNumber, Integer roleId, Integer schoolId); + //查询员工学号、工号是否存在 + @Select("SELECT userId,workNumber,schoolId,roleId from staff where workNumber = #{workNumber} and roleId = #{roleId} and schoolId = #{schoolId}") + List queryStaffWorkNumberIsExist(String workNumber, Integer roleId, Integer schoolId); + + //查询学生学号、工号是否存在 + @Select("SELECT userId,workNumber,schoolId,roleId from student where workNumber = #{workNumber} and roleId = #{roleId} and schoolId = #{schoolId}") + List queryStudentWorkNumberIsExist(String workNumber, Integer roleId, Integer schoolId); //查询平台 @Select("SELECT platformId,platformName,domainName,createTime from hr_platform where FIND_IN_SET (platformId,#{platformId})") diff --git a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java index 3094a99..4181acc 100644 --- a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java +++ b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java @@ -99,33 +99,47 @@ public class UserInfoService { @Transactional public HashMap addUser(UserInfo user,Student student,List staffList,List userProfilesList){ HashMap resp = new HashMap(); + int PLsize = userProfilesList.size(); + String studentWorkNumber = student.getWorkNumber(); try { - user.setPassword("huoran123");//设置默认密码 - userInfoMapper.addUser(user); - Integer userId = user.getUserId(); - student.setUserId(userId); - userInfoMapper.userAddStudent(student); - int size = userProfilesList.size(); - for (int i = 0;i queryUserInfo(UserInfo userInfo,Integer pageNo,Integer pageSize){ @@ -351,8 +365,10 @@ public class UserInfoService { // obj.put("user",user); if(user!=null) { Integer userId = user.getUserId(); - List organizationRelationship = userInfoMapper.queryOrganizationRelationship(userId); - obj.put("organizationRelationship",organizationRelationship); + List staffList = userInfoMapper.loginGetStaffSchool(userId); + obj.put("staffList",staffList); + List studentList = userInfoMapper.loginGetStudentSchool(userId); + obj.put("studentList",studentList); resp.put("retcode", 200); resp.put("retvalue", obj); }else { @@ -379,8 +395,10 @@ public class UserInfoService { UserInfo user=userInfoMapper.logins(userInfo); obj.put("user",user); if(userId!=null) { - List organizationRelationship = userInfoMapper.queryOrganizationRelationshipAll(userId,roleId,schoolId); - obj.put("organizationRelationship",organizationRelationship); + List staffList = userInfoMapper.queryStaffAll(userId,roleId,schoolId); + obj.put("staffList",staffList); + List studentList = userInfoMapper.queryStudentAll(userId,roleId,schoolId); + obj.put("studentList",studentList); resp.put("retcode", 200); resp.put("retvalue", obj); }else { @@ -397,21 +415,16 @@ public class UserInfoService { } //登陆获取角色 - public HashMap loginRole(OrganizationRelationship OR){ + public HashMap loginRole(Integer userId,Integer schoolId){ HashMap resp = new HashMap(); HashMap obj = new HashMap(); try { - if(OR!=null) { - Integer userId = OR.getUserId(); - Integer schoolId = OR.getSchoolId(); - List organizationRelationship = userInfoMapper.loginRole(userId,schoolId); - obj.put("organizationRelationship",organizationRelationship); - resp.put("retcode", 200); - resp.put("retvalue", obj); - }else { - resp.put("retcode", 300); - resp.put("retvalue", "登录失败!"); - } + List staffList = userInfoMapper.loginStaffRole(userId,schoolId); + obj.put("staffList",staffList); + List studentList = userInfoMapper.loginStudentRole(userId,schoolId); + obj.put("studentList",studentList); + resp.put("retcode", 200); + resp.put("retvalue", obj); } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); @@ -585,8 +598,17 @@ public class UserInfoService { //查询学号、工号是否存在 public HashMap queryWorkNumberIsExist(String workNumber,Integer roleId,Integer schoolId){ HashMap resp = new HashMap(); + HashMap obj = new HashMap(); try { - resp.put("retvalue", userInfoMapper.queryWorkNumberIsExist(workNumber,roleId,schoolId)); + List staffList = userInfoMapper.queryStaffWorkNumberIsExist(workNumber,roleId,schoolId); + List studentList = userInfoMapper.queryStudentWorkNumberIsExist(workNumber,roleId,schoolId); + if (!staffList.isEmpty()){ + obj.put("staffList",staffList); + } + if (!studentList.isEmpty()){ + obj.put("studentList",studentList); + } + resp.put("retvalue",obj); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage());