From 61296d8ad47658c5bd2420725c9b9229d4631a3d Mon Sep 17 00:00:00 2001 From: "zhiyong.ning" <354350178@qq.com> Date: Fri, 31 Jul 2020 18:35:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../liuwanr/controller/StaffController.java | 80 +++++++---- .../liuwanr/controller/StudentController.java | 127 ++++++++++-------- .../liuwanr/controller/UserController.java | 4 +- .../liuwanr/entity/ContractInformation.java | 6 +- .../com/yipin/liuwanr/mapper/StaffMapper.java | 21 ++- .../yipin/liuwanr/mapper/StudentMapper.java | 18 ++- .../com/yipin/liuwanr/mapper/UserMapper.java | 17 ++- .../yipin/liuwanr/service/StaffService.java | 16 ++- .../yipin/liuwanr/service/StudentService.java | 9 +- .../yipin/liuwanr/service/UserService.java | 32 +++++ 10 files changed, 220 insertions(+), 110 deletions(-) diff --git a/src/main/java/com/yipin/liuwanr/controller/StaffController.java b/src/main/java/com/yipin/liuwanr/controller/StaffController.java index bc46660..93ca95c 100644 --- a/src/main/java/com/yipin/liuwanr/controller/StaffController.java +++ b/src/main/java/com/yipin/liuwanr/controller/StaffController.java @@ -98,18 +98,23 @@ public class StaffController { * 查询员工 */ @GetMapping("/queryStaff") - Response queryCustomer(@RequestParam String nameAndNumber,String staffProfessionalArchitectureIds,Integer pageNo,Integer pageSize,String staffGradeIds) { + Response queryCustomer(@RequestParam Integer schoolId,String nameAndNumber,String staffProfessionalArchitectureIds,Integer pageNo,Integer pageSize,String staffGradeIds) { Response resp = new Response(); Staff staff = new Staff(); - if (nameAndNumber!=null&&nameAndNumber!="") { - staff.setNameAndNumber(nameAndNumber); - } - if (staffProfessionalArchitectureIds!=null&&staffProfessionalArchitectureIds!="") { - staff.setStaffProfessionalArchitectureIds(staffProfessionalArchitectureIds); - } - if (staffGradeIds!=null&&staffGradeIds!="") { - staff.setStaffGradeIds(staffGradeIds); - } + if (schoolId==null){ + resp.setStatus(300); + resp.setErrmessage("学校id为空,查询失败!"); + }else { + if (nameAndNumber!=null&&nameAndNumber!="") { + staff.setNameAndNumber(nameAndNumber); + } + if (staffProfessionalArchitectureIds!=null&&staffProfessionalArchitectureIds!="") { + staff.setStaffProfessionalArchitectureIds(staffProfessionalArchitectureIds); + } + if (staffGradeIds!=null&&staffGradeIds!="") { + staff.setStaffGradeIds(staffGradeIds); + } + staff.setSchoolId(schoolId); HashMap ret = staffService.queryStaff(staff,pageNo,pageSize); int status = (int) ret.get("retcode"); if (200 == status) { @@ -119,6 +124,7 @@ public class StaffController { resp.setStatus(status); resp.setErrmessage(ret.get("retvalue").toString()); } + } return resp; } @@ -149,20 +155,30 @@ public class StaffController { * 删除员工 */ @PostMapping("/deleteStaff") - Response deleteStaff(@RequestBody List staffId) { + Response deleteStaff(@RequestBody List staffList) { Response resp = new Response(); - if (staffId==null) { - resp.setStatus(300); - resp.setErrmessage("Parameter Invalid"); - } else { - HashMap ret = staffService.deleteStaff(staffId); - 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()); + int size = staffList.size(); + for(int i=0;i ret = staffService.deleteStaff(staffId,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; @@ -172,13 +188,21 @@ public class StaffController { * 更新员工 */ @PostMapping("/updateStaff") - Response updateStaff(@RequestBody Staff staff) { + Response updateStaff(@RequestBody UserVO vo) { Response resp = new Response(); - if (staff==null) { + Staff staff = vo.getStaff(); + Integer staffId = staff.getStaffId(); + UserM user = vo.getUser(); + String phone = user.getPhone(); + if (staffId==null) { resp.setStatus(300); - resp.setErrmessage("Parameter Invalid"); - } else { - HashMap ret = staffService.updateStaff(staff); + resp.setErrmessage("员工id为空,修改失败!"); + }else if (phone==null||phone==""){ + resp.setStatus(300); + resp.setErrmessage("电话为空,修改失败!"); + } + else { + HashMap ret = staffService.updateStaff(vo); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); diff --git a/src/main/java/com/yipin/liuwanr/controller/StudentController.java b/src/main/java/com/yipin/liuwanr/controller/StudentController.java index 12cf8d8..e909233 100644 --- a/src/main/java/com/yipin/liuwanr/controller/StudentController.java +++ b/src/main/java/com/yipin/liuwanr/controller/StudentController.java @@ -1,27 +1,21 @@ package com.yipin.liuwanr.controller; -import java.util.HashMap; -import java.util.List; - -import com.yipin.liuwanr.vo.UserVO; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.StringUtils; -import org.springframework.web.bind.annotation.CrossOrigin; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; - import com.yipin.liuwanr.entity.Response; import com.yipin.liuwanr.entity.Student; import com.yipin.liuwanr.entity.UserM; import com.yipin.liuwanr.helper.RedisHelper; import com.yipin.liuwanr.service.StudentService; import com.yipin.liuwanr.service.UserService; +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; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.HashMap; +import java.util.List; @RestController @RequestMapping("/student") @@ -105,29 +99,35 @@ public class StudentController { * 查询学生 */ @GetMapping("/queryStudent") - Response queryStudent(@RequestParam String searchContent,Integer pageNo,Integer pageSize,String professionalIds,String gradeIds,String classIds) { + Response queryStudent(@RequestParam Integer schoolId,String searchContent,Integer pageNo,Integer pageSize,String professionalIds,String gradeIds,String classIds) { Response resp = new Response(); Student student = new Student(); - if (searchContent!=null&&searchContent!="") { - student.setSearchContent(searchContent); - } - if (professionalIds!=null&&professionalIds!="") { - student.setProfessionalIds(professionalIds); - } - if (gradeIds!=null&&gradeIds!="") { - student.setGradeIds(gradeIds); - } - if (classIds!=null&&classIds!="") { - student.setClassIds(classIds); - } - HashMap ret = studentService.queryStudent(student,pageNo,pageSize); - 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 (schoolId==null){ + resp.setStatus(300); + resp.setErrmessage("学校id为空,查询失败!"); + }else{ + if (searchContent!=null&&searchContent!="") { + student.setSearchContent(searchContent); + } + if (professionalIds!=null&&professionalIds!="") { + student.setProfessionalIds(professionalIds); + } + if (gradeIds!=null&&gradeIds!="") { + student.setGradeIds(gradeIds); + } + if (classIds!=null&&classIds!="") { + student.setClassIds(classIds); + } + student.setSchoolId(schoolId); + HashMap ret = studentService.queryStudent(student,pageNo,pageSize); + 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; } @@ -140,7 +140,7 @@ public class StudentController { Response resp = new Response(); if (studentId==null) { resp.setStatus(300); - resp.setErrmessage("Parameter Invalid"); + resp.setErrmessage("学生id为空,查询失败!"); }else { HashMap ret = studentService.queryStudentDetails(studentId); int status = (int) ret.get("retcode"); @@ -159,20 +159,30 @@ public class StudentController { * 删除学生 */ @PostMapping("/deleteStudent") - Response deleteStudent(@RequestBody List studentId) { + Response deleteStudent(@RequestBody List studentList) { Response resp = new Response(); - if (studentId==null) { - resp.setStatus(300); - resp.setErrmessage("Parameter Invalid"); - } else { - HashMap ret = studentService.deleteStudent(studentId); - 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()); + int size = studentList.size(); + for (int i=0;i 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; @@ -182,13 +192,20 @@ public class StudentController { * 更新学生 */ @PostMapping("/updateStudent") - Response updateStudent(@RequestBody Student student) { + Response updateStudent(@RequestBody UserVO vo) { Response resp = new Response(); - if (student==null) { + Student student = vo.getStudent(); + UserM user = vo.getUser(); + Integer studentId = student.getStudentId(); + String phone = user.getPhone(); + if (studentId==null) { resp.setStatus(300); - resp.setErrmessage("Parameter Invalid"); + resp.setErrmessage("学生id为空,修改失败!"); + }else if (phone==null||phone==""){ + resp.setStatus(300); + resp.setErrmessage("电话为空,修改失败!"); } else { - HashMap ret = studentService.updateStudent(student); + HashMap ret = studentService.updateStudent(vo); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); diff --git a/src/main/java/com/yipin/liuwanr/controller/UserController.java b/src/main/java/com/yipin/liuwanr/controller/UserController.java index 0b5f74a..55d803f 100644 --- a/src/main/java/com/yipin/liuwanr/controller/UserController.java +++ b/src/main/java/com/yipin/liuwanr/controller/UserController.java @@ -346,7 +346,7 @@ public class UserController { resp.setStatus(status); resp.setMessage(ret.get("retvalue")); if (roleId ==3){ - HashMap sta = staffService.updateStaff(staff); + HashMap sta = userService.updateStaff(staff); int staStatus = (int) sta.get("retcode"); if (200 == status) { resp.setStatus(staStatus); @@ -358,7 +358,7 @@ public class UserController { } } if (roleId ==4){ - HashMap stu = studentService.updateStudent(student); + HashMap stu = userService.updateStudent(student); int stuStatus = (int) stu.get("retcode"); if (200 == status) { resp.setStatus(stuStatus); diff --git a/src/main/java/com/yipin/liuwanr/entity/ContractInformation.java b/src/main/java/com/yipin/liuwanr/entity/ContractInformation.java index ef3d88b..1123088 100644 --- a/src/main/java/com/yipin/liuwanr/entity/ContractInformation.java +++ b/src/main/java/com/yipin/liuwanr/entity/ContractInformation.java @@ -8,7 +8,7 @@ public class ContractInformation { //合同编号 private String contractInformationNumber; //合同金额 - private int contractInformationSum; + private String contractInformationSum; //合同文件链接 private String contractInformationLink; //绑定订单id @@ -38,10 +38,10 @@ public class ContractInformation { public void setContractInformationNumber(String contractInformationNumber) { this.contractInformationNumber = contractInformationNumber; } - public int getContractInformationSum() { + public String getContractInformationSum() { return contractInformationSum; } - public void setContractInformationSum(int contractInformationSum) { + public void setContractInformationSum(String contractInformationSum) { this.contractInformationSum = contractInformationSum; } public String getContractInformationLink() { diff --git a/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java index f3ea98f..ece79a1 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java @@ -16,7 +16,7 @@ public interface StaffMapper { void addStaff(Staff staff); @Select({" "}) - void deleteStaff(@Param("staffId")List staffId); + void deleteStaff(Integer staffId); + + @Update({" "}) + void deleteUser(String phone); @Select({" " }) List queryStaffDetailsU(Integer staffId); + //修改员工 @Update("UPDATE staff SET staffName = #{staffName},staffWorkNumber = #{staffWorkNumber},phone = #{phone},email = #{email},staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}," + "staffProfessionalArchitectureId = #{staffProfessionalArchitectureId},staffGradeId = #{staffGradeId},roleId = #{roleId} where staffId = #{staffId}") void updateStaff(Staff staff); - + + //修改用户 + @Update("UPDATE user SET phone = #{phone},name = #{name},userAccount = #{userAccount},workNumber = #{workNumber},provinceId = #{provinceId},cityId = #{cityId},email = #{email},schoolId = #{schoolId},uniqueIdentificationAccount = #{uniqueIdentificationAccount},disciplineId = #{disciplineId},professionalClassId = #{professionalClassId},professionalId = #{professionalId} where phone = #{phone}") + void updateUser(UserM user); + /** * 得到所有未删除的部门信息 * @return diff --git a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java index d008af2..799adb4 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java @@ -19,7 +19,7 @@ public interface StudentMapper { //查询学生 @Select({ " " }) - void deleteStudent(@Param("studentId") List studentId); + void deleteStudent(Integer studentId); + + //删除用户 + @Update({ " " }) + void deleteUser(String phone); //查询学生详情 @Select({ "" }) void deleteStudent(UserM user); + //修改用户 @Update("UPDATE user SET name = #{name},sex = #{sex},documentType = #{documentType},countries = #{countries},educationDegree = #{educationDegree}," + "IDNumber = #{IDNumber},accountRole = #{accountRole},provinceId = #{provinceId},subjectsTaught = #{subjectsTaught},cityId = #{cityId}," + "phone = #{phone},teachingProfessional = #{teachingProfessional},WeChatID = #{WeChatID},dateBirth = #{dateBirth},email = #{email},schoolId = #{schoolId},disciplineId = #{disciplineId},professionalId = #{professionalId},professionalClassId = #{professionalClassId} where userId = #{userId}") void updateUser(UserM user); - @Update("UPDATE user SET name = #{name},sex = #{sex},documentType = #{documentType},countries = #{countries},educationDegree = #{educationDegree}," - + "IDNumber = #{IDNumber},accountRole = #{accountRole},provinceId = #{provinceId},subjectsTaught = #{subjectsTaught},cityId = #{cityId}," - + "phone = #{phone},teachingProfessional = #{teachingProfessional},WeChatID = #{WeChatID},dateBirth = #{dateBirth},email = #{email},schoolId = #{schoolId},disciplineId = #{disciplineId},professionalId = #{professionalId},professionalClassId = #{professionalClassId} where userId = #{userId}") + //修改员工 + @Update("UPDATE staff SET staffName = #{staffName},staffWorkNumber = #{staffWorkNumber},phone = #{phone},email = #{email},staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}," + + "staffProfessionalArchitectureId = #{staffProfessionalArchitectureId},staffGradeId = #{staffGradeId},roleId = #{roleId} where phone = #{phone}") void updateStaff(Staff staff); + //修改学生 + @Update("UPDATE student SET studentName = #{studentName},studentNumber = #{studentNumber},phone = #{phone},email = #{email},roleId = #{roleId}" + + ",schoolId = #{schoolId},professionalId = #{professionalId},gradeId = #{gradeId},classId = #{classId} where phone = #{phone}") + void updateStudent(Student student); + + //登陆 @Select("SELECT u.* from user u where isdel=0 and phone = #{phone} and password = #{password}") UserM logins(UserM user); + //查询用户手机 @Select("SELECT u.* from user u where isdel=0 and phone = #{phone}") List queryPhone(String phone); - + + //查询用户详情 @Select({" "}) diff --git a/src/main/java/com/yipin/liuwanr/service/StaffService.java b/src/main/java/com/yipin/liuwanr/service/StaffService.java index 7d9a3cd..757a516 100644 --- a/src/main/java/com/yipin/liuwanr/service/StaffService.java +++ b/src/main/java/com/yipin/liuwanr/service/StaffService.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import com.yipin.liuwanr.vo.UserVO; import org.jboss.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -142,15 +143,16 @@ public class StaffService { return resp; } - public HashMap deleteStaff(List staffId){ + public HashMap deleteStaff(Integer staffId,String phone){ HashMap resp = new HashMap(); try { staffMapper.deleteStaff(staffId); + staffMapper.deleteUser(phone); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "删除员工失败!"); return resp; } return resp; @@ -169,16 +171,20 @@ public class StaffService { } return resp; } - - public HashMap updateStaff(Staff staff){ + + //修改员工 + public HashMap updateStaff(UserVO vo){ HashMap resp = new HashMap(); + Staff staff = vo.getStaff(); + UserM user = vo.getUser(); try { staffMapper.updateStaff(staff); + staffMapper.updateUser(user); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); resp.put("retcode", 500); - resp.put("retvalue", "Inquiry Failed"); + resp.put("retvalue", "修改员工失败!"); return resp; } return resp; diff --git a/src/main/java/com/yipin/liuwanr/service/StudentService.java b/src/main/java/com/yipin/liuwanr/service/StudentService.java index 5906365..62458ce 100644 --- a/src/main/java/com/yipin/liuwanr/service/StudentService.java +++ b/src/main/java/com/yipin/liuwanr/service/StudentService.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import com.yipin.liuwanr.vo.UserVO; import org.jboss.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -80,10 +81,11 @@ public class StudentService { return resp; } - public HashMap deleteStudent(List studentId) { + public HashMap deleteStudent(Integer studentId,String phone) { HashMap resp = new HashMap(); try { studentMapper.deleteStudent(studentId); + studentMapper.deleteUser(phone); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); @@ -108,10 +110,13 @@ public class StudentService { return resp; } - public HashMap updateStudent(Student student) { + public HashMap updateStudent(UserVO vo) { HashMap resp = new HashMap(); + Student student = vo.getStudent(); + UserM user = vo.getUser(); try { studentMapper.updateStudent(student); + studentMapper.updateUser(user); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); diff --git a/src/main/java/com/yipin/liuwanr/service/UserService.java b/src/main/java/com/yipin/liuwanr/service/UserService.java index c478f79..87e4c99 100644 --- a/src/main/java/com/yipin/liuwanr/service/UserService.java +++ b/src/main/java/com/yipin/liuwanr/service/UserService.java @@ -231,6 +231,38 @@ public class UserService { return resp; } + //更新用户 + @Transactional + public HashMap updateStudent(Student student){ + HashMap resp = new HashMap(); + try { + userMapper.updateStudent(student); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "更新学生失败!"); + throw new RuntimeException(); + } + return resp; + } + + //更新用户 + @Transactional + public HashMap updateStaff(Staff staff){ + HashMap resp = new HashMap(); + try { + userMapper.updateStaff(staff); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "更新员工失败!"); + throw new RuntimeException(); + } + return resp; + } + //登陆 public HashMap logins(UserM userM){ HashMap resp = new HashMap();