添加学生管理的添加学生和删除学生接口

master
mzh820631607 4 years ago
parent a3141cca39
commit 5585f78693
  1. 6
      src/main/java/com/yipin/liuwanr/controller/StudentController.java
  2. 391
      src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
  3. 30
      src/main/java/com/yipin/liuwanr/entity/OrganizationRelationship.java
  4. 14
      src/main/java/com/yipin/liuwanr/helper/QueryStudentUtils.java
  5. 9
      src/main/java/com/yipin/liuwanr/mapper/OrganizationRelationshipMapper.java
  6. 32
      src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
  7. 194
      src/main/java/com/yipin/liuwanr/service/UserInfoService.java
  8. 91
      src/test/java/com/yipin/liuwanr/service/StudentServiceTest.java

@ -135,7 +135,7 @@ public class StudentController {
resp.setErrmessage("学校id为空,查询失败!"); resp.setErrmessage("学校id为空,查询失败!");
}else{ }else{
HashMap<String, Object> ret = studentService.queryStudentByProfessionalIds(professionalId, pageNo, pageSize, schoolId); HashMap<String, Object> ret = studentService.queryStudentByProfessionalIds(professionalId, pageNo, pageSize, schoolId);
QueryStudentUtils.queryStudentByIds(resp, ret, "retcode", "retvalue"); QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue");
} }
return resp; return resp;
} }
@ -156,7 +156,7 @@ public class StudentController {
resp.setErrmessage("学校id为空,查询失败!"); resp.setErrmessage("学校id为空,查询失败!");
}else { }else {
HashMap<String, Object> ret = studentService.queryStudentByGradeIds(gradeId, pageNo, pageSize, schoolId); HashMap<String, Object> ret = studentService.queryStudentByGradeIds(gradeId, pageNo, pageSize, schoolId);
QueryStudentUtils.queryStudentByIds(resp, ret, "retcode", "retvalue"); QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue");
} }
return resp; return resp;
} }
@ -177,7 +177,7 @@ public class StudentController {
resp.setErrmessage("学校id为空,查询失败!"); resp.setErrmessage("学校id为空,查询失败!");
}else { }else {
HashMap<String, Object> ret = studentService.queryStudentByClassIds(classId, pageNo, pageSize, schoolId); HashMap<String, Object> ret = studentService.queryStudentByClassIds(classId, pageNo, pageSize, schoolId);
QueryStudentUtils.queryStudentByIds(resp, ret, "retcode", "retvalue"); QueryStudentUtils.statusInformationEntity(resp, ret, "retcode", "retvalue");
} }
return resp; return resp;
} }

