master
zhiyong.ning 4 years ago
parent 12c4f755ea
commit 962b630d09
  1. 13
      src/main/java/com/yipin/liuwanr/controller/StaffController.java
  2. 12
      src/main/java/com/yipin/liuwanr/controller/StudentController.java
  3. 166
      src/main/java/com/yipin/liuwanr/controller/UserController.java
  4. 27
      src/main/java/com/yipin/liuwanr/mapper/StaffMapper.java
  5. 23
      src/main/java/com/yipin/liuwanr/mapper/StudentMapper.java
  6. 77
      src/main/java/com/yipin/liuwanr/mapper/UserMapper.java
  7. 2
      src/main/java/com/yipin/liuwanr/service/StaffService.java
  8. 4
      src/main/java/com/yipin/liuwanr/service/StudentService.java
  9. 54
      src/main/java/com/yipin/liuwanr/service/UserService.java

@ -66,19 +66,6 @@ public class StaffController {
Response resp = new Response(); Response resp = new Response();
Staff staff = vo.getStaff(); Staff staff = vo.getStaff();
UserM user = vo.getUser(); UserM user = vo.getUser();
// user.setPassword("huoran123");
// user.setWorkNumber(staff.getStaffWorkNumber());
// user.setUserAccount(staff.getStaffWorkNumber());
// user.setAccountRole(3);
// user.setName(staff.getStaffName());
// user.setPhone(staff.getPhone());
// user.setEmail(staff.getEmail());
// user.setSchoolId(staff.getSchoolId());
// Long startTs = System.currentTimeMillis(); // 当前时间戳
// String uniqueIdentificationAccount = startTs+"";
// user.setUniqueIdentificationAccount(uniqueIdentificationAccount);
// staff.setUniqueIdentificationAccount(uniqueIdentificationAccount);
// user.setUniqueIdentificationAccount(staff.getUniqueIdentificationAccount());
if (staff.getPhone()==null) { if (staff.getPhone()==null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("电话为空添加失败!"); resp.setErrmessage("电话为空添加失败!");

@ -73,18 +73,6 @@ public class StudentController {
Response resp = new Response(); Response resp = new Response();
Student student = vo.getStudent(); Student student = vo.getStudent();
UserM user = vo.getUser(); UserM user = vo.getUser();
// user.setPassword("huoran123");
// user.setPassword(student.getStudentPassword());
// user.setUserAccount(student.getStudentNumber());
// user.setAccountRole(4);
// user.setName(student.getStudentName());
// user.setPhone(student.getPhone());
// user.setEmail(student.getEmail());
// user.setWorkNumber(student.getStudentNumber());
// Long startTs = System.currentTimeMillis(); // 当前时间戳
// String uniqueIdentificationAccount = startTs+"";
// user.setUniqueIdentificationAccount(uniqueIdentificationAccount);
// student.setUniqueIdentificationAccount(uniqueIdentificationAccount);
if (student.getPhone()==null) { if (student.getPhone()==null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("Parameter Invalid"); resp.setErrmessage("Parameter Invalid");

@ -17,6 +17,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.HashMap; import java.util.HashMap;
import java.util.List;
@RestController @RestController
@RequestMapping("/user") @RequestMapping("/user")
@ -164,35 +165,35 @@ public class UserController {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("学校不能为空!"); resp.setErrmessage("学校不能为空!");
}else { }else {
if (accountRole == 4){
HashMap<String, Object> stu = studentService.addStudent(student);
int status = (int) stu.get("retcode");
if (status == 200){
resp.setStatus(status);
resp.setMessage(stu.get("retvalue"));
}else {
resp.setStatus(status);
resp.setErrmessage(stu.get("retvalue").toString());
throw new RuntimeException();
}
}
if(accountRole == 3){
HashMap<String, Object> sta = staffService.addStaff(staff);
int status = (int) sta.get("retcode");
if (status == 200){
resp.setStatus(status);
resp.setMessage(sta.get("retvalue"));
}else {
resp.setStatus(status);
resp.setErrmessage(sta.get("retvalue").toString());
throw new RuntimeException();
}
}
HashMap<String, Object> ret = userService.addUser(user); HashMap<String, Object> ret = userService.addUser(user);
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"));
if (accountRole == 4){
HashMap<String, Object> stu = studentService.addStudent(student);
int stuStatus = (int) stu.get("retcode");
if (stuStatus == 200){
resp.setStatus(stuStatus);
resp.setMessage(stu.get("retvalue"));
}else {
resp.setStatus(stuStatus);
resp.setErrmessage(stu.get("retvalue").toString());
throw new RuntimeException();
}
}
if(accountRole == 3){
HashMap<String, Object> sta = staffService.addStaff(staff);
int staStatus = (int) sta.get("retcode");
if (staStatus == 200){
resp.setStatus(staStatus);
resp.setMessage(sta.get("retvalue"));
}else {
resp.setStatus(staStatus);
resp.setErrmessage(sta.get("retvalue").toString());
throw new RuntimeException();
}
}
} else { } else {
resp.setStatus(status); resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString()); resp.setErrmessage(ret.get("retvalue").toString());
@ -260,22 +261,61 @@ public class UserController {
/** /**
* 删除用户(根据ID修改isdel状态,0可见 1不可见) * 删除用户(根据ID修改isdel状态,0可见 1不可见)
*/ */
@Transactional
@PostMapping("/deleteUser") @PostMapping("/deleteUser")
Response deleteUser(@RequestBody UserM user) { Response deleteUser(@RequestBody List<UserM> userList) {
Response resp = new Response(); Response resp = new Response();
if (user.getUser().isEmpty()) { int size = userList.size();
resp.setStatus(300); for(int i=0;i<size;i++){
resp.setErrmessage("参数有误,删除用户失败!"); UserM user = userList.get(i);
} else { Integer userId = user.getUserId();
HashMap<String, Object> ret = userService.deleteUser(user); Integer roleId = user.getAccountRole();
int status = (int) ret.get("retcode"); String phone = user.getPhone();
if (200 == status) { if (userId==null) {
resp.setStatus(status); resp.setStatus(300);
resp.setMessage(ret.get("retvalue")); resp.setErrmessage("用户id为空,删除用户失败!");
}else if (phone==null||phone==""){
resp.setStatus(300);
resp.setErrmessage("用户电话为空,删除用户失败!");
}else if (roleId==null){
resp.setStatus(300);
resp.setErrmessage("用户角色为空,删除用户失败!");
} else { } else {
resp.setStatus(status); HashMap<String, Object> ret = userService.deleteUser(userId);
resp.setErrmessage(ret.get("retvalue").toString()); int status = (int) ret.get("retcode");
} if (200 == status) {
resp.setStatus(status);
resp.setMessage(ret.get("retvalue"));
if (roleId==3){
HashMap<String, Object> sta = userService.deleteStaff(user);
int staStatus = (int) ret.get("retcode");
if (200 == staStatus) {
resp.setStatus(staStatus);
resp.setMessage(sta.get("retvalue"));
}else{
resp.setStatus(staStatus);
resp.setErrmessage(sta.get("retvalue").toString());
throw new RuntimeException();
}
}
if (roleId==4){
HashMap<String, Object> stu = userService.deleteStudent(user);
int stuStatus = (int) stu.get("retcode");
if (200 == stuStatus) {
resp.setStatus(stuStatus);
resp.setMessage(stu.get("retvalue"));
}else{
resp.setStatus(stuStatus);
resp.setErrmessage(stu.get("retvalue").toString());
throw new RuntimeException();
}
}
} else {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
throw new RuntimeException();
}
}
} }
return resp; return resp;
} }
@ -283,21 +323,56 @@ public class UserController {
/** /**
* 更新用户 * 更新用户
*/ */
@Transactional
@PostMapping("/updateUser") @PostMapping("/updateUser")
Response updateUser(@RequestBody UserM user) { Response updateUser(@RequestBody UserVO vo) {
Response resp = new Response(); Response resp = new Response();
if (user.getUserId()==null) { UserM user = vo.getUser();
Staff staff = vo.getStaff();
Student student = vo.getStudent();
Integer userId = user.getUserId();
Integer roleId = user.getAccountRole();
if (userId==null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户ID为空,修改用户失败!"); resp.setErrmessage("用户ID为空,修改用户失败!");
} else { }else if (roleId==null){
resp.setStatus(300);
resp.setErrmessage("角色ID为空,修改用户失败!");
}
else {
HashMap<String, Object> ret = userService.updateUser(user); HashMap<String, Object> ret = userService.updateUser(user);
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"));
if (roleId ==3){
HashMap<String, Object> sta = staffService.updateStaff(staff);
int staStatus = (int) sta.get("retcode");
if (200 == status) {
resp.setStatus(staStatus);
resp.setMessage(sta.get("retvalue"));
}else{
resp.setStatus(staStatus);
resp.setErrmessage(sta.get("retvalue").toString());
throw new RuntimeException("修改员工失败!");
}
}
if (roleId ==4){
HashMap<String, Object> stu = studentService.updateStudent(student);
int stuStatus = (int) stu.get("retcode");
if (200 == status) {
resp.setStatus(stuStatus);
resp.setMessage(stu.get("retvalue"));
}else{
resp.setStatus(stuStatus);
resp.setErrmessage(stu.get("retvalue").toString());
throw new RuntimeException("修改学生失败!");
}
}
} else { } else {
resp.setStatus(status); resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString()); resp.setErrmessage(ret.get("retvalue").toString());
throw new RuntimeException("修改用户失败!");
} }
} }
return resp; return resp;
@ -334,15 +409,16 @@ public class UserController {
* 查询用户详情(ID) * 查询用户详情(ID)
*/ */
@GetMapping("/queryUserDetails") @GetMapping("/queryUserDetails")
Response queryUserDetails(@RequestParam Integer userId) { Response queryUserDetails(@RequestParam Integer userId,Integer roleId) {
Response resp = new Response(); Response resp = new Response();
if (userId==null) {//前台传来的值是否为空 if (roleId == null){
resp.setStatus(300);
resp.setErrmessage("用户角色id为空!查询失败!");
}else if (userId==null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id为空!查询失败!"); resp.setErrmessage("用户id为空!查询失败!");
}else { }else {
HashMap<String, Object> ret = userService.queryUserDetails(userId); HashMap<String, Object> ret = userService.queryUserDetails(userId,roleId);
resp.setStatus(200);
resp.setErrmessage("查询成功!");
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
resp.setStatus(status); resp.setStatus(status);

@ -3,9 +3,8 @@ package com.yipin.liuwanr.mapper;
import java.util.List; import java.util.List;
import com.yipin.liuwanr.entity.UserM; import com.yipin.liuwanr.entity.UserM;
import org.apache.ibatis.annotations.Insert; import com.yipin.liuwanr.vo.UserVO;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Update;
import com.yipin.liuwanr.entity.Staff; import com.yipin.liuwanr.entity.Staff;
import com.yipin.liuwanr.entity.StaffGrade; import com.yipin.liuwanr.entity.StaffGrade;
@ -34,10 +33,26 @@ public interface StaffMapper {
void deleteStaff(@Param("staffId")List<Integer> staffId); void deleteStaff(@Param("staffId")List<Integer> staffId);
@Select({"<script>", @Select({"<script>",
"SELECT uniqueIdentificationAccount,staffName,staffWorkNumber,phone,email,staffProfessionalArchitectureId,staffProfessionalArchitectureId,staffGradeId,roleId from staff where isdel = 0 and staffId = #{staffId}", "SELECT staffId,staffName,staffWorkNumber,phone,email,logNumber,lastTimeOfLanding,staffGradeId,staffProfessionalArchitectureId,roleId,uniqueIdentificationAccount,schoolId from staff where isdel = 0 and staffId = #{staffId}",
"</script> "}) "</script> "})
List<Staff> queryStaffDetails(Integer staffId); List<Staff> queryStaffDetails(Integer staffId);
//查询学生详情
@Select({ "<script>",
"SELECT * from staff where isdel = 0 and staffId = #{staffId}",
"</script> " })
@Results({
@Result(property = "staff", column = "staffId",one = @One(select = "com.yipin.liuwanr.mapper.StaffMapper.queryStaffDetails")),
@Result(property = "user", column = "staffId",one = @One(select = "com.yipin.liuwanr.mapper.StaffMapper.queryStaffDetailsU"))
})
List<UserVO> queryStaffDetailsUser(Integer staffId);
//查询学生详情
@Select({ "<script>",
"SELECT s.phone,s.staffId,u.* from staff s,user u where u.isdel = 0 and s.staffId = #{staffId} and s.phone = u.phone",
"</script> " })
List<UserM> queryStaffDetailsU(Integer staffId);
@Update("UPDATE staff SET staffName = #{staffName},staffWorkNumber = #{staffWorkNumber},phone = #{phone},email = #{email},staffProfessionalArchitectureId = #{staffProfessionalArchitectureId}," @Update("UPDATE staff SET staffName = #{staffName},staffWorkNumber = #{staffWorkNumber},phone = #{phone},email = #{email},staffProfessionalArchitectureId = #{staffProfessionalArchitectureId},"
+ "staffProfessionalArchitectureId = #{staffProfessionalArchitectureId},staffGradeId = #{staffGradeId},roleId = #{roleId} where staffId = #{staffId}") + "staffProfessionalArchitectureId = #{staffProfessionalArchitectureId},staffGradeId = #{staffGradeId},roleId = #{roleId} where staffId = #{staffId}")
void updateStaff(Staff staff); void updateStaff(Staff staff);

@ -3,9 +3,8 @@ package com.yipin.liuwanr.mapper;
import java.util.List; import java.util.List;
import com.yipin.liuwanr.entity.UserM; import com.yipin.liuwanr.entity.UserM;
import org.apache.ibatis.annotations.Insert; import com.yipin.liuwanr.vo.UserVO;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Update;
import com.yipin.liuwanr.entity.Student; import com.yipin.liuwanr.entity.Student;
@ -42,8 +41,24 @@ public interface StudentMapper {
"</script> " }) "</script> " })
List<Student> queryStudentDetails(Integer studentId); List<Student> queryStudentDetails(Integer studentId);
//查询学生详情
@Select({ "<script>",
"SELECT * from student where isdel = 0 and studentId = #{studentId}",
"</script> " })
@Results({
@Result(property = "student", column = "studentId",one = @One(select = "com.yipin.liuwanr.mapper.StudentMapper.queryStudentDetails")),
@Result(property = "user", column = "studentId",one = @One(select = "com.yipin.liuwanr.mapper.StudentMapper.queryStudentDetailsU"))
})
List<UserVO> queryStudentDetailsUser(Integer studentId);
//查询学生详情
@Select({ "<script>",
"SELECT s.uniqueIdentificationAccount,s.studentName,s.studentNumber,s.phone,s.email,s.roleId,s.schoolId,s.professionalId,s.gradeId,s.classId,u.* from student s,user u where s.isdel = 0 and s.studentId = #{studentId} and s.phone = u.phone",
"</script> " })
List<UserM> queryStudentDetailsU(Integer studentId);
//修改学生 //修改学生
@Update("UPDATE student SET studentName = #{studentName},studentWorkNumber = #{studentWorkNumber},phone = #{phone},email = #{email},roleId = #{roleId}" @Update("UPDATE student SET studentName = #{studentName},studentNumber = #{studentNumber},phone = #{phone},email = #{email},roleId = #{roleId}"
+ ",schoolId = #{schoolId},professionalId = #{professionalId},gradeId = #{gradeId},classId = #{classId} where studentId = #{studentId}") + ",schoolId = #{schoolId},professionalId = #{professionalId},gradeId = #{gradeId},classId = #{classId} where studentId = #{studentId}")
void updateStudent(Student student); void updateStudent(Student student);

@ -1,6 +1,7 @@
package com.yipin.liuwanr.mapper; package com.yipin.liuwanr.mapper;
import com.yipin.liuwanr.entity.*; import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.vo.UserVO;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType; import org.apache.ibatis.mapping.FetchType;
@ -129,31 +130,85 @@ public interface UserMapper {
"</script> "}) "</script> "})
List<UserM> queryUser(UserM user); List<UserM> queryUser(UserM user);
@Update("UPDATE user SET isdel = 1 where userId = #{userId}")
void deleteUser(Integer userId);
//批量删除员工
@Update({ "<script>", @Update({ "<script>",
"UPDATE user SET isdel = 1 where userId in " "UPDATE staff SET isdel = 1 where phone = #{phone} ",
+"<foreach collection='user' item='u' open='(' separator=',' close=')'>" "</script>" })
+"#{u.userId} " void deleteStaff(UserM user);
+ "</foreach> ",
"</script>" }) //批量删除学生
void deleteUser(UserM user); @Update({ "<script>",
"UPDATE student SET isdel = 1 where phone = #{phone} ",
"</script>" })
void deleteStudent(UserM user);
@Update("UPDATE user SET name = #{name},sex = #{sex},documentType = #{documentType},countries = #{countries},educationDegree = #{educationDegree}," @Update("UPDATE user SET name = #{name},sex = #{sex},documentType = #{documentType},countries = #{countries},educationDegree = #{educationDegree},"
+ "IDNumber = #{IDNumber},accountRole = #{accountRole},provinceId = #{provinceId},subjectsTaught = #{subjectsTaught},cityId = #{cityId}," + "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}") + "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); 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}")
void updateStaff(Staff staff);
@Select("SELECT u.* from user u where isdel=0 and phone = #{phone} and password = #{password}") @Select("SELECT u.* from user u where isdel=0 and phone = #{phone} and password = #{password}")
UserM logins(UserM user); UserM logins(UserM user);
@Select("SELECT u.* from user u where isdel=0 and phone = #{phone}") @Select("SELECT u.* from user u where isdel=0 and phone = #{phone}")
UserM queryPhone(String phone); List<UserM> queryPhone(String phone);
@Select({"<script>", @Select({"<script>",
"SELECT u.*,d.disciplineName,p.professionalName,pc.professionalClassName,schoolName from user u,discipline d,professional p,professional_class pc,school s where u.isdel = 0 and u.disciplineId = d.disciplineId and u.professionalId = p.professionalId and u.professionalClassId = pc.professionalClassId and u.schoolId = s.schoolId and u.userId = #{userId}", "SELECT u.*,schoolName from user u,school s where u.isdel = 0 and u.schoolId = s.schoolId and u.userId = #{userId}",
"</script> "}) "</script> "})
List<UserM> queryUserDetails(Integer userId); List<UserM> queryUserDetails(Integer userId);
@Select({"<script>",
"SELECT u.*,schoolName from user u,school s where u.isdel = 0 and u.schoolId = s.schoolId and u.userId = #{userId}",
"</script> "})
@Results({
@Result(property = "user", column = "userId",one = @One(select = "com.yipin.liuwanr.mapper.UserMapper.queryUserDetailss")),
})
List<UserVO> queryUserDetailsAdmin(Integer userId);
@Select({"<script>",
"SELECT u.*,schoolName from user u,school s where u.isdel = 0 and u.schoolId = s.schoolId and u.userId = #{userId}",
"</script> "})
List<UserM> queryUserDetailss(Integer userId);
@Select({"<script>",
"SELECT u.*,schoolName from user u,school s where u.isdel = 0 and u.schoolId = s.schoolId and u.userId = #{userId}",
"</script> "})
@Results({
@Result(property = "user", column = "userId",one = @One(select = "com.yipin.liuwanr.mapper.UserMapper.queryUserDetails")),
@Result(property = "staff", column = "userId",one = @One(select = "com.yipin.liuwanr.mapper.UserMapper.queryUserDetailsSta"))
})
List<UserVO> queryUserDetailsStaff(Integer userId);
//查询用户详情学生角色
//查询学生用户详情
@Select({"<script>",
"SELECT u.*,schoolName from user u,school s where u.isdel = 0 and u.schoolId = s.schoolId and u.userId = #{userId}",
"</script> "})
@Results({
@Result(property = "user", column = "userId",one = @One(select = "com.yipin.liuwanr.mapper.UserMapper.queryUserDetails")),
@Result(property = "student", column = "userId",one = @One(select = "com.yipin.liuwanr.mapper.UserMapper.queryUserDetailsStu"))
})
List<UserVO> queryUserDetailsStudent(Integer userId);
@Select({"<script>",
" SELECT u.userId,u.phone,s.* FROM user u,student s where u.phone = s.phone and u.userId =#{userId}",
"</script> "})
List<Student> queryUserDetailsStu(Integer userId);
//查询老师用户详情
@Select({"<script>",
" SELECT u.userId,u.phone,s.* FROM user u,staff s where u.phone = s.phone and u.userId =#{userId}",
"</script> "})
List<Staff> queryUserDetailsSta(Integer userId);
@Select({"<script>", @Select({"<script>",
"SELECT customerId,customerName,schoolId FROM customer where isdel = 0 and provinceId = #{provinceId} and cityId = #{cityId}", "SELECT customerId,customerName,schoolId FROM customer where isdel = 0 and provinceId = #{provinceId} and cityId = #{cityId}",
"</script> "}) "</script> "})

@ -159,7 +159,7 @@ public class StaffService {
public HashMap<String, Object> queryStaffDetails(Integer staffId){ public HashMap<String, Object> queryStaffDetails(Integer staffId){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
resp.put("retvalue", staffMapper.queryStaffDetails(staffId)); resp.put("retvalue", staffMapper.queryStaffDetailsUser(staffId));
resp.put("retcode", 200); resp.put("retcode", 200);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());

@ -97,7 +97,7 @@ public class StudentService {
public HashMap<String, Object> queryStudentDetails(Integer studentId) { public HashMap<String, Object> queryStudentDetails(Integer studentId) {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
resp.put("retvalue", studentMapper.queryStudentDetails(studentId)); resp.put("retvalue", studentMapper.queryStudentDetailsUser(studentId));
resp.put("retcode", 200); resp.put("retcode", 200);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
@ -116,7 +116,7 @@ public class StudentService {
} 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", "Inquiry Failed"); resp.put("retvalue", "修改学生失败!");
return resp; return resp;
} }
return resp; return resp;

@ -14,6 +14,7 @@ import org.jboss.logging.Logger;
import org.springframework.beans.factory.BeanFactory; import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import com.aliyun.oss.OSSClient; import com.aliyun.oss.OSSClient;
@ -127,8 +128,6 @@ public class UserService {
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
user.setPassword("huoran123");//设置默认密码 user.setPassword("huoran123");//设置默认密码
String uniqueIdentificationAccount = System.currentTimeMillis()+"";
user.setUniqueIdentificationAccount(uniqueIdentificationAccount);
userMapper.addUser(user); userMapper.addUser(user);
resp.put("retcode", 200); resp.put("retcode", 200);
} catch (RuntimeException e) { } catch (RuntimeException e) {
@ -172,10 +171,10 @@ public class UserService {
} }
//删除用户 //删除用户
public HashMap<String, Object> deleteUser(UserM user){ public HashMap<String, Object> deleteUser(Integer userId){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
userMapper.deleteUser(user); userMapper.deleteUser(userId);
resp.put("retcode", 200); resp.put("retcode", 200);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
@ -186,7 +185,38 @@ public class UserService {
return resp; return resp;
} }
//批量删除员工
public HashMap<String, Object> deleteStaff(UserM user){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
userMapper.deleteStaff(user);
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> deleteStudent(UserM user){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
userMapper.deleteStudent(user);
resp.put("retcode", 200);
} catch (RuntimeException e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "删除学生失败");
return resp;
}
return resp;
}
//更新用户 //更新用户
@Transactional
public HashMap<String, Object> updateUser(UserM user){ public HashMap<String, Object> updateUser(UserM user){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
@ -196,7 +226,7 @@ public class UserService {
logger.error(e.getMessage()); logger.error(e.getMessage());
resp.put("retcode", 500); resp.put("retcode", 500);
resp.put("retvalue", "更新用户失败!"); resp.put("retvalue", "更新用户失败!");
return resp; throw new RuntimeException();
} }
return resp; return resp;
} }
@ -250,11 +280,19 @@ public class UserService {
} }
//查询用户详情 //查询用户详情
public HashMap<String, Object> queryUserDetails(Integer userId){ public HashMap<String, Object> queryUserDetails(Integer userId,Integer roleId){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
resp.put("retvalue", userMapper.queryUserDetails(userId)); if (roleId == 3){
resp.put("retcode", 200); resp.put("retvalue", userMapper.queryUserDetailsStaff(userId));
resp.put("retcode", 200);
}else if (roleId == 4){
resp.put("retvalue", userMapper.queryUserDetailsStudent(userId));
resp.put("retcode", 200);
}else{
resp.put("retvalue", userMapper.queryUserDetailsAdmin(userId));
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);

Loading…
Cancel
Save