上传代码

master
zhiyong.ning 4 years ago
parent f22e354b0c
commit 431ae0e4f0
  1. 15
      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. 96
      src/main/java/com/yipin/liuwanr/service/UserInfoService.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<String, Object> ret = userInfoService.loginRole(OR);
// staff.setUserId(userId);
// staff.setSchoolId(schoolId);
// staff.setUserId(userId);
// staff.setSchoolId(schoolId);
HashMap<String, Object> 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());
}

@ -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>"})
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<OrganizationRelationship> loginRole(Integer userId, Integer schoolId);
@Select("SELECT userId,roleId from staff where userId = #{userId} and schoolId = #{schoolId}")
List<Staff> loginStaffRole(Integer userId, Integer schoolId);
//查询用户组织关系
@Select("SELECT schoolId,schoolName,userId from hr_organization_relationship where userId = #{userId} GROUP BY schoolId")
List<OrganizationRelationship> queryOrganizationRelationship(Integer userId);
//查询用户角色
@Select("SELECT userId,roleId from student where userId = #{userId} and schoolId = #{schoolId}")
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}")
List<OrganizationRelationship> 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<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")
// 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}")
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}")
List<OrganizationRelationship> 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<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})")

@ -99,33 +99,47 @@ public class UserInfoService {
@Transactional
public HashMap<String, Object> addUser(UserInfo user,Student student,List<Staff> staffList,List<UserProfiles> userProfilesList){
HashMap<String, Object> resp = new HashMap<String, Object>();
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<size; i++){
UserProfiles userProfiles = userProfilesList.get(i);
userProfiles.setUserId(userId);
userInfoMapper.addPersonalFile(userProfiles);
}
int staffListSize = staffList.size();
for (int i = 0;i<staffListSize;i++){
Staff staff = staffList.get(i);
staff.setUserId(userId);
userInfoMapper.userAddStaff(staff);
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");//设置默认密码
userInfoMapper.addUser(user);
Integer userId = user.getUserId();
if (studentWorkNumber!=null){
student.setUserId(userId);
userInfoMapper.userAddStudent(student);
}
int size = userProfilesList.size();
if (size<=0){
for (int i = 0;i<size; i++){
UserProfiles userProfiles = userProfilesList.get(i);
userProfiles.setUserId(userId);
userInfoMapper.addPersonalFile(userProfiles);
}
}
int staffListSize = staffList.size();
for (int i = 0;i<staffListSize;i++){
Staff staff = staffList.get(i);
staff.setUserId(userId);
userInfoMapper.userAddStaff(staff);
}
resp.put("retcode", 200);
}
resp.put("retcode", 200);
} catch (RuntimeException e) {
} catch (RuntimeException e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "添加用户失败!");
throw new RuntimeException();
}
return resp;
}
return resp;
}
//查询用户信息
public HashMap<String, Object> 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> organizationRelationship = userInfoMapper.queryOrganizationRelationship(userId);
obj.put("organizationRelationship",organizationRelationship);
List<UserInfo> staffList = userInfoMapper.loginGetStaffSchool(userId);
obj.put("staffList",staffList);
List<UserInfo> 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> organizationRelationship = userInfoMapper.queryOrganizationRelationshipAll(userId,roleId,schoolId);
obj.put("organizationRelationship",organizationRelationship);
List<Staff> staffList = userInfoMapper.queryStaffAll(userId,roleId,schoolId);
obj.put("staffList",staffList);
List<Student> 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<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> obj = new HashMap<String, Object>();
try {
if(OR!=null) {
Integer userId = OR.getUserId();
Integer schoolId = OR.getSchoolId();
List<OrganizationRelationship> 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<Staff> staffList = userInfoMapper.loginStaffRole(userId,schoolId);
obj.put("staffList",staffList);
List<Student> 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<String, Object> queryWorkNumberIsExist(String workNumber,Integer roleId,Integer schoolId){
HashMap<String, Object> resp = new HashMap<String, Object>();
HashMap<String, Object> obj = new HashMap<String, Object>();
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);
} catch (RuntimeException e) {
logger.error(e.getMessage());

Loading…
Cancel
Save