学生添加、删除、查询

master
mzh820631607 4 years ago
parent d6d4ef9b92
commit 424cf6daa0
  1. 370
      src/main/java/com/yipin/liuwanr/controller/StudentController.java
  2. 229
      src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
  3. 85
      src/main/java/com/yipin/liuwanr/entity/StudentInfo.java
  4. 4
      src/main/java/com/yipin/liuwanr/mapper/OrganizationRelationshipMapper.java
  5. 37
      src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
  6. 26
      src/main/java/com/yipin/liuwanr/service/UserInfoService.java
  7. 23
      src/test/java/com/yipin/liuwanr/service/StudentServiceTest.java

@ -1,14 +1,13 @@
package com.yipin.liuwanr.controller;
import com.yipin.liuwanr.entity.Response;
import com.yipin.liuwanr.entity.Student;
import com.yipin.liuwanr.entity.UserM;
import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.helper.QueryStudentUtils;
import com.yipin.liuwanr.helper.RedisHelper;
import com.yipin.liuwanr.service.StudentService;
import com.yipin.liuwanr.service.UserInfoService;
import com.yipin.liuwanr.service.UserService;
import com.yipin.liuwanr.vo.UserInfoVO;
import com.yipin.liuwanr.vo.UserVO;
import org.apache.kafka.common.protocol.types.Field;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
@ -28,6 +27,9 @@ public class StudentController {
@Autowired
private UserService userService;
@Autowired
private UserInfoService userInfoService;
@Autowired
RedisHelper redisHelper;
@ -58,55 +60,181 @@ public class StudentController {
}
// /**
// * 添加学生
// */
// @Transactional
// @PostMapping("/addStudent")
// Response addStudent(@RequestBody UserVO vo) {
// Response resp = new Response();
// Student student = vo.getStudent();
// UserM user = vo.getUser();
// if (student.getPhone()==null) {
// resp.setStatus(300);
// resp.setErrmessage("Parameter Invalid");
// } else {
// HashMap<String, Object> ret = studentService.addStudent(student);
// int status = (int) ret.get("retcode");
// if (200 == status) {
// resp.setStatus(status);
// resp.setMessage(ret.get("retvalue"));
// HashMap<String, Object> ret1 = userService.addUser(user);
// int status1 = (int)ret.get("retcode");
// if (status1 == 200){
// resp.setStatus(status1);
// resp.setMessage(ret1.get("retvalue"));
// }else {
// resp.setStatus(status1);
// resp.setErrmessage(ret1.get("retvalue").toString());
// throw new RuntimeException();
// }
// } else {
// resp.setStatus(status);
// resp.setErrmessage(ret.get("retvalue").toString());
// throw new RuntimeException();
// }
// }
// return resp;
// }
/**
* 添加学生
* 查询学生详情
*/
@Transactional
@PostMapping("/addStudent")
Response addStudent(@RequestBody UserVO vo) {
@GetMapping("/queryStudentDetails")
Response queryStudentDetails(@RequestParam Integer studentId) {
Response resp = new Response();
Student student = vo.getStudent();
UserM user = vo.getUser();
if (student.getPhone()==null) {
if (studentId==null) {
resp.setStatus(300);
resp.setErrmessage("Parameter Invalid");
resp.setErrmessage("学生id为空,查询失败!");
}else {
HashMap<String, Object> ret = studentService.addStudent(student);
HashMap<String, Object> ret = studentService.queryStudentDetails(studentId);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
HashMap<String, Object> ret1 = userService.addUser(user);
int status1 = (int)ret.get("retcode");
if (status1 == 200){
resp.setStatus(status1);
resp.setMessage(ret1.get("retvalue"));
}else {
resp.setStatus(status1);
resp.setErrmessage(ret1.get("retvalue").toString());
throw new RuntimeException();
}
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
throw new RuntimeException();
}
}
return resp;
}
//
// /**
// * 根据professionalIds(专业id)查询所有学生
// * @param schoolId 必须
// * @param professionalId
// * @param pageNo
// * @param pageSize
// * @return
// */
// @GetMapping("queryStudent/byProfessionalIds")
// Response queryStudentByProfessionalIds(@RequestParam Integer schoolId,@RequestParam Integer professionalId,Integer pageNo,Integer pageSize){
// Response resp = new Response();
// if (schoolId == null){
// resp.setMessage(300);
// resp.setErrmessage("学校id为空,查询失败!");
// }else{
// HashMap<String, Object> ret = studentService.queryStudentByProfessionalIds(professionalId, pageNo, pageSize, schoolId);
// QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue");
// }
// return resp;
// }
//
// /**
// * 根据年级id查询所有学生信息
// * @param schoolId
// * @param gradeId
// * @param pageNo
// * @param pageSize
// * @return
// */
// @GetMapping("queryStudent/byGradeId")
// Response queryStudentByGradeId(@RequestParam Integer schoolId, @RequestParam Integer gradeId, Integer pageNo, Integer pageSize){
// Response resp = new Response();
// if (schoolId == null){
// resp.setMessage(300);
// resp.setErrmessage("学校id为空,查询失败!");
// }else {
// HashMap<String, Object> ret = studentService.queryStudentByGradeIds(gradeId, pageNo, pageSize, schoolId);
// QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue");
// }
// return resp;
// }
// /**
// * 根据班级id查询所有学生信息
// * @param schoolId
// * @param classId
// * @param pageNo
// * @param pageSize
// * @return
// */
// @GetMapping("queryStudent/byClassIds")
// Response queryStudentByClassIds(@RequestParam Integer schoolId,@RequestParam Integer classId,Integer pageNo,Integer pageSize){
//
// Response resp = new Response();
// if (schoolId == null){
// resp.setMessage(300);
// resp.setErrmessage("学校id为空,查询失败!");
// }else {
// HashMap<String, Object> ret = studentService.queryStudentByClassIds(classId, pageNo, pageSize, schoolId);
// QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue");
// }
// return resp;
// }
//
// /**
// * 删除学生
// */
// @PostMapping("/deleteStudent")
// Response deleteStudent(@RequestBody List<Student> studentList) {
// Response resp = new Response();
// int size = studentList.size();
// for (int i=0;i<size;i++){
// Student student = studentList.get(i);
// Integer studentId = student.getStudentId();
// String phone = student.getPhone();
// if (studentId==null) {
// resp.setStatus(300);
// resp.setErrmessage("学生id为空,删除失败!");
// }else if (phone == null || phone == ""){
// resp.setStatus(300);
// resp.setErrmessage("学生电话为空,删除失败!");
// }
// else {
// HashMap<String, Object> ret = studentService.deleteStudent(studentId,phone);
// int status = (int) ret.get("retcode");
// if (200 == status) {
// resp.setStatus(status);
// resp.setMessage(ret.get("retvalue"));
// } else {
// resp.setStatus(status);
// resp.setErrmessage(ret.get("retvalue").toString());
// }
// }
// }
// return resp;
// }
/**
* 查询学生详情
* 更新学生
*/
@GetMapping("/queryStudentDetails")
Response queryStudentDetails(@RequestParam Integer studentId) {
@PostMapping("/updateStudent")
Response updateStudent(@RequestBody UserVO vo) {
Response resp = new Response();
Student student = vo.getStudent();
UserM user = vo.getUser();
Integer studentId = student.getStudentId();
String phone = user.getPhone();
if (studentId==null) {
resp.setStatus(300);
resp.setErrmessage("学生id为空,查询失败!");
resp.setErrmessage("学生id为空,修改失败!");
}else if (phone==null||phone==""){
resp.setStatus(300);
resp.setErrmessage("电话为空,修改失败!");
} else {
HashMap<String, Object> ret = studentService.queryStudentDetails(studentId);
HashMap<String, Object> ret = studentService.updateStudent(vo);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
@ -120,128 +248,114 @@ public class StudentController {
}
/**
* 根据professionalIds专业id查询所有学生
* @param schoolId 必须
* @param professionalId
* @param pageNo
* @param pageSize
* @return
* 添加学生信息
* 接收参数
* UserInfo:account,userName,roleId,uniqueIdentificationAccount,phone,email,schoolId
* OrganizationRelationship:workNumber,professionalClassId,gradeId,classId,schoolId
*/
@GetMapping("queryStudent/byProfessionalIds")
Response queryStudentByProfessionalIds(@RequestParam Integer schoolId,@RequestParam Integer professionalId,Integer pageNo,Integer pageSize){
Response resp = new Response();
if (schoolId == null){
resp.setMessage(300);
resp.setErrmessage("学校id为空,查询失败!");
@Transactional
@PostMapping("/addStudent")
Response addStudent(@RequestBody UserInfoVO vo) {
Response response = new Response();
// Student student = vo.getStudent();
UserInfo userInfo = vo.getUserInfo();
OrganizationRelationship organizationRelationship = vo.getOrganizationRelationship();
String account = userInfo.getAccount();
String userName = userInfo.getUserName();
Integer roleId = userInfo.getRoleId();
String uniqueIdentificationAccount = userInfo.getUniqueIdentificationAccount();
String phone = userInfo.getPhone();
String email = userInfo.getEmail();
String workNumber = organizationRelationship.getWorkNumber();
Integer professionalId = organizationRelationship.getProfessionalId();
Integer gradeId = organizationRelationship.getGradeId();
Integer classId = organizationRelationship.getClassId();
// UserM user = vo.getUser();
if (account==null||userName==null||roleId!=4||uniqueIdentificationAccount==null||workNumber==null||professionalId<=0||gradeId<=0||classId<=0) {
response.setStatus(300);
response.setErrmessage("Parameter Invalid");
} else {
HashMap<String, Object> ret = studentService.queryStudentByProfessionalIds(professionalId, pageNo, pageSize, schoolId);
QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue");
}
return resp;
HashMap<String, Object> ret = userInfoService.addUserInfo(userInfo);
int status = (int) ret.get("retcode");
if (200 == status) {
response.setStatus(status);
response.setMessage(ret.get("retvalue"));
Integer userId = userInfo.getUserId();
organizationRelationship.setUserId(userId);
HashMap<String, Object> ret1 = userInfoService.addOrganizationRelationship(organizationRelationship);
int status1 = (int)ret.get("retcode");
if (status1 == 200){
response.setStatus(status1);
response.setMessage(ret1.get("retvalue"));
}else {
response.setStatus(status1);
response.setErrmessage(ret1.get("retvalue").toString());
throw new RuntimeException();
}
/**
* 根据年级id查询所有学生信息
* @param schoolId
* @param gradeId
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("queryStudent/byGradeId")
Response queryStudentByGradeId(@RequestParam Integer schoolId, @RequestParam Integer gradeId, Integer pageNo, Integer pageSize){
Response resp = new Response();
if (schoolId == null){
resp.setMessage(300);
resp.setErrmessage("学校id为空,查询失败!");
} else {
HashMap<String, Object> ret = studentService.queryStudentByGradeIds(gradeId, pageNo, pageSize, schoolId);
QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue");
response.setStatus(status);
response.setErrmessage(ret.get("retvalue").toString());
throw new RuntimeException();
}
return resp;
}
return response;
}
/**
* 根据班级id查询所有学生信息
* 查询学生信息
* @param schoolId
* @param classId
* @param professionalIds
* @param searchContent
* @param gradeIds
* @param classIds
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("queryStudent/byClassIds")
Response queryStudentByClassIds(@RequestParam Integer schoolId,@RequestParam Integer classId,Integer pageNo,Integer pageSize){
Response resp = new Response();
@GetMapping("/queryStudent")
Response queryStudent(@RequestParam Integer schoolId, String professionalIds, String searchContent, String gradeIds, String classIds, Integer pageNo, Integer pageSize) {
Response response = new Response();
StudentInfo studentInfo = new StudentInfo();
if (schoolId == null) {
resp.setMessage(300);
resp.setErrmessage("学校id为空,查询失败!");
response.setStatus(300);
response.setErrmessage("学校信息为空");
} else {
HashMap<String, Object> ret = studentService.queryStudentByClassIds(classId, pageNo, pageSize, schoolId);
QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue");
}
return resp;
if (searchContent != null && searchContent != "") {
studentInfo.setSearchContent(searchContent);
}
/**
* 删除学生
*/
@PostMapping("/deleteStudent")
Response deleteStudent(@RequestBody List<Student> studentList) {
Response resp = new Response();
int size = studentList.size();
for (int i=0;i<size;i++){
Student student = studentList.get(i);
Integer studentId = student.getStudentId();
String phone = student.getPhone();
if (studentId==null) {
resp.setStatus(300);
resp.setErrmessage("学生id为空,删除失败!");
}else if (phone == null || phone == ""){
resp.setStatus(300);
resp.setErrmessage("学生电话为空,删除失败!");
if (professionalIds!=null&&professionalIds!="") {
studentInfo.setProfessionalIds(professionalIds);
}
else {
HashMap<String, Object> ret = studentService.deleteStudent(studentId,phone);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
if (gradeIds!=null&&gradeIds!="") {
studentInfo.setGradeIds(gradeIds);
}
if (classIds!=null&&classIds!="") {
studentInfo.setClassIds(classIds);
}
studentInfo.setSchoolId(schoolId);
HashMap map = userInfoService.queryStudent(studentInfo,pageNo,pageSize);
QueryStudentUtils.statusInformationController(response,map, "retcode", "retvalue");
}
return resp;
return response;
}
/**
* 更新学生
* 批量删除学生
*
* @param userId 用户id
* @return
*/
@PostMapping("/updateStudent")
Response updateStudent(@RequestBody UserVO vo) {
Response resp = new Response();
Student student = vo.getStudent();
UserM user = vo.getUser();
Integer studentId = student.getStudentId();
String phone = user.getPhone();
if (studentId==null) {
resp.setStatus(300);
resp.setErrmessage("学生id为空,修改失败!");
}else if (phone==null||phone==""){
resp.setStatus(300);
resp.setErrmessage("电话为空,修改失败!");
} else {
HashMap<String, Object> ret = studentService.updateStudent(vo);
int status = (int) ret.get("retcode");
if (200 == status) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
@GetMapping("/deleteStudent")
Response deleteStudent(Integer[] userId) {
Response response = new Response();
if (userId!=null&&userId.length > 0) {
userInfoService.deleteStudent(userId);
response.setStatus(200);
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
response.setStatus(500);
response.setErrmessage("学生id不能为空");
}
return resp;
return response;
}
}

@ -33,127 +33,116 @@ public class UserInfoController {
RedisHelper redisHelper;
/**
* 接收参数
* UserInfo:account,userName,roleId,uniqueIdentificationAccount,phone,email
* OrganizationRelationship:workNumber,professionalClassId,gradeId,classId
*/
@PostMapping("/addStudent")
Response addUserInfo(@RequestBody UserInfoVO vo) {
Response response = new Response();
// Student student = vo.getStudent();
UserInfo userInfo = vo.getUserInfo();
OrganizationRelationship organizationRelationship = vo.getOrganizationRelationship();
String account = userInfo.getAccount();
String userName = userInfo.getUserName();
Integer roleId = userInfo.getRoleId();
String uniqueIdentificationAccount = userInfo.getUniqueIdentificationAccount();
String phone = userInfo.getPhone();
String email = userInfo.getEmail();
String workNumber = organizationRelationship.getWorkNumber();
Integer professionalId = organizationRelationship.getProfessionalId();
Integer gradeId = organizationRelationship.getGradeId();
Integer classId = organizationRelationship.getClassId();
// UserM user = vo.getUser();
if (account==null||userName==null||roleId!=4||uniqueIdentificationAccount==null||workNumber==null||professionalId<=0||gradeId<=0||classId<=0) {
response.setStatus(300);
response.setErrmessage("Parameter Invalid");
} else {
HashMap<String, Object> ret = userInfoService.addUserInfo(userInfo);
int status = (int) ret.get("retcode");
if (200 == status) {
response.setStatus(status);
response.setMessage(ret.get("retvalue"));
HashMap<String, Object> ret1 = userInfoService.addOrganizationRelationship(organizationRelationship);
int status1 = (int)ret.get("retcode");
if (status1 == 200){
response.setStatus(status1);
response.setMessage(ret1.get("retvalue"));
}else {
response.setStatus(status1);
response.setErrmessage(ret1.get("retvalue").toString());
throw new RuntimeException();
}
} else {
response.setStatus(status);
response.setErrmessage(ret.get("retvalue").toString());
throw new RuntimeException();
}
}
return response;
}
/**
* 查询学生信息
* @param schoolId
* @param professionalIds
* @param searchContent
* @param gradeIds
* @param classIds
* @param pageNo
* @param pageSize
* @return
*/
@GetMapping("/queryStudent")
Response queryStudent(@RequestParam Integer schoolId, Integer[] professionalIds, String searchContent, Integer[] gradeIds, Integer[] classIds, Integer pageNo, Integer pageSize) {
Response response = new Response();
UserInfo userInfo = new UserInfo();
OrganizationRelationship ship = new OrganizationRelationship();
HashMap<Object, Object> ids = new HashMap<>(8);
if (schoolId == null) {
response.setStatus(300);
response.setErrmessage("学校信息为空");
} else {
if (searchContent != null && searchContent != "") {
userInfo.setSearchContent(searchContent);
}
if (professionalIds.length > 0) {
// List<Integer> professionalList = Arrays.asList(professionalId);
for (Integer professionalId:professionalIds){
ship.setProfessionalId(professionalId);
}
}
if (gradeIds.length > 0) {
// List<Integer> gradeList = Arrays.asList(gradeIds);
for (Integer gradeId:gradeIds){
ship.setGradeId(gradeId);
}
}
if (classIds.length > 0) {
// List<Integer> classList = Arrays.asList(classIds);
for (Integer classId:classIds){
ship.setClassId(classId);
}
}
userInfo.setSchoolId(schoolId);
// HashMap map = userInfoService.queryStudent(userInfo,ship,pageNo,pageSize);
// /**
// * 接收参数:
// * UserInfo:account,userName,roleId,uniqueIdentificationAccount,phone,email
// * OrganizationRelationship:workNumber,professionalClassId,gradeId,classId
// */
// @Transactional
// @PostMapping("/addStudent")
// Response addStudent(@RequestBody UserInfoVO vo) {
// Response response = new Response();
//// Student student = vo.getStudent();
// UserInfo userInfo = vo.getUserInfo();
// OrganizationRelationship organizationRelationship = vo.getOrganizationRelationship();
// String account = userInfo.getAccount();
// String userName = userInfo.getUserName();
// Integer roleId = userInfo.getRoleId();
// String uniqueIdentificationAccount = userInfo.getUniqueIdentificationAccount();
// String phone = userInfo.getPhone();
// String email = userInfo.getEmail();
// String workNumber = organizationRelationship.getWorkNumber();
// Integer professionalId = organizationRelationship.getProfessionalId();
// Integer gradeId = organizationRelationship.getGradeId();
// Integer classId = organizationRelationship.getClassId();
//
//// UserM user = vo.getUser();
// if (account==null||userName==null||roleId!=4||uniqueIdentificationAccount==null||workNumber==null||professionalId<=0||gradeId<=0||classId<=0) {
// response.setStatus(300);
// response.setErrmessage("Parameter Invalid");
// } else {
// HashMap<String, Object> ret = userInfoService.addUserInfo(userInfo);
// int status = (int) ret.get("retcode");
// if (200 == status) {
// response.setStatus(status);
// response.setMessage(ret.get("retvalue"));
// Integer userId = userInfo.getUserId();
// organizationRelationship.setUserId(userId);
// HashMap<String, Object> ret1 = userInfoService.addOrganizationRelationship(organizationRelationship);
// int status1 = (int)ret.get("retcode");
// if (status1 == 200){
// response.setStatus(status1);
// response.setMessage(ret1.get("retvalue"));
// }else {
// response.setStatus(status1);
// response.setErrmessage(ret1.get("retvalue").toString());
// throw new RuntimeException();
// }
// } else {
// response.setStatus(status);
// response.setErrmessage(ret.get("retvalue").toString());
// throw new RuntimeException();
// }
// }
// return response;
// }
//
// /**
// * 查询学生信息
// * @param schoolId
// * @param professionalIds
// * @param searchContent
// * @param gradeIds
// * @param classIds
// * @param pageNo
// * @param pageSize
// * @return
// */
// @GetMapping("/queryStudent")
// Response queryStudent(@RequestParam Integer schoolId, String professionalIds, String searchContent, String gradeIds, String classIds, Integer pageNo, Integer pageSize) {
// Response response = new Response();
// StudentInfo studentInfo = new StudentInfo();
// if (schoolId == null) {
// response.setStatus(300);
// response.setErrmessage("学校信息为空");
// } else {
// if (searchContent != null && searchContent != "") {
// studentInfo.setSearchContent(searchContent);
// }
// if (professionalIds!=null&&professionalIds!="") {
// studentInfo.setProfessionalIds(professionalIds);
// }
// if (gradeIds!=null&&gradeIds!="") {
// studentInfo.setGradeIds(gradeIds);
// }
// if (classIds!=null&&classIds!="") {
// studentInfo.setClassIds(classIds);
// }
// studentInfo.setSchoolId(schoolId);
// HashMap map = userInfoService.queryStudent(studentInfo,pageNo,pageSize);
// QueryStudentUtils.statusInformationController(response,map, "retcode", "retvalue");
}
return response;
}
/**
* 批量删除学生
*
* @param ids 用户id
* @return
*/
@GetMapping("/deleteStudent")
Response deleteStudent(Integer[] ids) {
Response response = new Response();
if (ids.length > 0) {
userInfoService.deleteStudent(ids);
response.setStatus(200);
} else {
response.setStatus(500);
response.setErrmessage("学生id不能为空");
}
return response;
}
// }
// return response;
// }
//
// /**
// * 批量删除学生
// *
// * @param ids 用户id
// * @return
// */
// @GetMapping("/deleteStudent")
// Response deleteStudent(Integer[] ids) {
// Response response = new Response();
// if (ids.length > 0) {
// userInfoService.deleteStudent(ids);
// response.setStatus(200);
// } else {
// response.setStatus(500);
// response.setErrmessage("学生id不能为空");
// }
// return response;
// }
/**
* 添加用户

@ -0,0 +1,85 @@
package com.yipin.liuwanr.entity;
public class StudentInfo {
private Integer schoolId;
private String professionalIds;
private String classIds;
private String gradeIds;
private String searchContent;
private String logInNumber;
private String userName;
private String lastLoginTime;
private Integer roleId;
public Integer getSchoolId() {
return schoolId;
}
public void setSchoolId(Integer schoolId) {
this.schoolId = schoolId;
}
public String getProfessionalIds() {
return professionalIds;
}
public void setProfessionalIds(String professionalIds) {
this.professionalIds = professionalIds;
}
public String getClassIds() {
return classIds;
}
public void setClassIds(String classIds) {
this.classIds = classIds;
}
public String getGradeIds() {
return gradeIds;
}
public void setGradeIds(String gradeIds) {
this.gradeIds = gradeIds;
}
public String getSearchContent() {
return searchContent;
}
public void setSearchContent(String searchContent) {
this.searchContent = searchContent;
}
public String getLogInNumber() {
return logInNumber;
}
public void setLogInNumber(String logInNumber) {
this.logInNumber = logInNumber;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getLastLoginTime() {
return lastLoginTime;
}
public void setLastLoginTime(String lastLoginTime) {
this.lastLoginTime = lastLoginTime;
}
public Integer getRoleId() {
return roleId;
}
public void setRoleId(Integer roleId) {
this.roleId = roleId;
}
}

@ -13,8 +13,8 @@ import java.util.List;
public interface OrganizationRelationshipMapper{
@Insert({"<script>" +
"INSERT INTO hr_organization_relationship(roleId,workNumber,professionalId,gradeId,classId,isdel)",
"VALUES(#{roleId},#{workNumber},#{professionalId},#{gradeId},#{classId},0)",
"INSERT INTO hr_organization_relationship(userId,roleId,workNumber,professionalId,gradeId,classId,isdel,schoolId,platformId)",
"VALUES(#{userId},4,#{workNumber},#{professionalId},#{gradeId},#{classId},0,#{schoolId},1)",
"</script>"})
Integer insertOrganizationRelationship(OrganizationRelationship organizationRelationship);

@ -13,26 +13,33 @@ public interface UserInfoMapper{
@Insert("INSERT INTO hr_user_info(userName,uniqueIdentificationAccount,documentType,IDNumber,provinceId,cityId,countries,dateBirth,educationDegree,schoolId,phone,weChatID,email,account,password,creationTime,logInNumber,sex,userAvatars,isdel)"
+ " VALUES(#{userName},#{uniqueIdentificationAccount},#{documentType},#{IDNumber},#{provinceId},#{cityId},#{countries},#{dateBirth},#{educationDegree},#{schoolId},#{phone},#{weChatID},#{email},#{account},#{password},now(),#{logInNumber},#{sex},#{userAvatars},0)")
@Options(useGeneratedKeys=true, keyProperty="userId", keyColumn="userId")
Integer insertUserInfo(UserInfo userInfo);
/**
* 批量查询学生信息
* @param
* @return
*/
@Select({"<script>" ,
"SELECT u.logInNumber,u.userName,u.lastLoginTime,o.roleId, o.gradeId, o.classId, o.professionalId FROM hr_user_info u,hr_organization_relationship o WHERE o.roleId = 4 AND u.schoolId = #{schoolId} AND u.isdel = 0",
"SELECT DISTINCT\n" +
"\tu.logInNumber,\n" +
"\tu.userName,\n" +
"\tu.lastLoginTime,\n" +
"\to.roleId,\n" +
"\to.gradeId,\n" +
"\to.classId,\n" +
"\to.workNumber,\n" +
"\to.professionalId \n" +
"FROM\n" +
"\thr_user_info u,\n" +
"\thr_organization_relationship o \n" +
"WHERE\n" +
"\to.roleId = 4 \n" +
"\tAND u.schoolId = 1 \n" +
"\tAND u.isdel = 0 \n",
"<if test='searchContent!=null'>AND (u.userName like CONCAT('%',#{searchContent},'%') or u.userId like CONCAT('%',#{searchContent},'%'))</if>",
// "<if test='professionalIds.size()>0'> OR o.professionalId IN <foreach collection='professionalIds' item='professionalId' open='(' separator=',' close=')'>#{professionalId}</foreach></if>" ,
// "<if test='gradeIds.size()>0'>OR o.gradeId IN <foreach collection='gradeIds' item='gradeId' open='(' separator=',' close=')'>#{gradeId}</foreach></if>" ,
// "<if test='classIds.size()>0'>OR o.classId IN <foreach collection='classIds' item='classId' open='(' separator=',' close=')'>#{classId}</foreach></if>" ,
"<if test='professionalId>0'> OR o.professionalId = #{professionalId}</if>" ,
"<if test='gradeId>0'>OR o.gradeId = #{gradeId}</if>" ,
"<if test='classId>0'>OR o.classId = #{classId}</if>" ,
"ORDER BY o.professionalId desc,o.gradeId desc,o.classId desc",
"<if test='gradeIds!=null'>and FIND_IN_SET(o.gradeId,#{gradeIds})</if>",
"<if test='professionalIds!=null'>and FIND_IN_SET(o.professionalId,#{professionalIds})</if>",
"<if test='classIds!=null'>and FIND_IN_SET(o.classId,#{classIds})</if>",
"ORDER BY o.classId desc",
"</script>"})
// List queryStudent(UserInfo userInfo,OrganizationRelationship organizationRelationship);
List queryStudent(String searchContent,Integer schoolId,Integer gradeId,Integer classId,Integer professionalId);
List<StudentInfo> queryStudent(StudentInfo studentInfo);
@Update({"<script>" +
"UPDATE hr_user_info SET isdel=1 WHERE userId IN " +

@ -84,18 +84,18 @@ public class UserInfoService {
public HashMap<String,Object> addUserInfo(UserInfo userInfo){
HashMap<String, Object> resp = new HashMap<>();
try {
userInfo.setPassword("hanran999");
userInfo.setPassword("hanran123");
int insert = userInfoMapper.insertUserInfo(userInfo);
if (insert>0){
resp.put(RETCODE,200);
}else{
resp.put(RETCODE,400);
resp.put(RETVALUE,"student/insert Invalid");
resp.put(RETVALUE,"student/insertUSERINFO Invalid");
}
}catch (RuntimeException e){
logger.error(e);
resp.put(RETCODE,500);
resp.put(RETVALUE,"student/insert Invalid");
resp.put(RETVALUE,"student/insertUSERINFO abnormal");
}
return resp;
}
@ -109,11 +109,11 @@ public class UserInfoService {
resp.put(RETCODE,200);
}else{
resp.put(RETCODE,400);
resp.put(RETVALUE,"student/insert Invalid");
resp.put(RETVALUE,"student/insertORGANIZA Invalid");
}
}catch (RuntimeException e){
resp.put(RETCODE,500);
resp.put(RETVALUE,"student/insert Invalid");
resp.put(RETVALUE,"student/insertORGANIZA abnormal");
}
return resp;
}
@ -122,21 +122,13 @@ public class UserInfoService {
* 批量查询学生信息
*/
@Transactional
public HashMap<String,Object> queryStudent(UserInfo userInfo,OrganizationRelationship ship,Integer pageNo,Integer pageSize){
public HashMap<String,Object> queryStudent(StudentInfo studentInfo,Integer pageNo,Integer pageSize){
HashMap<String, Object> resp = new HashMap<String, Object>();
// UserInfo user = new UserInfo();
// OrganizationRelationship organizationRelationship = new OrganizationRelationship();
String searchContent = userInfo.getSearchContent();
Integer schoolId = userInfo.getSchoolId();
Integer gradeId = ship.getGradeId();
Integer classId = ship.getClassId();
Integer professionalId = ship.getProfessionalId();
try {
if(pageNo!=null&&pageSize!=null) {
PageHelper.startPage(pageNo, pageSize);
List list = userInfoMapper.queryStudent(searchContent, schoolId, gradeId, classId, professionalId);
PageInfo info=new PageInfo(list);
List<StudentInfo> list = userInfoMapper.queryStudent(studentInfo);
PageInfo<StudentInfo> info=new PageInfo(list);
int total1 = (int) info.getTotal();
int totalPages;
totalPages = total1 / pageSize;
@ -147,7 +139,7 @@ public class UserInfoService {
resp.put("retvalue", new PageResult(total, list,totalPages));
resp.put("retcode", 200);
}else {
List<UserInfo> list = userInfoMapper.queryStudent(searchContent,schoolId,gradeId,classId,professionalId);
List<StudentInfo> list = userInfoMapper.queryStudent(studentInfo);
resp.put("retvalue", list);
resp.put("retcode", 200);
}

@ -1,6 +1,7 @@
package com.yipin.liuwanr.service;
import com.yipin.liuwanr.entity.OrganizationRelationship;
import com.yipin.liuwanr.entity.StudentInfo;
import com.yipin.liuwanr.entity.UserInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -50,26 +51,16 @@ public class StudentServiceTest {
*/
@Test
public void queryStudent(){
UserInfo userInfo = new UserInfo();
StudentInfo studentInfo = new StudentInfo();
OrganizationRelationship organizationRelationship = new OrganizationRelationship();
userInfo.setSchoolId(1);
userInfo.setSearchContent("1");
Integer[] a = {1,2};
Integer[] b = {1,2};
Integer[] c = {1,2};
studentInfo.setSchoolId(1);
studentInfo.setSearchContent("8");
for (Integer aa: a){
organizationRelationship.setProfessionalId(aa);
}
for (Integer bb:b){
organizationRelationship.setGradeId(bb);
}
for (Integer cc:c){
organizationRelationship.setClassId(cc);
}
Integer pageNo = 1;
Integer pageSize = 3;
HashMap<String, Object> map = userInfoService.queryStudent(userInfo, organizationRelationship, pageNo, pageSize);
HashMap<String, Object> map = userInfoService.queryStudent(studentInfo, pageNo, pageSize);
for (String s : map.keySet()) {
System.out.println("key:" + s + "," + "value:" + map.get(s));
}

Loading…
Cancel
Save