修改登录

master
mzh820631607 4 years ago
parent 90b26c90ab
commit 8e7a90cd2c
  1. 2
      pom.xml
  2. 50
      src/main/java/com/yipin/liuwanr/controller/UserController.java
  3. 52
      src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
  4. 16
      src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
  5. 104
      src/main/java/com/yipin/liuwanr/mapper/UserMapper.java
  6. 49
      src/main/java/com/yipin/liuwanr/service/UserInfoService.java
  7. 146
      src/main/java/com/yipin/liuwanr/service/UserService.java
  8. 19
      src/main/java/com/yipin/liuwanr/vo/UserInfoReceiveVo.java
  9. 3
      src/main/resources/application.properties

@ -6,7 +6,7 @@
<groupId>com.yipin</groupId>
<artifactId>liuwanr</artifactId>
<version>1.0.0</version>
<packaging>war</packaging>
<packaging>jar</packaging>
<name>Spring Boot Project</name>

@ -38,7 +38,7 @@ public class UserController {
@GetMapping("/login")
Response loginUser(@RequestParam("id") String id, @RequestParam("password") String password,
HttpServletResponse response) {
HttpServletResponse response) {
Response resp = new Response();
HashMap<String, Object> ret = userService.login(id, password);
int status = (int) ret.get("retcode");
@ -73,7 +73,7 @@ public class UserController {
@GetMapping("/reauth")
Response getNewToken(@RequestHeader("X-UUID") String uuid, @RequestHeader("X-TOKEN") String stoken,
@RequestHeader("X-SIGN") String sign, HttpServletResponse response) {
@RequestHeader("X-SIGN") String sign, HttpServletResponse response) {
Response resp = new Response();
String oldtoken = redisHelper.getTokenById(uuid);
String oldrefreshtoken = redisHelper.getRefreshTokenById(uuid);
@ -255,8 +255,8 @@ public class UserController {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
return resp;
}
return resp;
}
/**
* 删除用户(根据ID修改isdel状态,0可见 1不可见)
@ -315,7 +315,7 @@ public class UserController {
resp.setErrmessage(ret.get("retvalue").toString());
throw new RuntimeException();
}
}
}
}
return resp;
}
@ -401,7 +401,7 @@ public class UserController {
resp.setStatus(status);
resp.setErrmessage(ret.get("retvalue").toString());
}
return resp;
return resp;
}
@ -428,28 +428,28 @@ public class UserController {
resp.setErrmessage(ret.get("retvalue").toString());
}
}
return resp;
}
return resp;
}
@PostMapping("/uploadUserAvatars")
Response uploadUserAvatars(MultipartFile file,Integer userId) {
Response resp = new Response();
if (userId==null) {//前台传来的值是否为空
resp.setStatus(300);
resp.setErrmessage("Parameter Invalid");
}else {
HashMap<String, Object> ret = userService.uploadUserAvatars(file,userId);
Response uploadUserAvatars(MultipartFile file,Integer userId) {
Response resp = new Response();
if (userId==null) {//前台传来的值是否为空
resp.setStatus(300);
resp.setErrmessage("Parameter Invalid");
}else {
HashMap<String, Object> ret = userService.uploadUserAvatars(file,userId);
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;
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;
}
/**

@ -299,6 +299,35 @@ public class UserInfoController {
}
return resp;
}
/**
* 登陆查询学校/电子科大
*/
@GetMapping("/loginSchoolClient")
Response loginSchoolClient(@RequestParam("account") String account, @RequestParam("password") String password , HttpServletRequest req, HttpServletResponse res) {
Response resp = new Response();
UserInfo userInfo = new UserInfo();
userInfo.setSchoolId(2105);//暂定学校id
if (account == null || account=="") {
resp.setStatus(300);
resp.setErrmessage("用户账号为空,登录失败!");
}else if(password ==null || password=="") {
resp.setStatus(300);
resp.setErrmessage("用户密码为空,登录失败!");
}else{
userInfo.setAccount(account);
userInfo.setPassword(password);
HashMap<String, Object> ret = userInfoService.loginSchoolClient(userInfo);
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;
}
/**
* 服务端登陆
@ -693,4 +722,27 @@ public class UserInfoController {
}
return resp;
}
/**
* 查询电话
*/
@GetMapping("/queryPhone")
com.yipin.liuwanr.entity.Response queryPhone(@RequestParam String phone) {
com.yipin.liuwanr.entity.Response resp = new com.yipin.liuwanr.entity.Response();
if (phone==null||phone=="") {//前台传来的值是否为空
resp.setStatus(300);
resp.setErrmessage("手机号为空!查询失败!");
}else {
HashMap<String, Object> ret = userInfoService.queryPhone(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;
}
}

@ -2,6 +2,7 @@ package com.yipin.liuwanr.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.vo.UserInfoReceiveVo;
import com.yipin.liuwanr.vo.UserInfoVO;
import com.yipin.liuwanr.vo.UserVO;
import org.apache.ibatis.annotations.*;
@ -143,14 +144,22 @@ public interface UserInfoMapper {
@Select("SELECT userId,roleId from student where userId = #{userId} and schoolId = #{schoolId}")
List<Student> loginStudentRole(Integer userId, Integer schoolId);
//登陆查询学校
//登陆查询员工学校信息
@Select("SELECT sta.schoolId,sch.schoolName,sta.userId from staff sta,school sch where sta.userId = #{userId} and sta.schoolId = sch.schoolId GROUP BY sta.schoolId")
List<UserInfo> loginGetStaffSchool(Integer userId);
//登陆查询学校
//登陆查询学生学信息
@Select("SELECT stu.schoolId,sch.schoolName,stu.userId from student stu,school sch where stu.userId = #{userId} and stu.schoolId = sch.schoolId GROUP BY stu.schoolId")
List<UserInfo> loginGetStudentSchool(Integer userId);
//登陆查询员工学校信息/dianzikeda
@Select("SELECT sta.schoolId,sch.schoolName,sta.userId from staff sta,school sch where sta.userId = #{userId} and sta.schoolId = sch.schoolId and sch.schoolId=#{schoolId} GROUP BY sta.schoolId")
List<UserInfo> loginsGetStaffSchoolInfo(Integer userId,Integer schoolId);
//登陆查询学生学校信息/dianzikeda
@Select("SELECT stu.schoolId,sch.schoolName,stu.userId,stu.studentId from student stu,school sch where stu.userId = #{userId} and stu.schoolId = sch.schoolId and sch.schoolId=#{schoolId} GROUP BY stu.schoolId")
List<UserInfoReceiveVo> loginsGetStudentSchoolInfo(Integer userId, Integer schoolId);
//查询用户员工组织关系
@Select("SELECT * from staff where userId = #{userId} and roleId = #{roleId} and schoolId = #{schoolId}")
List<Staff> queryStaffAll(Integer userId, String roleId, Integer schoolId);
@ -328,4 +337,7 @@ public interface UserInfoMapper {
"UPDATE hr_organization_relationship set isdel=1 where userId = #{userId}",
"</script>"})
void deleteOrganizationRelationship(Integer userId);
@Select("SELECT disableAccount FROM hr_user_info WHERE schoolId = #{schoolId} AND account = #{account}")
Integer queryDisableAccount(UserInfo userInfo);
}

@ -16,19 +16,19 @@ public interface UserMapper {
User getOne(String uuid);
@Results({
@Result(property="pets", column="petlist", many=@Many(select="com.yipin.liuwanr.mapper.PetMapper.getAll",fetchType=FetchType.EAGER))
@Result(property="pets", column="petlist", many=@Many(select="com.yipin.liuwanr.mapper.PetMapper.getAll",fetchType=FetchType.EAGER))
})
@Select("SELECT uuid,mobile,email,wxid,qqid,aliid,sinaid,netid,nickname,sex,birthday,sign,avatar,country,province,city, uuid as petlist, password,createtime,updatetime FROM lw_user WHERE uuid = #{uuid}")
User getSelfById(String uuid);
@Results({
@Result(property="pets", column="petlist", many=@Many(select="com.yipin.liuwanr.mapper.PetMapper.getAll",fetchType=FetchType.EAGER))
@Result(property="pets", column="petlist", many=@Many(select="com.yipin.liuwanr.mapper.PetMapper.getAll",fetchType=FetchType.EAGER))
})
@Select("SELECT uuid,mobile,email,wxid,qqid,aliid,sinaid,netid,nickname,sex,birthday,sign,avatar,country,province,city, uuid as petlist, password,createtime,updatetime FROM lw_user WHERE mobile = #{key} or email = #{key}")
User getSelfByAccount(String key);
@Results({
@Result(property="pets", column="petlist", many=@Many(select="com.yipin.liuwanr.mapper.PetMapper.getAll",fetchType=FetchType.EAGER))
@Result(property="pets", column="petlist", many=@Many(select="com.yipin.liuwanr.mapper.PetMapper.getAll",fetchType=FetchType.EAGER))
})
@Select("SELECT uuid,mobile,email,wxid,qqid,aliid,sinaid,netid,nickname,sex,birthday,sign,avatar,country,province,city, uuid as petlist, password,createtime,updatetime FROM lw_user WHERE wxid = #{value} or qqid = #{value} or aliid = #{value} or sinaid = #{value} or netid = #{value}")
User getSelfBy3rdId(String value);
@ -43,18 +43,18 @@ public interface UserMapper {
void insert(User user);
@Update({ "<script>",
"UPDATE lw_user SET",
"<when test='mobile!=null'>", "mobile=#{mobile},", "</when>",
"<when test='email!=null'>", "email=#{email},", "</when>",
"<when test='nickname!=null'>", "nickname=#{nickname},", "</when>",
"<when test='sex!=-1'>", "sex=#{sex},", "</when>",
"<when test='sign!=null'>", "sign=#{sign},", "</when>",
"<when test='birthday!=null'>", "birthday=#{birthday},", "</when>",
"<when test='avatar!=null'>", "avatar=#{avatar},", "</when>",
"<when test='country!=null'>", "country=#{country},", "</when>",
"<when test='province!=null'>", "province=#{province},", "</when>",
"<when test='city!=null'>", "city=#{city},", "</when>",
"updatetime=now() WHERE uuid =#{uuid}",
"UPDATE lw_user SET",
"<when test='mobile!=null'>", "mobile=#{mobile},", "</when>",
"<when test='email!=null'>", "email=#{email},", "</when>",
"<when test='nickname!=null'>", "nickname=#{nickname},", "</when>",
"<when test='sex!=-1'>", "sex=#{sex},", "</when>",
"<when test='sign!=null'>", "sign=#{sign},", "</when>",
"<when test='birthday!=null'>", "birthday=#{birthday},", "</when>",
"<when test='avatar!=null'>", "avatar=#{avatar},", "</when>",
"<when test='country!=null'>", "country=#{country},", "</when>",
"<when test='province!=null'>", "province=#{province},", "</when>",
"<when test='city!=null'>", "city=#{city},", "</when>",
"updatetime=now() WHERE uuid =#{uuid}",
"</script>"})
void update(User user);
@ -80,14 +80,14 @@ public interface UserMapper {
Config getconf(String uuid);
@Update({ "<script>",
"UPDATE lw_user_config SET",
"<when test='conf1!=-1'>", "conf1=#{conf1},", "</when>",
"<when test='conf2!=-1'>", "conf2=#{conf2},", "</when>",
"<when test='conf3!=-1'>", "conf3=#{conf3},", "</when>",
"<when test='conf4!=-1'>", "conf4=#{conf4},", "</when>",
"<when test='conf5!=-1'>", "conf5=#{conf5},", "</when>",
"updatetime=now() WHERE uuid =#{uuid}",
"</script>"})
"UPDATE lw_user_config SET",
"<when test='conf1!=-1'>", "conf1=#{conf1},", "</when>",
"<when test='conf2!=-1'>", "conf2=#{conf2},", "</when>",
"<when test='conf3!=-1'>", "conf3=#{conf3},", "</when>",
"<when test='conf4!=-1'>", "conf4=#{conf4},", "</when>",
"<when test='conf5!=-1'>", "conf5=#{conf5},", "</when>",
"updatetime=now() WHERE uuid =#{uuid}",
"</script>"})
void putconf(Config config);
@Select("SELECT * from demo")
@ -112,22 +112,22 @@ public interface UserMapper {
// + " VALUES(#{name},#{password},#{sex},#{documentType},#{countries},#{educationDegree},#{IDNumber},#{accountRole},#{provinceId},#{subjectsTaught},#{cityId},#{phone},#{teachingProfessional},#{WeChatID},#{dateBirth},#{email},now(),0,#{schoolId},#{uniqueIdentificationAccount},#{disciplineId},#{professionalClassId},#{professionalId})")
// void addStaff(Staff staff);
// @Select("SELECT * from user where isdel = 1 and countries = #{countries} and provinces = #{provinces} and city = #{city}")
// @Select("SELECT * from user where isdel = 1 and countries = #{countries} and provinces = #{provinces} and city = #{city}")
@Select({"<script>",
"SELECT u.*,s.schoolName,p.provinceName,c.cityName from user u,school s,province p,city c where u.isdel = 0 and p.provinceId = u.provinceId and p.provinceId = c.provinceId and u.cityId = c.cityId and u.schoolId = s.schoolId",
" <if test='countries!=null and countries !=\"\" '>and u.countries = #{countries} </if>",
" <if test='provinceId!=null and provinceId !=\"\" '>and u.provinceId = #{provinceId} </if>",
" <if test='schoolId!=null'>and u.schoolId = #{schoolId} </if>",
" <if test='cityId!=null and cityId !=\"\" '>and u.cityId = #{cityId} </if>",
" <if test='accountRole!=null and accountRole !=\"\" '>and u.accountRole = #{accountRole} </if>",
" <if test='searchContent!=null and searchContent !=\"\" '> AND CONCAT(u.name, s.schoolName) LIKE CONCAT('%',#{searchContent},'%')</if>",
" <if test='month==3'>and u.creationTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)</if>",
" <if test='month==6'>and u.creationTime>DATE_SUB(CURDATE(), INTERVAL 6 MONTH)</if>",
" <if test='month==9'>and u.creationTime>DATE_SUB(CURDATE(), INTERVAL 9 MONTH)</if>",
" <if test='month==12'>and u.creationTime>DATE_SUB(CURDATE(), INTERVAL 12 MONTH)</if>",
" <if test='creationTime!=null and endTime!=null and endTime!=\"\" and creationTime!=\"\" '> and u.creationTime between #{creationTime} and #{endTime}</if>",
"GROUP BY u.userId order by u.creationTime desc",
"</script> "})
"SELECT u.*,s.schoolName,p.provinceName,c.cityName from user u,school s,province p,city c where u.isdel = 0 and p.provinceId = u.provinceId and p.provinceId = c.provinceId and u.cityId = c.cityId and u.schoolId = s.schoolId",
" <if test='countries!=null and countries !=\"\" '>and u.countries = #{countries} </if>",
" <if test='provinceId!=null and provinceId !=\"\" '>and u.provinceId = #{provinceId} </if>",
" <if test='schoolId!=null'>and u.schoolId = #{schoolId} </if>",
" <if test='cityId!=null and cityId !=\"\" '>and u.cityId = #{cityId} </if>",
" <if test='accountRole!=null and accountRole !=\"\" '>and u.accountRole = #{accountRole} </if>",
" <if test='searchContent!=null and searchContent !=\"\" '> AND CONCAT(u.name, s.schoolName) LIKE CONCAT('%',#{searchContent},'%')</if>",
" <if test='month==3'>and u.creationTime>DATE_SUB(CURDATE(), INTERVAL 3 MONTH)</if>",
" <if test='month==6'>and u.creationTime>DATE_SUB(CURDATE(), INTERVAL 6 MONTH)</if>",
" <if test='month==9'>and u.creationTime>DATE_SUB(CURDATE(), INTERVAL 9 MONTH)</if>",
" <if test='month==12'>and u.creationTime>DATE_SUB(CURDATE(), INTERVAL 12 MONTH)</if>",
" <if test='creationTime!=null and endTime!=null and endTime!=\"\" and creationTime!=\"\" '> and u.creationTime between #{creationTime} and #{endTime}</if>",
"GROUP BY u.userId order by u.creationTime desc",
"</script> "})
List<UserM> queryUser(UserM user);
@Select({"<script>",
@ -188,8 +188,8 @@ public interface UserMapper {
//查询用户详情
@Select({"<script>",
"SELECT u.*,schoolName from user u,school s where u.isdel = 0 and u.schoolId = s.schoolId and u.userId = #{userId}",
"</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> queryUserDetails(Integer userId);
@Select({"<script>",
@ -235,28 +235,28 @@ public interface UserMapper {
"</script> "})
List<Staff> queryUserDetailsSta(Integer userId);
@Select({"<script>",
"SELECT customerId,customerName,schoolId FROM customer where isdel = 0 and provinceId = #{provinceId} and cityId = #{cityId}",
"</script> "})
List<Customer> queryCustomer(Integer cityId,Integer provinceId);
@Select({"<script>",
"SELECT customerId,customerName,schoolId FROM customer where isdel = 0 and provinceId = #{provinceId} and cityId = #{cityId}",
"</script> "})
List<Customer> queryCustomer(Integer cityId,Integer provinceId);
/**
* 批量插入用户
* @param user
*/
@Insert({
"<script>",
"insert into user(name, password,accountRole,workNumber,phone,uniqueIdentificationAccount,creationTime,isdel) values ",
"<foreach collection='users' item='user' index='index' separator=','>",
"(#{user.name}, #{user.password}, #{user.accountRole}, #{user.workNumber} ,#{user.phone},#{user.uniqueIdentificationAccount},now(),0)",
"</foreach>",
"</script>"
})
"<script>",
"insert into user(name, password,accountRole,workNumber,phone,uniqueIdentificationAccount,creationTime,isdel) values ",
"<foreach collection='users' item='user' index='index' separator=','>",
"(#{user.name}, #{user.password}, #{user.accountRole}, #{user.workNumber} ,#{user.phone},#{user.uniqueIdentificationAccount},now(),0)",
"</foreach>",
"</script>"
})
void addUserM(@Param("users")List<UserM> users);
//修改用户头像
@Update("update user set userAvatars=#{userAvatars} where userId=#{userId}")
void updateUserAvatars(@Param("userAvatars")String userAvatars, @Param("userId")Integer userId);
void updateUserAvatars(@Param("userAvatars")String userAvatars, @Param("userId")Integer userId);
//更新用户登录次数和最后一次登录时间
@Update({ "UPDATE user SET logInNumber=logInNumber+1, lastTimeOfLanding=now() WHERE userId=#{userId}"})

@ -12,6 +12,7 @@ import com.yipin.liuwanr.mapper.OrganizationRelationshipMapper;
import com.yipin.liuwanr.mapper.StaffMapper;
import com.yipin.liuwanr.mapper.StudentMapper;
import com.yipin.liuwanr.mapper.UserInfoMapper;
import com.yipin.liuwanr.vo.UserInfoReceiveVo;
import org.jboss.logging.Logger;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -137,9 +138,9 @@ public class UserInfoService {
resp.put("retcode", 500);
resp.put("retvalue", "添加用户失败!");
throw new RuntimeException();
}
return resp;
}
return resp;
}
//查询用户信息
public HashMap<String, Object> queryUserInfo(UserInfo userInfo,Integer pageNo,Integer pageSize){
@ -383,6 +384,46 @@ public class UserInfoService {
}
return resp;
}
//登陆获取学校/电子科大
public HashMap<String, Object> loginSchoolClient(UserInfo userInfo){
HashMap<String, Object> resp = new HashMap<String, Object>();
HashMap<String, Object> obj = new HashMap<String, Object>();
Integer schoolId = userInfo.getSchoolId();
Integer state = userInfoMapper.queryDisableAccount(userInfo);
if (state==null){
resp.put("retcode",300);
resp.put("retvalue","账号不存在");
}else if (state==0){
try {
UserInfo user=userInfoMapper.loginsAP(userInfo);
// obj.put("user",user);
if(user!=null) {
Integer userId = user.getUserId();
List<UserInfo> staffList = userInfoMapper.loginsGetStaffSchoolInfo(userId,schoolId);
obj.put("staffList",staffList);
// List<UserInfo> studentList = userInfoMapper.loginsGetStudentSchoolInfo(userId,schoolId);
List<UserInfoReceiveVo> studentList = userInfoMapper.loginsGetStudentSchoolInfo(userId,schoolId);
obj.put("studentList",studentList);
resp.put("retcode", 200);
resp.put("retvalue", obj);
}else {
resp.put("retcode", 300);
resp.put("retvalue", "登录失败,密码有误!");
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "登录异常,请稍后再试!");
return resp;
}
}else if (state==1){
resp.put("retcode",400);
resp.put("retvalue","账号处于禁用状态");
}
return resp;
}
//登陆
public HashMap<String, Object> logins(UserInfo userInfo){
@ -692,8 +733,8 @@ public class UserInfoService {
//删除平台
public HashMap<String, Object> queryStuAndSta(Integer platformId,Integer userId){
HashMap<String, Object> resp = new HashMap<String, Object>();
HashMap<String, Object> obj = new HashMap<String, Object>();
HashMap<String, Object> resp = new HashMap<String, Object>();
HashMap<String, Object> obj = new HashMap<String, Object>();
try {
obj.put("Staff", userInfoMapper.queryStaff(platformId,userId));
obj.put("Student", userInfoMapper.queryStudent1(platformId,userId));

@ -43,11 +43,11 @@ public class UserService {
@Autowired
private JedisCluster jedis;
@Autowired
private AliyunOssConfig config;
@Autowired
private AliyunOssConfig config;
@Autowired
private BeanFactory beanFactory;
@Autowired
private BeanFactory beanFactory;
public HashMap<String, Object> login(String id, String password){
HashMap<String, Object> resp = new HashMap<String, Object>();
@ -152,7 +152,7 @@ public class UserService {
totalPages = total1 / pageSize;
if (total1 % pageSize != 0){
totalPages ++;
}
}
long total = total1;
resp.put("retvalue", new PageResult(total, list,totalPages));
resp.put("retcode", 200);
@ -185,38 +185,38 @@ public class UserService {
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;
}
//批量删除员工
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
@Transactional
public HashMap<String, Object> updateUser(UserM user){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
@ -226,7 +226,7 @@ public class UserService {
logger.error(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "更新用户失败!");
throw new RuntimeException();
throw new RuntimeException();
}
return resp;
}
@ -266,9 +266,9 @@ public class UserService {
//登陆
public HashMap<String, Object> logins(UserM userM){
HashMap<String, Object> resp = new HashMap<String, Object>();
HashMap<String, Object> obj = new HashMap<String, Object>();
Student student;
Staff staff;
HashMap<String, Object> obj = new HashMap<String, Object>();
Student student;
Staff staff;
try {
UserM user=userMapper.logins(userM);
if(user!=null) {
@ -279,14 +279,14 @@ public class UserService {
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String lastTime=sd.format(date);
if(user.getAccountRole().equals(4)) {
student=studentMapper.queryStudentQ(user);
student=studentMapper.queryStudentQ(user);
if(student!=null) {
Integer studentId=student.getStudentId();
studentMapper.updateStudentQ(lastTime,loginNumber, studentId);
obj.put("student",student);
}
}else if(user.getAccountRole().equals(3)) {
staff =staffMapper.queryStaffQ(user);
staff =staffMapper.queryStaffQ(user);
if(staff!=null) {
Integer staffId=staff.getStaffId();
staffMapper.updateStaffQ(lastTime,loginNumber, staffId);
@ -315,16 +315,16 @@ public class UserService {
public HashMap<String, Object> queryUserDetails(Integer userId,Integer roleId){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
if (roleId == 3){
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);
}
if (roleId == 3){
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) {
logger.error(e.getMessage());
resp.put("retcode", 500);
@ -349,28 +349,28 @@ public class UserService {
return resp;
}
//修改用户头像
public HashMap<String, Object> uploadUserAvatars(MultipartFile file,Integer userId){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
OSSClient client=beanFactory.getBean(OSSClient.class);
FilesResult result=OssConfigUtil.uploadUserAvatars(file, client, config);
//用户图片路径
String userAvatars=result.getFileUrl();
userMapper.updateUserAvatars(userAvatars,userId);
resp.put("retcode", 200);
resp.put("retvalue", userAvatars);
} catch (Exception e) {
logger.info(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "修改头像失败!");
return resp;
}
return resp;
}
//更新登录次数和时间
//修改用户头像
public HashMap<String, Object> uploadUserAvatars(MultipartFile file,Integer userId){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {
OSSClient client=beanFactory.getBean(OSSClient.class);
FilesResult result=OssConfigUtil.uploadUserAvatars(file, client, config);
//用户图片路径
String userAvatars=result.getFileUrl();
userMapper.updateUserAvatars(userAvatars,userId);
resp.put("retcode", 200);
resp.put("retvalue", userAvatars);
} catch (Exception e) {
logger.info(e.getMessage());
resp.put("retcode", 500);
resp.put("retvalue", "修改头像失败!");
return resp;
}
return resp;
}
//更新登录次数和时间
public HashMap<String, Object> updateLogInNumber(UserM user){
HashMap<String, Object> resp = new HashMap<String, Object>();
try {

@ -0,0 +1,19 @@
package com.yipin.liuwanr.vo;
import lombok.Data;
@Data
public class UserInfoReceiveVo {
//学校id
private Integer schoolId;
//学校名称
private String schoolName;
//用户id
private Integer userId;
//学生id
private Integer studentId;
//账号状态
private Integer state;
}

@ -48,3 +48,6 @@ redis.cluster.maxTotal=200
redis.cluster.maxIdle=8
redis.cluster.minIdle=3
redis.cluster.nodes=192.168.136.191:8000,192.168.136.191:8001,192.168.136.191:8002
server.port=8090
server.servlet.context-path= /liuwanr
Loading…
Cancel
Save