@ -1,11 +1,13 @@
package com.yipin.liuwanr.controller; package com.yipin.liuwanr.controller;
import com.yipin.liuwanr.entity.*; import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.helper.QueryStudentUtils;
import com.yipin.liuwanr.helper.RedisHelper; import com.yipin.liuwanr.helper.RedisHelper;
import com.yipin.liuwanr.service.StaffService; import com.yipin.liuwanr.service.StaffService;
import com.yipin.liuwanr.service.StudentService; import com.yipin.liuwanr.service.StudentService;
import com.yipin.liuwanr.service.UserInfoService; import com.yipin.liuwanr.service.UserInfoService;
import com.yipin.liuwanr.vo.UserInfoVO; import com.yipin.liuwanr.vo.UserInfoVO;
import jdk.nashorn.internal.ir.IfNode;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -13,6 +15,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -32,8 +35,131 @@ public class UserInfoController {
@Autowired @Autowired
RedisHelper redisHelper; 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);
// 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;
}
/**
* 添加用户
*/ */
@Transactional @Transactional
@PostMapping("/addUser") @PostMapping("/addUser")
@ -59,45 +185,45 @@ public class UserInfoController {
Integer cityId = user.getCityId(); Integer cityId = user.getCityId();
//学校id //学校id
Integer schoolId = user.getSchoolId(); Integer schoolId = user.getSchoolId();
if(name==null||name==""){ if (name == null || name == "") {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("姓名不能为空!"); resp.setErrmessage("姓名不能为空!");
}else if(provinceId==null){ } else if (provinceId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("省份不能为空!"); resp.setErrmessage("省份不能为空!");
}else if(cityId==null){ } else if (cityId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("城市不能为空!"); resp.setErrmessage("城市不能为空!");
}else if(schoolId==null){ } else if (schoolId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("学校不能为空!"); resp.setErrmessage("学校不能为空!");
}else { } else {
HashMap<String, Object> ret = userInfoService.addUser(user); HashMap<String, Object> ret = userInfoService.addUser(user);
Integer userId = user.getUserId(); Integer userId = user.getUserId();
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
resp.setStatus(status); resp.setStatus(status);
resp.setMessage(ret.get("retvalue")); resp.setMessage(ret.get("retvalue"));
HashMap<String, Object> stu = userInfoService.addPersonalFile(userProfilesList,userId); HashMap<String, Object> stu = userInfoService.addPersonalFile(userProfilesList, userId);
int stuStatus = (int) stu.get("retcode"); int stuStatus = (int) stu.get("retcode");
if (stuStatus == 200){ if (stuStatus == 200) {
resp.setStatus(stuStatus); resp.setStatus(stuStatus);
resp.setMessage(stu.get("retvalue")); resp.setMessage(stu.get("retvalue"));
}else { } else {
resp.setStatus(stuStatus); resp.setStatus(stuStatus);
resp.setErrmessage(stu.get("retvalue").toString()); resp.setErrmessage(stu.get("retvalue").toString());
throw new RuntimeException(); throw new RuntimeException();
} }
HashMap<String, Object> sta = userInfoService.addStuStaff(ORList,userId); HashMap<String, Object> sta = userInfoService.addStuStaff(ORList, userId);
int staStatus = (int) sta.get("retcode"); int staStatus = (int) sta.get("retcode");
if (staStatus == 200){ if (staStatus == 200) {
resp.setStatus(staStatus); resp.setStatus(staStatus);
resp.setMessage(sta.get("retvalue")); resp.setMessage(sta.get("retvalue"));
}else { } else {
resp.setStatus(staStatus); resp.setStatus(staStatus);
resp.setErrmessage(sta.get("retvalue").toString()); resp.setErrmessage(sta.get("retvalue").toString());
throw new RuntimeException(); throw new RuntimeException();
} }
} else { } else {
resp.setStatus(status); resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString()); resp.setErrmessage(ret.get("retvalue").toString());
@ -108,49 +234,50 @@ public class UserInfoController {
} }
/** /**
* 查询用户(根据国家省份城市) * 查询用户(根据国家省份城市)
*/ */
@GetMapping("/queryUserInfo") @GetMapping("/queryUserInfo")
Response queryUserInfo(@RequestParam String countries, Integer provinceId, Integer cityId, Integer pageNo, Integer pageSize, Integer schoolId, Integer roleId, String searchContent, Integer month, String creationTime, String endTime) { Response queryUserInfo(@RequestParam String countries, Integer provinceId, Integer cityId, Integer pageNo, Integer pageSize, Integer schoolId, Integer roleId, String searchContent, Integer month, String creationTime, String endTime) {
Response resp = new Response(); Response resp = new Response();
UserInfo userInfo = new UserInfo(); UserInfo userInfo = new UserInfo();
//设置国家 //设置国家
if (countries != null&&countries!="") { if (countries != null && countries != "") {
userInfo.setCountries(countries); userInfo.setCountries(countries);
} }
//设置省份 //设置省份
if(provinceId!=null) { if (provinceId != null) {
userInfo.setProvinceId(provinceId); userInfo.setProvinceId(provinceId);
} }
//设置城市 //设置城市
if(cityId!=null) { if (cityId != null) {
userInfo.setCityId(cityId); userInfo.setCityId(cityId);
} }
//学校 //学校
if (schoolId!=null) { if (schoolId != null) {
userInfo.setSchoolId(schoolId); userInfo.setSchoolId(schoolId);
} }
//角色 //角色
if (roleId!=null) { if (roleId != null) {
userInfo.setRoleId(roleId); userInfo.setRoleId(roleId);
} }
//搜索内容 //搜索内容
if (searchContent!=null&&searchContent!="") { if (searchContent != null && searchContent != "") {
userInfo.setSearchContent(searchContent); userInfo.setSearchContent(searchContent);
} }
//月份 //月份
if (month!=null) { if (month != null) {
userInfo.setMonth(month);; userInfo.setMonth(month);
;
} }
//创建时间 //创建时间
if (creationTime!=null&&creationTime!="") { if (creationTime != null && creationTime != "") {
userInfo.setCreationTime(creationTime); userInfo.setCreationTime(creationTime);
} }
//结束时间 //结束时间
if (endTime!=null&&endTime!="") { if (endTime != null && endTime != "") {
userInfo.setEndTime(endTime); userInfo.setEndTime(endTime);
} }
HashMap<String, Object> ret = userInfoService.queryUserInfo(userInfo,pageNo,pageSize); HashMap<String, Object> ret = userInfoService.queryUserInfo(userInfo, pageNo, pageSize);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
resp.setStatus(status); resp.setStatus(status);
@ -163,49 +290,49 @@ public class UserInfoController {
} }
/** /**
* 删除用户(根据ID修改isdel状态,0可见 1不可见) * 删除用户(根据ID修改isdel状态,0可见 1不可见)
*/ */
@Transactional @Transactional
@PostMapping("/deleteUserInfo") @PostMapping("/deleteUserInfo")
public Response deleteUserInfo(@RequestBody List<Integer> userIdList) { public Response deleteUserInfo(@RequestBody List<Integer> userIdList) {
Response resp = new Response(); Response resp = new Response();
if (userIdList==null) { if (userIdList == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id为空,删除用户失败!"); resp.setErrmessage("用户id为空,删除用户失败!");
} else { } else {
HashMap<String, Object> ret = userInfoService.deleteUserInfo(userIdList); HashMap<String, Object> ret = userInfoService.deleteUserInfo(userIdList);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
resp.setStatus(status); resp.setStatus(status);
resp.setMessage(ret.get("retvalue")); resp.setMessage(ret.get("retvalue"));
HashMap<String, Object> sta = userInfoService.deleteOrganizationRelationship(userIdList); HashMap<String, Object> sta = userInfoService.deleteOrganizationRelationship(userIdList);
int staStatus = (int) sta.get("retcode"); int staStatus = (int) sta.get("retcode");
if (200 == staStatus) { if (200 == staStatus) {
resp.setStatus(staStatus); resp.setStatus(staStatus);
resp.setMessage(sta.get("retvalue")); resp.setMessage(sta.get("retvalue"));
}else{ } else {
resp.setStatus(staStatus); resp.setStatus(staStatus);
resp.setErrmessage(sta.get("retvalue").toString()); resp.setErrmessage(sta.get("retvalue").toString());
throw new RuntimeException();
}
}else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
throw new RuntimeException(); throw new RuntimeException();
} }
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
throw new RuntimeException();
} }
}
return resp; return resp;
} }
/** /**
* 更新用户 * 更新用户
*/ */
@Transactional @Transactional
@PostMapping("/updateUserInfo") @PostMapping("/updateUserInfo")
public Response updateUserInfo(@RequestBody UserInfo userInfo) { public Response updateUserInfo(@RequestBody UserInfo userInfo) {
Response resp = new Response(); Response resp = new Response();
Integer userId = userInfo.getUserId(); Integer userId = userInfo.getUserId();
if (userId==null) { if (userId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户ID为空,修改用户失败!"); resp.setErrmessage("用户ID为空,修改用户失败!");
} else { } else {
@ -224,7 +351,7 @@ public class UserInfoController {
} }
/** /**
* 更新用户个人档案 * 更新用户个人档案
*/ */
@Transactional @Transactional
@PostMapping("/updateUserProfiles") @PostMapping("/updateUserProfiles")
@ -250,7 +377,7 @@ public class UserInfoController {
} }
/** /**
* 更新用户组织关系 * 更新用户组织关系
*/ */
@Transactional @Transactional
@PostMapping("/updateOR") @PostMapping("/updateOR")
@ -275,19 +402,19 @@ public class UserInfoController {
} }
/** /**
* 登陆查询学校 * 登陆查询学校
*/ */
@GetMapping("/loginSchool") @GetMapping("/loginSchool")
Response loginSchool(@RequestParam("account") String account, @RequestParam("password") String password, HttpServletRequest req, HttpServletResponse res) { Response loginSchool(@RequestParam("account") String account, @RequestParam("password") String password, HttpServletRequest req, HttpServletResponse res) {
Response resp = new Response(); Response resp = new Response();
UserInfo userInfo = new UserInfo(); UserInfo userInfo = new UserInfo();
if (account == null || account=="") { if (account == null || account == "") {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户账号为空,登录失败!"); resp.setErrmessage("用户账号为空,登录失败!");
}else if(password ==null || password=="") { } else if (password == null || password == "") {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户密码为空,登录失败!"); resp.setErrmessage("用户密码为空,登录失败!");
}else{ } else {
userInfo.setAccount(account); userInfo.setAccount(account);
userInfo.setPassword(password); userInfo.setPassword(password);
HashMap<String, Object> ret = userInfoService.loginSchool(userInfo); HashMap<String, Object> ret = userInfoService.loginSchool(userInfo);
@ -304,23 +431,22 @@ public class UserInfoController {
} }
/** /**
* 登陆 * 登陆
*/ */
@GetMapping("/logins") @GetMapping("/logins")
Response logins(@RequestParam("userId") Integer userId, @RequestParam("schoolId") Integer schoolId,@RequestParam("roleId") Integer roleId, HttpServletRequest req, HttpServletResponse res) { Response logins(@RequestParam("userId") Integer userId, @RequestParam("schoolId") Integer schoolId, @RequestParam("roleId") Integer roleId, HttpServletRequest req, HttpServletResponse res) {
Response resp = new Response(); Response resp = new Response();
UserInfo userInfo = new UserInfo(); UserInfo userInfo = new UserInfo();
if (userId == null) { if (userId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id为空,登录失败!"); resp.setErrmessage("用户id为空,登录失败!");
}else if(schoolId ==null) { } else if (schoolId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户学校id为空,登录失败!"); resp.setErrmessage("用户学校id为空,登录失败!");
}else if(roleId ==null) { } else if (roleId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户角色id为空,登录失败!"); resp.setErrmessage("用户角色id为空,登录失败!");
} } else {
else{
userInfo.setRoleId(roleId); userInfo.setRoleId(roleId);
userInfo.setUserId(userId); userInfo.setUserId(userId);
userInfo.setSchoolId(schoolId); userInfo.setSchoolId(schoolId);
@ -338,19 +464,19 @@ 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(); OrganizationRelationship OR = new OrganizationRelationship();
if (userId == null) { if (userId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id为空,登录失败!"); resp.setErrmessage("用户id为空,登录失败!");
}else if(schoolId ==null) { } else if (schoolId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("角色id为空,登录失败!"); resp.setErrmessage("角色id为空,登录失败!");
}else{ } else {
OR.setUserId(userId); OR.setUserId(userId);
OR.setSchoolId(schoolId); OR.setSchoolId(schoolId);
HashMap<String, Object> ret = userInfoService.loginRole(OR); HashMap<String, Object> ret = userInfoService.loginRole(OR);
@ -367,15 +493,15 @@ public class UserInfoController {
} }
/** /**
* 查询用户详情(ID) * 查询用户详情(ID)
*/ */
@GetMapping("/queryUserInfoDetails") @GetMapping("/queryUserInfoDetails")
Response queryUserInfoDetails(@RequestParam Integer userId) { Response queryUserInfoDetails(@RequestParam Integer userId) {
Response resp = new Response(); Response resp = new Response();
if (userId==null) { if (userId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id为空!查询失败!"); resp.setErrmessage("用户id为空!查询失败!");
}else { } else {
HashMap<String, Object> ret = userInfoService.queryUserInfoDetails(userId); HashMap<String, Object> ret = userInfoService.queryUserInfoDetails(userId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
@ -390,19 +516,19 @@ public class UserInfoController {
} }
/** /**
* 查询用户组织架构OR(organization relationship) * 查询用户组织架构OR(organization relationship)
*/ */
@GetMapping("/queryUserOR") @GetMapping("/queryUserOR")
Response queryUserOR(@RequestParam Integer userId,Integer platformId) { Response queryUserOR(@RequestParam Integer userId, Integer platformId) {
Response resp = new Response(); Response resp = new Response();
if (userId==null) { if (userId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id为空!查询失败!"); resp.setErrmessage("用户id为空!查询失败!");
}else if (platformId==null){ } else if (platformId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("平台id为空!查询失败!"); resp.setErrmessage("平台id为空!查询失败!");
} else { } else {
HashMap<String, Object> ret = userInfoService.queryUserOR(userId,platformId); HashMap<String, Object> ret = userInfoService.queryUserOR(userId, platformId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
resp.setStatus(status); resp.setStatus(status);
@ -416,15 +542,15 @@ public class UserInfoController {
} }
/** /**
* 查询用户个人档案 * 查询用户个人档案
*/ */
@GetMapping("/queryUserProfiles") @GetMapping("/queryUserProfiles")
Response queryUserProfiles(@RequestParam Integer userId) { Response queryUserProfiles(@RequestParam Integer userId) {
Response resp = new Response(); Response resp = new Response();
if (userId==null) { if (userId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id为空!查询失败!"); resp.setErrmessage("用户id为空!查询失败!");
}else { } else {
HashMap<String, Object> ret = userInfoService.queryUserProfiles(userId); HashMap<String, Object> ret = userInfoService.queryUserProfiles(userId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
@ -441,11 +567,11 @@ public class UserInfoController {
@PostMapping("/uploadUserAvatars") @PostMapping("/uploadUserAvatars")
Response uploadUserAvatars(MultipartFile file, Integer userId) { Response uploadUserAvatars(MultipartFile file, Integer userId) {
Response resp = new Response(); Response resp = new Response();
if (userId==null) {//前台传来的值是否为空 if (userId == null) {//前台传来的值是否为空
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("Parameter Invalid"); resp.setErrmessage("Parameter Invalid");
}else { } else {
HashMap<String, Object> ret = userInfoService.uploadUserAvatars(file,userId); HashMap<String, Object> ret = userInfoService.uploadUserAvatars(file, userId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
@ -460,7 +586,7 @@ public class UserInfoController {
} }
/** /**
* 更新登录次数和时间 * 更新登录次数和时间
*/ */
@PostMapping("/updateLogInNumber") @PostMapping("/updateLogInNumber")
Response updateLogInNumber(@RequestBody UserM user) { Response updateLogInNumber(@RequestBody UserM user) {
@ -468,13 +594,13 @@ public class UserInfoController {
Integer userId = user.getUserId(); Integer userId = user.getUserId();
String phone = user.getPhone(); String phone = user.getPhone();
Integer accountRole = user.getAccountRole(); Integer accountRole = user.getAccountRole();
if (userId==null) { if (userId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id不能为空!"); resp.setErrmessage("用户id不能为空!");
}else if(phone==null||phone==""){ } else if (phone == null || phone == "") {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户电话不能为空!"); resp.setErrmessage("用户电话不能为空!");
} else if(accountRole==null){ } else if (accountRole == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户角色不能为空!"); resp.setErrmessage("用户角色不能为空!");
} else { } else {
@ -490,34 +616,35 @@ public class UserInfoController {
} }
return resp; return resp;
} }
/** /**
* 用户模块查询客户 * 用户模块查询客户
*/ */
@GetMapping("/queryCustomer") @GetMapping("/queryCustomer")
Response queryCustomer(@RequestParam String searchContent,@RequestParam List<Integer> customerIds) { Response queryCustomer(@RequestParam String searchContent, @RequestParam List<Integer> customerIds) {
Response resp = new Response(); Response resp = new Response();
HashMap<String, Object> ret = userInfoService.queryCustomer(searchContent,customerIds); HashMap<String, Object> ret = userInfoService.queryCustomer(searchContent, customerIds);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
resp.setStatus(status); resp.setStatus(status);
resp.setMessage(ret.get("retvalue")); resp.setMessage(ret.get("retvalue"));
} else { } else {
resp.setStatus(status); resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString()); resp.setErrmessage(ret.get("retvalue").toString());
} }
return resp; return resp;
} }
/** /**
* 查询账号是否存在 * 查询账号是否存在
*/ */
@GetMapping("/queryAccountIsExist") @GetMapping("/queryAccountIsExist")
Response queryAccountIsExist(@RequestParam String account) { Response queryAccountIsExist(@RequestParam String account) {
Response resp = new Response(); Response resp = new Response();
if (account==null&&account=="") { if (account == null && account == "") {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("账号为空!"); resp.setErrmessage("账号为空!");
}else { } else {
HashMap<String, Object> ret = userInfoService.queryAccountIsExist(account); HashMap<String, Object> ret = userInfoService.queryAccountIsExist(account);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
@ -532,20 +659,19 @@ public class UserInfoController {
} }
/** /**
* 查询学号工号是否存在 * 查询学号工号是否存在
*/ */
@GetMapping("/queryWorkNumberIsExist") @GetMapping("/queryWorkNumberIsExist")
Response queryWorkNumberIsExist(@RequestParam String workNumber,Integer roleId,Integer schoolId) { Response queryWorkNumberIsExist(@RequestParam String workNumber, Integer roleId, Integer schoolId) {
Response resp = new Response(); Response resp = new Response();
if (workNumber==null) { if (workNumber == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("学号、工号为空!"); resp.setErrmessage("学号、工号为空!");
}else if (roleId==null){ } else if (roleId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("角色id为空!"); resp.setErrmessage("角色id为空!");
} } else {
else { HashMap<String, Object> ret = userInfoService.queryWorkNumberIsExist(workNumber, roleId, schoolId);
HashMap<String, Object> ret = userInfoService.queryWorkNumberIsExist(workNumber,roleId,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);
@ -559,17 +685,17 @@ public class UserInfoController {
} }
/** /**
* 查询平台 * 查询平台
*/ */
@GetMapping("/queryPlatform") @GetMapping("/queryPlatform")
Response queryPlatform(@RequestParam String platformId) { Response queryPlatform(@RequestParam String platformId) {
Response resp = new Response(); Response resp = new Response();
UserInfo userInfo = new UserInfo(); UserInfo userInfo = new UserInfo();
//平台id //平台id
if (platformId==null&&platformId=="") { if (platformId == null && platformId == "") {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("平台id为空!"); resp.setErrmessage("平台id为空!");
}else{ } else {
HashMap<String, Object> ret = userInfoService.queryPlatform(platformId); HashMap<String, Object> ret = userInfoService.queryPlatform(platformId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
@ -584,7 +710,7 @@ public class UserInfoController {
} }
/** /**
* 删除平台 * 删除平台
*/ */
@PostMapping("/deletePlatform") @PostMapping("/deletePlatform")
Response deletePlatform(@RequestBody OrganizationRelationship OR) { Response deletePlatform(@RequestBody OrganizationRelationship OR) {
@ -592,15 +718,14 @@ public class UserInfoController {
Integer platformId = OR.getPlatformId(); Integer platformId = OR.getPlatformId();
Integer userId = OR.getUserId(); Integer userId = OR.getUserId();
//平台id //平台id
if (platformId==null) { if (platformId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("平台id为空!"); resp.setErrmessage("平台id为空!");
}else if(userId==null){ } else if (userId == null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id为空!"); resp.setErrmessage("用户id为空!");
} } else {
else{ HashMap<String, Object> ret = userInfoService.deletePlatform(platformId, userId);
HashMap<String, Object> ret = userInfoService.deletePlatform(platformId,userId);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
resp.setStatus(status); resp.setStatus(status);

@ -33,6 +33,10 @@ public class OrganizationRelationship {
private String professionalName; private String professionalName;
//年级ID //年级ID
private Integer gradeId; private Integer gradeId;
private String professionalIds;
private String gradeIds;
private String classIds;
//年级名称 //年级名称
private String gradeName; private String gradeName;
//班级ID //班级ID
@ -42,6 +46,32 @@ public class OrganizationRelationship {
//客户ID //客户ID
private Integer customerId; private Integer customerId;
public String getProfessionalIds() {
return professionalIds;
}
public void setProfessionalIds(String professionalIds) {
this.professionalIds = professionalIds;
}
public String getGradeIds() {
return gradeIds;
}
public void setGradeIds(String gradeIds) {
this.gradeIds = gradeIds;
}
public String getClassIds() {
return classIds;
}
public void setClassIds(String classIds) {
this.classIds = classIds;
}
public String getOneDepartmentIds() { public String getOneDepartmentIds() {
return oneDepartmentIds; return oneDepartmentIds;
} }

@ -13,7 +13,8 @@ public class QueryStudentUtils {
* @param retcode * @param retcode
* @param retvalue * @param retvalue
*/ */
public static void queryStudentByIds(Response resp,HashMap<String, Object> hashMap,String retcode,String retvalue){ //com.yipin.liuwanr.entity.Response
public static void statusInformationEntity(Response resp,HashMap<String, Object> hashMap,String retcode,String retvalue){
int status = (int)hashMap.get(retcode); int status = (int)hashMap.get(retcode);
if (status==200){ if (status==200){
@ -23,6 +24,17 @@ public class QueryStudentUtils {
resp.setStatus(status); resp.setStatus(status);
resp.setMessage(hashMap.get(retvalue.toString())); resp.setMessage(hashMap.get(retvalue.toString()));
} }
}
//com.yipin.liuwanr.controller.Response
public static void statusInformationController(com.yipin.liuwanr.controller.Response resp, HashMap<String, Object> hashMap, String retcode, String retvalue){
int status = (int)hashMap.get(retcode);
if (status==200){
resp.setStatus(status);
resp.setMessage(hashMap.get(retvalue));
}else{
resp.setStatus(status);
resp.setMessage(hashMap.get(retvalue.toString()));
}
} }
} }

@ -3,13 +3,20 @@ package com.yipin.liuwanr.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yipin.liuwanr.entity.OrganizationRelationship; import com.yipin.liuwanr.entity.OrganizationRelationship;
import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import java.util.List; import java.util.List;
@Mapper @Mapper
public interface OrganizationRelationshipMapper { public interface OrganizationRelationshipMapper{
@Insert({"<script>" +
"INSERT INTO hr_organization_relationship(roleId,workNumber,professionalId,gradeId,classId,isdel)",
"VALUES(#{roleId},#{workNumber},#{professionalId},#{gradeId},#{classId},0)",
"</script>"})
Integer insertOrganizationRelationship(OrganizationRelationship organizationRelationship);
@Select("select organizationRelationshipId,schoolName,professionalName,gradeName,className,workNumber,roleId " + @Select("select organizationRelationshipId,schoolName,professionalName,gradeName,className,workNumber,roleId " +
"from hr_organization_relationship where userId=#{userId} ") "from hr_organization_relationship where userId=#{userId} ")

@ -1,5 +1,6 @@
package com.yipin.liuwanr.mapper; package com.yipin.liuwanr.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yipin.liuwanr.entity.*; import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.vo.UserInfoVO; import com.yipin.liuwanr.vo.UserInfoVO;
import com.yipin.liuwanr.vo.UserVO; import com.yipin.liuwanr.vo.UserVO;
@ -8,7 +9,36 @@ import org.apache.ibatis.mapping.FetchType;
import java.util.List; import java.util.List;
public interface UserInfoMapper { 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)")
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",
"<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",
"</script>"})
// List queryStudent(UserInfo userInfo,OrganizationRelationship organizationRelationship);
List queryStudent(String searchContent,Integer schoolId,Integer gradeId,Integer classId,Integer professionalId);
@Update({"<script>" +
"UPDATE hr_user_info SET isdel=1 WHERE userId IN " +
"<foreach collection='list' item='userId' index='index' separator=',' open='(' close=')'>#{userId}</foreach>" +
"</script>"})
Integer updateStudentInfo(List list);
@Update({ "<script>", @Update({ "<script>",
"UPDATE lw_user SET", "UPDATE lw_user SET",

@ -1,12 +1,14 @@
package com.yipin.liuwanr.service; package com.yipin.liuwanr.service;
import com.aliyun.oss.OSSClient; import com.aliyun.oss.OSSClient;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.yipin.liuwanr.AliyunOssConfig; import com.yipin.liuwanr.AliyunOssConfig;
import com.yipin.liuwanr.entity.*; import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.helper.OssConfigUtil; import com.yipin.liuwanr.helper.OssConfigUtil;
import com.yipin.liuwanr.helper.RandomUtil; import com.yipin.liuwanr.helper.RandomUtil;
import com.yipin.liuwanr.mapper.OrganizationRelationshipMapper;
import com.yipin.liuwanr.mapper.StaffMapper; import com.yipin.liuwanr.mapper.StaffMapper;
import com.yipin.liuwanr.mapper.StudentMapper; import com.yipin.liuwanr.mapper.StudentMapper;
import com.yipin.liuwanr.mapper.UserInfoMapper; import com.yipin.liuwanr.mapper.UserInfoMapper;
@ -19,6 +21,7 @@ import org.springframework.web.multipart.MultipartFile;
import redis.clients.jedis.JedisCluster; import redis.clients.jedis.JedisCluster;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -28,6 +31,9 @@ import java.util.List;
public class UserInfoService { public class UserInfoService {
private static Logger logger = Logger.getLogger(UserInfoService.class); private static Logger logger = Logger.getLogger(UserInfoService.class);
private final static String RETCODE = "retcode";
private final static String RETVALUE = "retvalue";
@Autowired @Autowired
private StaffMapper staffMapper; private StaffMapper staffMapper;
@ -41,6 +47,118 @@ public class UserInfoService {
private AliyunOssConfig config; private AliyunOssConfig config;
@Autowired @Autowired
private BeanFactory beanFactory; private BeanFactory beanFactory;
@Autowired
private OrganizationRelationshipMapper organizationRelationshipMapper;
/**
* 批量删除学生信息
*/
@Transactional
public HashMap<String,Object> deleteStudent(Integer[] ids){
HashMap<String, Object> resp = new HashMap<String, Object>();
// UpdateWrapper<UserInfo> updateWrapper = new UpdateWrapper<UserInfo>();
// UserInfo userInfo = new UserInfo();
// for (Integer id:ids){
// userInfo.setUserId(id);
// }
// //修改学生状态信息码为1
// updateWrapper.eq("isdel",1);
// int update = userInfoMapper.update(userInfo, updateWrapper);
ArrayList<Object> list = new ArrayList<>();
for (Integer id : ids){
list.add(id);
}
int update = userInfoMapper.updateStudentInfo(list);
if (update>0){
resp.put(RETCODE,200);
}else{
resp.put(RETCODE,500);
resp.put(RETVALUE,"student/delete Invalid");
}
return resp;
}
/**
* 添加学生信息
*/
public HashMap<String,Object> addUserInfo(UserInfo userInfo){
HashMap<String, Object> resp = new HashMap<>();
try {
userInfo.setPassword("hanran999");
int insert = userInfoMapper.insertUserInfo(userInfo);
if (insert>0){
resp.put(RETCODE,200);
}else{
resp.put(RETCODE,400);
resp.put(RETVALUE,"student/insert Invalid");
}
}catch (RuntimeException e){
logger.error(e);
resp.put(RETCODE,500);
resp.put(RETVALUE,"student/insert Invalid");
}
return resp;
}
public HashMap<String,Object> addOrganizationRelationship(OrganizationRelationship ship){
HashMap<String, Object> resp = new HashMap<>();
try {
// userInfoMapper.insert(userInfo);
// int insert = organizationRelationshipMapper.insert(ship);
int insert = organizationRelationshipMapper.insertOrganizationRelationship(ship);
if (insert>0){
resp.put(RETCODE,200);
}else{
resp.put(RETCODE,400);
resp.put(RETVALUE,"student/insert Invalid");
}
}catch (RuntimeException e){
resp.put(RETCODE,500);
resp.put(RETVALUE,"student/insert Invalid");
}
return resp;
}
/**
* 批量查询学生信息
*/
@Transactional
public HashMap<String,Object> queryStudent(UserInfo userInfo,OrganizationRelationship ship,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);
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<UserInfo> list = userInfoMapper.queryStudent(searchContent,schoolId,gradeId,classId,professionalId);
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<String, Object> login(String id, String password){ public HashMap<String, Object> login(String id, String password){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
@ -154,27 +272,27 @@ public class UserInfoService {
return resp; return resp;
} }
//删除用户组织架构 //删除用户组织架构
public HashMap<String, Object> deleteOrganizationRelationship(List<Integer> userIdList){ public HashMap<String, Object> deleteOrganizationRelationship(List<Integer> userIdList){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
int size = userIdList.size(); int size = userIdList.size();
for (int i=0;i<size;i++){ for (int i=0;i<size;i++){
Integer userId=userIdList.get(i); Integer userId=userIdList.get(i);
userInfoMapper.deleteOrganizationRelationship(userId); userInfoMapper.deleteOrganizationRelationship(userId);
} }
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);
resp.put("retvalue", "删除学生失败"); resp.put("retvalue", "删除学生失败");
return resp; return resp;
} }
return resp; return resp;
} }
//更新用户 //更新用户
@Transactional @Transactional
public HashMap<String, Object> updateUser(UserInfo user){ public HashMap<String, Object> updateUser(UserInfo user){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
@ -184,7 +302,7 @@ public class UserInfoService {
logger.error(e.getMessage()); logger.error(e.getMessage());
resp.put("retcode", 500); resp.put("retcode", 500);
resp.put("retvalue", "更新用户失败!"); resp.put("retvalue", "更新用户失败!");
throw new RuntimeException(); throw new RuntimeException();
} }
return resp; return resp;
} }
@ -269,7 +387,7 @@ public class UserInfoService {
//登陆获取学校 //登陆获取学校
public HashMap<String, Object> loginSchool(UserInfo userInfo){ public HashMap<String, Object> loginSchool(UserInfo userInfo){
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 {
UserInfo user=userInfoMapper.loginsAP(userInfo); UserInfo user=userInfoMapper.loginsAP(userInfo);
// obj.put("user",user); // obj.put("user",user);
@ -420,28 +538,28 @@ public class UserInfoService {
return resp; return resp;
} }
//修改用户头像 //修改用户头像
public HashMap<String, Object> uploadUserAvatars(MultipartFile file,Integer userId){ public HashMap<String, Object> uploadUserAvatars(MultipartFile file,Integer userId){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
OSSClient client=beanFactory.getBean(OSSClient.class); OSSClient client=beanFactory.getBean(OSSClient.class);
FilesResult result=OssConfigUtil.uploadUserAvatars(file, client, config); FilesResult result=OssConfigUtil.uploadUserAvatars(file, client, config);
//用户图片路径 //用户图片路径
String userAvatars=result.getFileUrl(); String userAvatars=result.getFileUrl();
userInfoMapper.updateUserAvatars(userAvatars,userId); userInfoMapper.updateUserAvatars(userAvatars,userId);
resp.put("retcode", 200); resp.put("retcode", 200);
resp.put("retvalue", userAvatars); resp.put("retvalue", userAvatars);
} catch (Exception e) { } catch (Exception e) {
logger.info(e.getMessage()); logger.info(e.getMessage());
resp.put("retcode", 500); resp.put("retcode", 500);
resp.put("retvalue", "修改头像失败!"); resp.put("retvalue", "修改头像失败!");
return resp; return resp;
} }
return resp; return resp;
} }
//更新登录次数和时间 //更新登录次数和时间
public HashMap<String, Object> updateLogInNumber(UserM user){ public HashMap<String, Object> updateLogInNumber(UserM user){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {

@ -0,0 +1,91 @@
package com.yipin.liuwanr.service;
import com.yipin.liuwanr.entity.OrganizationRelationship;
import com.yipin.liuwanr.entity.UserInfo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.HashMap;
@SpringBootTest
@RunWith(SpringRunner.class)
public class StudentServiceTest {
@Autowired
private UserInfoService userInfoService;
/**
* 新增学生
*/
@Test
public void addStudent(){
UserInfo userInfo = new UserInfo();
OrganizationRelationship ship = new OrganizationRelationship();
userInfo.setAccount("");
userInfo.setUniqueIdentificationAccount("huoran999");
userInfo.setSchoolId(1);
userInfo.setUserName("michonne");
userInfo.setRoleId(4);
userInfo.setPassword("123456");
ship.setProfessionalId(1);
ship.setGradeId(1);
ship.setClassId(1);
ship.setWorkNumber("888");
HashMap<String, Object> map = userInfoService.addUserInfo(userInfo);
userInfoService.addOrganizationRelationship(ship);
for (String s : map.keySet()) {
System.out.println("key:" + s + "," + "value:" + map.get(s));
}
HashMap<String, Object> map1 = userInfoService.addOrganizationRelationship(ship);
for (String ss : map1.keySet()) {
System.out.println("key:" + ss + "," + "value:" + map.get(ss));
}
}
/**
* 查询学生信息
*/
@Test
public void queryStudent(){
UserInfo userInfo = new UserInfo();
OrganizationRelationship organizationRelationship = new OrganizationRelationship();
userInfo.setSchoolId(1);
userInfo.setSearchContent("1");
Integer[] a = {1,2};
Integer[] b = {1,2};
Integer[] c = {1,2};
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);
for (String s : map.keySet()) {
System.out.println("key:" + s + "," + "value:" + map.get(s));
}
}
/**
* 测试删除学生信息
*/
@Test
public void deleteStudent(){
Integer[] userInfo = new Integer[]{13,14,15};
HashMap<String, Object> map = userInfoService.deleteStudent(userInfo);
for (String s : map.keySet()) {
System.out.println("key:" + s + "," + "value:" + map.get(s));
}
}
}
Loading…
Cancel
Save