上传代码

master
zhiyong.ning 4 years ago
parent f22e354b0c
commit 431ae0e4f0
  1. 11
      src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
  2. 172
      src/main/java/com/yipin/liuwanr/entity/ExperimentalTeaching.java
  3. 41
      src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
  4. 52
      src/main/java/com/yipin/liuwanr/service/UserInfoService.java

@ -340,7 +340,8 @@ public class UserInfoController {
@GetMapping("/loginRole") @GetMapping("/loginRole")
Response loginRole(@RequestParam("userId") Integer userId, @RequestParam("schoolId") Integer schoolId, HttpServletRequest req, HttpServletResponse res) { Response loginRole(@RequestParam("userId") Integer userId, @RequestParam("schoolId") Integer schoolId, HttpServletRequest req, HttpServletResponse res) {
Response resp = new Response(); Response resp = new Response();
OrganizationRelationship OR = new OrganizationRelationship(); Staff staff = new Staff();
Student student = new Student();
if (userId == null) { if (userId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id为空,登录失败!"); resp.setErrmessage("用户id为空,登录失败!");
@ -348,9 +349,11 @@ public class UserInfoController {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("角色id为空,登录失败!"); resp.setErrmessage("角色id为空,登录失败!");
}else{ }else{
OR.setUserId(userId); // staff.setUserId(userId);
OR.setSchoolId(schoolId); // staff.setSchoolId(schoolId);
HashMap<String, Object> ret = userInfoService.loginRole(OR); // staff.setUserId(userId);
// staff.setSchoolId(schoolId);
HashMap<String, Object> ret = userInfoService.loginRole(userId,schoolId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
resp.setStatus(status); resp.setStatus(status);

@ -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 +
'}';
}
}

@ -26,8 +26,8 @@ public interface UserInfoMapper {
"</script>"}) "</script>"})
void update(User user); 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)" @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)") + " 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") @Options(useGeneratedKeys = true, keyProperty = "userId", keyColumn = "userId")
void addUser(UserInfo user); void addUser(UserInfo user);
@ -132,17 +132,28 @@ public interface UserInfoMapper {
UserInfo loginsAP(UserInfo userInfo); UserInfo loginsAP(UserInfo userInfo);
//查询用户角色 //查询用户角色
@Select("SELECT userId,roleId from hr_organization_relationship where userId = #{userId} and schoolId = #{schoolId}") @Select("SELECT userId,roleId from staff where userId = #{userId} and schoolId = #{schoolId}")
List<OrganizationRelationship> loginRole(Integer userId, Integer schoolId); List<Staff> loginStaffRole(Integer userId, Integer schoolId);
//查询用户组织关系 //查询用户角色
@Select("SELECT schoolId,schoolName,userId from hr_organization_relationship where userId = #{userId} GROUP BY schoolId") @Select("SELECT userId,roleId from student where userId = #{userId} and schoolId = #{schoolId}")
List<OrganizationRelationship> queryOrganizationRelationship(Integer userId); List<Student> 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<UserInfo> loginGetStaffSchool(Integer userId);
//查询用户组织关系 //登陆查询学校
@Select("SELECT * from hr_organization_relationship where userId = #{userId} and roleId = #{roleId} and schoolId = #{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<OrganizationRelationship> queryOrganizationRelationshipAll(Integer userId, String roleId, Integer schoolId); List<UserInfo> loginGetStudentSchool(Integer userId);
//查询用户员工组织关系
@Select("SELECT * from staff where userId = #{userId} and roleId = #{roleId} and schoolId = #{schoolId}")
List<Staff> queryStaffAll(Integer userId, String roleId, Integer schoolId);
//查询用户学生组织关系
@Select("SELECT * from student where userId = #{userId} and roleId = #{roleId} and schoolId = #{schoolId}")
List<Student> 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") // @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<Platform> queryUserPlatform(Integer userId); // List<Platform> 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}") @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<OrganizationRelationship> queryAccountIsExistOR(String account, Integer schoolId); List<OrganizationRelationship> queryAccountIsExistOR(String account, Integer schoolId);
//查询学号、工号是否存在 //查询员工学号、工号是否存在
@Select("SELECT userId,workNumber,schoolId,roleId from hr_organization_relationship where workNumber = #{workNumber} and roleId = #{roleId} and schoolId = #{schoolId}") @Select("SELECT userId,workNumber,schoolId,roleId from staff where workNumber = #{workNumber} and roleId = #{roleId} and schoolId = #{schoolId}")
List<OrganizationRelationship> queryWorkNumberIsExist(String workNumber, Integer roleId, Integer schoolId); List<Staff> 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<Student> queryStudentWorkNumberIsExist(String workNumber, Integer roleId, Integer schoolId);
//查询平台 //查询平台
@Select("SELECT platformId,platformName,domainName,createTime from hr_platform where FIND_IN_SET (platformId,#{platformId})") @Select("SELECT platformId,platformName,domainName,createTime from hr_platform where FIND_IN_SET (platformId,#{platformId})")

@ -99,18 +99,31 @@ public class UserInfoService {
@Transactional @Transactional
public HashMap<String, Object> addUser(UserInfo user,Student student,List<Staff> staffList,List<UserProfiles> userProfilesList){ public HashMap<String, Object> addUser(UserInfo user,Student student,List<Staff> staffList,List<UserProfiles> userProfilesList){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
int PLsize = userProfilesList.size();
String studentWorkNumber = student.getWorkNumber();
try { try {
if(user==null){
resp.put("retcode", 300);
resp.put("retvalue", "用户为空,添加用户失败!");
}else if(PLsize<=0){
resp.put("retcode", 300);
resp.put("retvalue", "用户组织架构为空,添加用户失败!");
}else {
user.setPassword("huoran123");//设置默认密码 user.setPassword("huoran123");//设置默认密码
userInfoMapper.addUser(user); userInfoMapper.addUser(user);
Integer userId = user.getUserId(); Integer userId = user.getUserId();
if (studentWorkNumber!=null){
student.setUserId(userId); student.setUserId(userId);
userInfoMapper.userAddStudent(student); userInfoMapper.userAddStudent(student);
}
int size = userProfilesList.size(); int size = userProfilesList.size();
if (size<=0){
for (int i = 0;i<size; i++){ for (int i = 0;i<size; i++){
UserProfiles userProfiles = userProfilesList.get(i); UserProfiles userProfiles = userProfilesList.get(i);
userProfiles.setUserId(userId); userProfiles.setUserId(userId);
userInfoMapper.addPersonalFile(userProfiles); userInfoMapper.addPersonalFile(userProfiles);
} }
}
int staffListSize = staffList.size(); int staffListSize = staffList.size();
for (int i = 0;i<staffListSize;i++){ for (int i = 0;i<staffListSize;i++){
Staff staff = staffList.get(i); Staff staff = staffList.get(i);
@ -118,6 +131,7 @@ public class UserInfoService {
userInfoMapper.userAddStaff(staff); userInfoMapper.userAddStaff(staff);
} }
resp.put("retcode", 200); resp.put("retcode", 200);
}
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
resp.put("retcode", 500); resp.put("retcode", 500);
@ -351,8 +365,10 @@ public class UserInfoService {
// obj.put("user",user); // obj.put("user",user);
if(user!=null) { if(user!=null) {
Integer userId = user.getUserId(); Integer userId = user.getUserId();
List<OrganizationRelationship> organizationRelationship = userInfoMapper.queryOrganizationRelationship(userId); List<UserInfo> staffList = userInfoMapper.loginGetStaffSchool(userId);
obj.put("organizationRelationship",organizationRelationship); obj.put("staffList",staffList);
List<UserInfo> studentList = userInfoMapper.loginGetStudentSchool(userId);
obj.put("studentList",studentList);
resp.put("retcode", 200); resp.put("retcode", 200);
resp.put("retvalue", obj); resp.put("retvalue", obj);
}else { }else {
@ -379,8 +395,10 @@ public class UserInfoService {
UserInfo user=userInfoMapper.logins(userInfo); UserInfo user=userInfoMapper.logins(userInfo);
obj.put("user",user); obj.put("user",user);
if(userId!=null) { if(userId!=null) {
List<OrganizationRelationship> organizationRelationship = userInfoMapper.queryOrganizationRelationshipAll(userId,roleId,schoolId); List<Staff> staffList = userInfoMapper.queryStaffAll(userId,roleId,schoolId);
obj.put("organizationRelationship",organizationRelationship); obj.put("staffList",staffList);
List<Student> studentList = userInfoMapper.queryStudentAll(userId,roleId,schoolId);
obj.put("studentList",studentList);
resp.put("retcode", 200); resp.put("retcode", 200);
resp.put("retvalue", obj); resp.put("retvalue", obj);
}else { }else {
@ -397,21 +415,16 @@ public class UserInfoService {
} }
//登陆获取角色 //登陆获取角色
public HashMap<String, Object> loginRole(OrganizationRelationship OR){ public HashMap<String, Object> loginRole(Integer userId,Integer schoolId){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
HashMap<String, Object> obj = new HashMap<String, Object>(); HashMap<String, Object> obj = new HashMap<String, Object>();
try { try {
if(OR!=null) { List<Staff> staffList = userInfoMapper.loginStaffRole(userId,schoolId);
Integer userId = OR.getUserId(); obj.put("staffList",staffList);
Integer schoolId = OR.getSchoolId(); List<Student> studentList = userInfoMapper.loginStudentRole(userId,schoolId);
List<OrganizationRelationship> organizationRelationship = userInfoMapper.loginRole(userId,schoolId); obj.put("studentList",studentList);
obj.put("organizationRelationship",organizationRelationship);
resp.put("retcode", 200); resp.put("retcode", 200);
resp.put("retvalue", obj); resp.put("retvalue", obj);
}else {
resp.put("retcode", 300);
resp.put("retvalue", "登录失败!");
}
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
resp.put("retcode", 500); resp.put("retcode", 500);
@ -585,8 +598,17 @@ public class UserInfoService {
//查询学号、工号是否存在 //查询学号、工号是否存在
public HashMap<String, Object> queryWorkNumberIsExist(String workNumber,Integer roleId,Integer schoolId){ public HashMap<String, Object> queryWorkNumberIsExist(String workNumber,Integer roleId,Integer schoolId){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
HashMap<String, Object> obj = new HashMap<String, Object>();
try { try {
resp.put("retvalue", userInfoMapper.queryWorkNumberIsExist(workNumber,roleId,schoolId)); List<Staff> staffList = userInfoMapper.queryStaffWorkNumberIsExist(workNumber,roleId,schoolId);
List<Student> 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); resp.put("retcode", 200);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());

Loading…
Cancel
Save