From 6eebe5f946693f9f3741ce81303afad2cd229e6a Mon Sep 17 00:00:00 2001 From: "zhiyong.ning" <354350178@qq.com> Date: Tue, 9 Mar 2021 16:21:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/yipin/liuwanr/JwtUtils.java | 108 ++++++++++++++++++ .../liuwanr/controller/CityController.java | 12 +- .../liuwanr/controller/UserController.java | 6 +- .../controller/UserInfoController.java | 25 ++-- .../entity/{SutdentClass.java => Class.java} | 8 +- .../java/com/yipin/liuwanr/entity/Grade.java | 6 +- .../entity/{City.java => StudentCity.java} | 4 +- .../yipin/liuwanr/mapper/AssesmentMapper.java | 4 +- .../com/yipin/liuwanr/mapper/CityMapper.java | 13 +-- .../com/yipin/liuwanr/mapper/ClassMapper.java | 4 +- .../yipin/liuwanr/mapper/CourseMapper.java | 2 +- .../StuProfessionalArchitectureMapper.java | 6 +- .../yipin/liuwanr/mapper/UserInfoMapper.java | 4 +- .../com/yipin/liuwanr/mapper/UserMapper.java | 4 +- .../liuwanr/service/AssesmentService.java | 5 +- .../yipin/liuwanr/service/CityService.java | 10 +- .../liuwanr/service/UserInfoService.java | 25 ++-- .../com/yipin/liuwanr/CityServiceTest.java | 16 +-- .../com/yipin/liuwanr/ClassServiceTest.java | 4 +- 19 files changed, 187 insertions(+), 79 deletions(-) create mode 100644 src/main/java/com/yipin/liuwanr/JwtUtils.java rename src/main/java/com/yipin/liuwanr/entity/{SutdentClass.java => Class.java} (89%) rename src/main/java/com/yipin/liuwanr/entity/{City.java => StudentCity.java} (93%) diff --git a/src/main/java/com/yipin/liuwanr/JwtUtils.java b/src/main/java/com/yipin/liuwanr/JwtUtils.java new file mode 100644 index 0000000..dc69c25 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/JwtUtils.java @@ -0,0 +1,108 @@ +//package com.yipin.liuwanr; +// +// +//import com.alibaba.fastjson.JSONObject; +//import com.sun.org.apache.xml.internal.security.algorithms.SignatureAlgorithm; +//import io.jsonwebtoken.Claims; +//import io.jsonwebtoken.ExpiredJwtException; +//import io.jsonwebtoken.JwtBuilder; +//import io.jsonwebtoken.Jwts; +//import io.jsonwebtoken.SignatureAlgorithm; +//import org.apache.commons.codec.binary.Base64; +// +//import javax.crypto.SecretKey; +//import javax.crypto.spec.SecretKeySpec; +//import java.security.SignatureException; +//import java.util.Date; +// +//public class JwtUtils { +// /** +// * 签发JWT +// * +// * @param id +// * @param subject 可以是JSON数据 尽可能少 +// * @param ttlMillis +// * @return String +// * +// */ +// public static String createJWT(String id, String subject, long ttlMillis) { +// ttlMillis = ttlMillis * 1000; +// SignatureAlgorithm signatureAlgorithm = SignatureAlgorithm.HS256; +// long nowMillis = System.currentTimeMillis(); +// Date now = new Date(nowMillis); +// SecretKey secretKey = generalKey(); +// JwtBuilder builder = Jwts.builder().setId(String.valueOf(id)).setSubject(subject) // 主题 +// .setIssuer("user") // 签发者 +// .setIssuedAt(now) // 签发时间 +// .signWith(signatureAlgorithm, secretKey); // 签名算法以及密匙 +// if (ttlMillis >= 0) { +// long expMillis = nowMillis + ttlMillis; +// Date expDate = new Date(expMillis); +// builder.setExpiration(expDate); // 过期时间 +// } +// return builder.compact(); +// } +// +// public static void main(String[] args) { +// //System.out.printf(createJWT("1","111", 10000000)); +// boolean isTrue = validateJWT("eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxIiwic3ViIjoiMTExIiwiaXNzIjoidXNlciIsImlhdCI6MTYwMTM0MzYyNywiZXhwIjoxNjAxMzUzNjI3fQ.q5Ssg2LM1OzzgvVWqLhgP_Hko0-pfeNO5bvpUE5KQ-s"); +// System.out.println(isTrue); +// } +// +// /** +// * 验证JWT +// * +// * @param jwtStr +// * @return +// */ +// public static Boolean validateJWT(String jwtStr) { +// //boolean isValidate = false; +// Claims claims = null; +// try { +// claims = parseJWT(jwtStr); +// return true; +// } catch (ExpiredJwtException e) { +// return false; +// } catch (SignatureException e) { +// return false; +// } catch (Exception e) { +// return false; +// } +// //return checkResult; +// } +// +// public static SecretKey generalKey() { +// byte[] encodedKey = Base64.decodeBase64("DQJWT"); +// SecretKey key = new SecretKeySpec(encodedKey, 0, encodedKey.length, "AES"); +// return key; +// } +// +// /** +// * +// * 解析JWT字符串 +// * +// * @param jwt +// * @return +// * @throws Exception +// */ +// public static Claims parseJWT(String jwt) throws Exception { +// SecretKey secretKey = generalKey(); +// return Jwts.parser().setSigningKey(secretKey).parseClaimsJws(jwt).getBody(); +// } +// +// public static void putTokenToRedis(Long userId, String token, long times) { +// RedisUtil.setEx("dq:token:"+token, String.valueOf(userId), times); +// } +// +// public static void putUserEntityToRedis(Long userId, UserEntity userEntity, long times) { +// RedisUtil.setEx("dq:userId:"+userId, JSONObject.toJSONString(userEntity), times); +// } +// +// public static void removeUserEntityByUserId(Long userId) { +// RedisUtil.del("dq:userId:"+userId); +// } +// +// public static void removeTokenByToken(String token) { +// RedisUtil.del("dq:token:"+token); +// } +//} \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/controller/CityController.java b/src/main/java/com/yipin/liuwanr/controller/CityController.java index 410c137..07bb533 100644 --- a/src/main/java/com/yipin/liuwanr/controller/CityController.java +++ b/src/main/java/com/yipin/liuwanr/controller/CityController.java @@ -2,6 +2,7 @@ package com.yipin.liuwanr.controller; import java.util.HashMap; +import com.yipin.liuwanr.entity.StudentCity; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.GetMapping; @@ -12,7 +13,6 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import com.yipin.liuwanr.entity.City; import com.yipin.liuwanr.entity.Response; import com.yipin.liuwanr.helper.RedisHelper; import com.yipin.liuwanr.service.CityService; @@ -32,9 +32,9 @@ public class CityController { * 添加城市 */ @PostMapping("/addCity") - Response addCustomer(@RequestBody City city) { + Response addCustomer(@RequestBody StudentCity studentCity) { Response resp = new Response(); - HashMap ret = cityService.addCity(city); + HashMap ret = cityService.addCity(studentCity); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); @@ -91,13 +91,13 @@ public class CityController { * 更新城市 */ @RequestMapping(value="/updateCity",method = RequestMethod.POST) - Response updateCity(@RequestBody City city) { + Response updateCity(@RequestBody StudentCity studentCity) { Response resp = new Response(); - if (city==null) { + if (studentCity ==null) { resp.setStatus(300); resp.setErrmessage("Parameter Invalid"); } else { - HashMap ret = cityService.updateCity(city); + HashMap ret = cityService.updateCity(studentCity); 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 e7c72aa..897a8b0 100644 --- a/src/main/java/com/yipin/liuwanr/controller/UserController.java +++ b/src/main/java/com/yipin/liuwanr/controller/UserController.java @@ -459,14 +459,14 @@ public class UserController { Response updateLogInNumber(@RequestBody UserM user) { Response resp = new Response(); Integer userId = user.getUserId(); - String phone = user.getPhone(); + String account = user.getUserAccount(); Integer accountRole = user.getAccountRole(); if (userId==null) { resp.setStatus(300); resp.setErrmessage("用户id不能为空!"); - }else if(phone==null||phone==""){ + }else if(account==null||account==""){ resp.setStatus(300); - resp.setErrmessage("用户电话不能为空!"); + resp.setErrmessage("用户账号不能为空!"); } else if(accountRole==null){ resp.setStatus(300); resp.setErrmessage("用户角色不能为空!"); diff --git a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java index 4303d84..22745dd 100644 --- a/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java +++ b/src/main/java/com/yipin/liuwanr/controller/UserInfoController.java @@ -521,22 +521,23 @@ public class UserInfoController { * 更新登录次数和时间 */ @PostMapping("/updateLogInNumber") - Response updateLogInNumber(@RequestBody UserM user) { + Response updateLogInNumber(@RequestBody UserInfo userInfo) { Response resp = new Response(); - Integer userId = user.getUserId(); - String phone = user.getPhone(); - Integer accountRole = user.getAccountRole(); + Integer userId = userInfo.getUserId(); + String phone = userInfo.getPhone(); + String roleId = userInfo.getRoleId(); if (userId==null) { resp.setStatus(300); resp.setErrmessage("用户id不能为空!"); - }else if(phone==null||phone==""){ - resp.setStatus(300); - resp.setErrmessage("用户电话不能为空!"); - } else if(accountRole==null){ - resp.setStatus(300); - resp.setErrmessage("用户角色不能为空!"); - } else { - HashMap ret = userInfoService.updateLogInNumber(user); +// }else if(phone==null||phone==""){ +// resp.setStatus(300); +// resp.setErrmessage("用户电话不能为空!"); +// } else if(accountRole==null){ +// resp.setStatus(300); +// resp.setErrmessage("用户角色不能为空!"); + } + else { + HashMap ret = userInfoService.updateLogInNumber(userInfo); int status = (int) ret.get("retcode"); if (200 == status) { resp.setStatus(status); diff --git a/src/main/java/com/yipin/liuwanr/entity/SutdentClass.java b/src/main/java/com/yipin/liuwanr/entity/Class.java similarity index 89% rename from src/main/java/com/yipin/liuwanr/entity/SutdentClass.java rename to src/main/java/com/yipin/liuwanr/entity/Class.java index d36a360..4e885b0 100644 --- a/src/main/java/com/yipin/liuwanr/entity/SutdentClass.java +++ b/src/main/java/com/yipin/liuwanr/entity/Class.java @@ -2,11 +2,11 @@ package com.yipin.liuwanr.entity; /** * 班级 - * - * @author 全承珠 + * + * @author Ning * */ -public class SutdentClass { +public class Class { private Integer classId; private String className; @@ -38,7 +38,7 @@ public class SutdentClass { @Override public String toString() { - return "SutdentClass{" + + return "Class{" + "classId=" + classId + ", className='" + className + '\'' + ", gradeId=" + gradeId + diff --git a/src/main/java/com/yipin/liuwanr/entity/Grade.java b/src/main/java/com/yipin/liuwanr/entity/Grade.java index a9348e7..89b66a7 100644 --- a/src/main/java/com/yipin/liuwanr/entity/Grade.java +++ b/src/main/java/com/yipin/liuwanr/entity/Grade.java @@ -14,13 +14,13 @@ public class Grade { private String gradeName; private Integer professionalArchitectureId; private List experimentalClass; - private List classes; + private List classes; - public List getClasses() { + public List getClasses() { return classes; } - public void setClasses(List classes) { + public void setClasses(List classes) { this.classes = classes; } diff --git a/src/main/java/com/yipin/liuwanr/entity/City.java b/src/main/java/com/yipin/liuwanr/entity/StudentCity.java similarity index 93% rename from src/main/java/com/yipin/liuwanr/entity/City.java rename to src/main/java/com/yipin/liuwanr/entity/StudentCity.java index 2e77b08..107feb6 100644 --- a/src/main/java/com/yipin/liuwanr/entity/City.java +++ b/src/main/java/com/yipin/liuwanr/entity/StudentCity.java @@ -1,6 +1,6 @@ package com.yipin.liuwanr.entity; -public class City { +public class StudentCity { //城市主键ID private Integer cityId; @@ -29,7 +29,7 @@ public class City { @Override public String toString() { - return "City{" + + return "StudentCity{" + "cityId=" + cityId + ", cityName='" + cityName + '\'' + ", provinceId=" + provinceId + diff --git a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java index 6acf638..4396b3b 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java @@ -1,9 +1,9 @@ package com.yipin.liuwanr.mapper; -import java.util.HashMap; import java.util.List; import com.yipin.liuwanr.entity.*; +import com.yipin.liuwanr.entity.Class; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Many; @@ -233,7 +233,7 @@ public interface AssesmentMapper { * @return */ @Select("SELECT c.classId as classId,c.className as className from assessment ass left join class c on FIND_IN_SET(c.classId,ass.classId) where ass.id=#{assesmentId}") - List queryClass(Integer assesmentId); + List queryClass(Integer assesmentId); //s.isdel=0 and @Select("select s.studentId,studentName from student s left join experimental_class_student ecs on s.studentId=ecs.studentId where ecs.experimentalClassId=#{experimentalClassId} ") diff --git a/src/main/java/com/yipin/liuwanr/mapper/CityMapper.java b/src/main/java/com/yipin/liuwanr/mapper/CityMapper.java index 68247f7..4e122e9 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/CityMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/CityMapper.java @@ -2,26 +2,25 @@ package com.yipin.liuwanr.mapper; import java.util.List; +import com.yipin.liuwanr.entity.StudentCity; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; -import com.yipin.liuwanr.entity.City; - public interface CityMapper { - @Insert("INSERT INTO city(cityName,provinceId,isdel)" + @Insert("INSERT INTO studentCity(cityName,provinceId,isdel)" + "VALUES(#{cityName},#{provinceId},0)") - void addCity(City city); + void addCity(StudentCity studentCity); @Select({" "}) - List queryCity(Integer provinceId); + List queryCity(Integer provinceId); @Update("UPDATE city SET isdel = 1 where cityId = #{cityId}") void deleteCity(Integer cityId); - @Update("UPDATE city SET cityName = #{cityName} where cityId = #{cityId}") - void updateCity(City city); + @Update("UPDATE studentCity SET cityName = #{cityName} where cityId = #{cityId}") + void updateCity(StudentCity studentCity); } \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/mapper/ClassMapper.java b/src/main/java/com/yipin/liuwanr/mapper/ClassMapper.java index addbc50..23d7b28 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/ClassMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/ClassMapper.java @@ -2,9 +2,9 @@ package com.yipin.liuwanr.mapper; import java.util.List; +import com.yipin.liuwanr.entity.Class; import org.apache.ibatis.annotations.Select; -import com.yipin.liuwanr.entity.SutdentClass; /** * * @@ -14,5 +14,5 @@ import com.yipin.liuwanr.entity.SutdentClass; public interface ClassMapper { @Select("select classId,className from class where className like concat(#{className},'%') ") - List queryGetByClassName(String className); + List queryGetByClassName(String className); } diff --git a/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java b/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java index ead1e99..994d92c 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java @@ -58,7 +58,7 @@ public interface CourseMapper { " and c.professionalClassId = #{professionalClassId} ", " and c.professionalId = #{professionalId} ", " and c.courseName like CONCAT('%',#{searchContent},'%')", - "GROUP BY courseId", + "GROUP BY c.courseId", "order by c.creationTime desc", " "}) List queryCourse(Course course); diff --git a/src/main/java/com/yipin/liuwanr/mapper/StuProfessionalArchitectureMapper.java b/src/main/java/com/yipin/liuwanr/mapper/StuProfessionalArchitectureMapper.java index ea86b26..f8fd98e 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/StuProfessionalArchitectureMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/StuProfessionalArchitectureMapper.java @@ -2,6 +2,7 @@ package com.yipin.liuwanr.mapper; import java.util.List; +import com.yipin.liuwanr.entity.Class; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Select; @@ -10,7 +11,6 @@ import org.apache.ibatis.annotations.Update; import com.yipin.liuwanr.entity.Grade; import com.yipin.liuwanr.entity.StuProfessionalArchitecture; import com.yipin.liuwanr.entity.Student; -import com.yipin.liuwanr.entity.SutdentClass; public interface StuProfessionalArchitectureMapper { @@ -55,12 +55,12 @@ public interface StuProfessionalArchitectureMapper { @Select({" "}) - List queryStuClass(Integer gradeId); + List queryStuClass(Integer gradeId); @Select({" "}) - List queryStuClassD(Integer classId); + List queryStuClassD(Integer classId); @Insert("INSERT INTO class(className,gradeId)" + "VALUES(#{className},#{gradeId})") diff --git a/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java index 35352af..dbb8be6 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java @@ -262,8 +262,8 @@ public interface UserInfoMapper { void updateUserAvatars(@Param("userAvatars") String userAvatars, @Param("userId") Integer userId); //更新用户登录次数和最后一次登录时间 - @Update({"UPDATE user SET logInNumber=logInNumber+1, lastTimeOfLanding=now() WHERE userId=#{userId}"}) - void updateLogInNumber(UserM user); + @Update({"UPDATE hr_user_info SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE userId=#{userId}"}) + void updateLogInNumber(UserInfo userInfo); //更新学生登录次数和最后一次登录时间 @Update({"UPDATE student SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE phone=#{phone}"}) diff --git a/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java b/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java index 26a90ea..5750558 100644 --- a/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java +++ b/src/main/java/com/yipin/liuwanr/mapper/UserMapper.java @@ -263,11 +263,11 @@ public interface UserMapper { void updateLogInNumber(UserM user); //更新用户登录次数和最后一次登录时间 - @Update({ "UPDATE student SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE phone=#{phone}"}) + @Update({ "UPDATE student SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE userId=#{userId}"}) void updateStudentLogInNumber(UserM user); //更新用户登录次数和最后一次登录时间 - @Update({ "UPDATE staff SET logNumber=logNumber+1, lastTimeOfLanding=now() WHERE phone=#{phone}"}) + @Update({ "UPDATE staff SET logNumber=logNumber+1, lastTimeOfLanding=now() WHERE userId=#{userId}"}) void updateStaffLogInNumber(UserM user); //查询账号是否存在 diff --git a/src/main/java/com/yipin/liuwanr/service/AssesmentService.java b/src/main/java/com/yipin/liuwanr/service/AssesmentService.java index 19577ad..205e413 100644 --- a/src/main/java/com/yipin/liuwanr/service/AssesmentService.java +++ b/src/main/java/com/yipin/liuwanr/service/AssesmentService.java @@ -19,10 +19,9 @@ import com.yipin.liuwanr.entity.PointRecord; import com.yipin.liuwanr.entity.Record; import com.yipin.liuwanr.entity.Score; import com.yipin.liuwanr.entity.Student; -import com.yipin.liuwanr.entity.SutdentClass; +import com.yipin.liuwanr.entity.Class; import com.yipin.liuwanr.helper.AssesmentHelper; import com.yipin.liuwanr.mapper.AssesmentMapper; -import com.yipin.liuwanr.vo.AssesmentStudentVo; @Service public class AssesmentService { @@ -383,7 +382,7 @@ public class AssesmentService { HashMap obj = new HashMap(); try { List experimentalClasses = mapper.queryExperimental(assesmentId); - List classes = mapper.queryClass(assesmentId); + List classes = mapper.queryClass(assesmentId); obj.put("experimentalClass", experimentalClasses); obj.put("class", classes); diff --git a/src/main/java/com/yipin/liuwanr/service/CityService.java b/src/main/java/com/yipin/liuwanr/service/CityService.java index 65ee31c..0f5313e 100644 --- a/src/main/java/com/yipin/liuwanr/service/CityService.java +++ b/src/main/java/com/yipin/liuwanr/service/CityService.java @@ -2,11 +2,11 @@ package com.yipin.liuwanr.service; import java.util.HashMap; +import com.yipin.liuwanr.entity.StudentCity; import org.jboss.logging.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.yipin.liuwanr.entity.City; import com.yipin.liuwanr.mapper.CityMapper; @Service @@ -17,10 +17,10 @@ public class CityService { @Autowired private CityMapper cityMapper; - public HashMap addCity(City city){ + public HashMap addCity(StudentCity studentCity){ HashMap resp = new HashMap(); try { - cityMapper.addCity(city); + cityMapper.addCity(studentCity); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); @@ -60,10 +60,10 @@ public class CityService { return resp; } - public HashMap updateCity(City city){ + public HashMap updateCity(StudentCity studentCity){ HashMap resp = new HashMap(); try { - cityMapper.updateCity(city); + cityMapper.updateCity(studentCity); resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); diff --git a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java index da13266..24ab730 100644 --- a/src/main/java/com/yipin/liuwanr/service/UserInfoService.java +++ b/src/main/java/com/yipin/liuwanr/service/UserInfoService.java @@ -449,7 +449,8 @@ public class UserInfoService { List studentList = userInfoMapper.queryStudentAll(id,roleId,schoolId); obj.put("studentList",studentList); ValueOperations redis = stringRedisTemplate.opsForValue(); - redis.set(token,userId+"", 30 * 60, TimeUnit.SECONDS); + //设置token 1小时候过期 + redis.set(token,userId+"", 1, TimeUnit.HOURS); resp.put("retcode", 200); resp.put("retvalue", obj); }else { @@ -611,19 +612,19 @@ public class UserInfoService { } //更新登录次数和时间 - public HashMap updateLogInNumber(UserM user){ + public HashMap updateLogInNumber(UserInfo userInfo){ HashMap resp = new HashMap(); try { - Integer accountRole = user.getAccountRole(); - userInfoMapper.updateLogInNumber(user); - if (accountRole==3){ - //更新员工登录次数和时间 - userInfoMapper.updateStaffLogInNumber(user); - } - if (accountRole==4){ - //更新学生登录次数和时间 - userInfoMapper.updateStudentLogInNumber(user); - } +// Integer accountRole = user.getAccountRole(); + userInfoMapper.updateLogInNumber(userInfo); +// if (accountRole==3){ +// //更新员工登录次数和时间 +// userInfoMapper.updateStaffLogInNumber(user); +// } +// if (accountRole==4){ +// //更新学生登录次数和时间 +// userInfoMapper.updateStudentLogInNumber(user); +// } resp.put("retcode", 200); } catch (RuntimeException e) { logger.error(e.getMessage()); diff --git a/src/test/java/com/yipin/liuwanr/CityServiceTest.java b/src/test/java/com/yipin/liuwanr/CityServiceTest.java index b580097..9d1ad4d 100644 --- a/src/test/java/com/yipin/liuwanr/CityServiceTest.java +++ b/src/test/java/com/yipin/liuwanr/CityServiceTest.java @@ -1,6 +1,6 @@ package com.yipin.liuwanr; -import com.yipin.liuwanr.entity.City; +import com.yipin.liuwanr.entity.StudentCity; import com.yipin.liuwanr.mapper.CityMapper; import com.yipin.liuwanr.service.CityService; import org.junit.Test; @@ -29,7 +29,7 @@ public class CityServiceTest { /*@Test @Transactional public void testAddCity() { - City city = new City(); + StudentCity city = new StudentCity(); city.setCityName("hhhh"); city.setProvinceId(2); HashMap map = cityService.addCity(city); @@ -45,7 +45,7 @@ public class CityServiceTest { Integer retcode = (Integer) map.get("retcode"); System.out.println(retcode); if (retcode == 200) { - List cities = (List) map.get("retvalue"); + List cities = (List) map.get("retvalue"); cities.forEach(item -> { System.out.println(item.toString()); }); @@ -71,11 +71,11 @@ public class CityServiceTest { @Test @Transactional public void testUpdateCity() { - City city = new City(); - city.setCityId(1); - city.setCityName("hhhh"); - city.setProvinceId(2); - HashMap map = cityService.updateCity(city); + StudentCity studentCity = new StudentCity(); + studentCity.setCityId(1); + studentCity.setCityName("hhhh"); + studentCity.setProvinceId(2); + HashMap map = cityService.updateCity(studentCity); map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); } } diff --git a/src/test/java/com/yipin/liuwanr/ClassServiceTest.java b/src/test/java/com/yipin/liuwanr/ClassServiceTest.java index e705dbe..207a653 100644 --- a/src/test/java/com/yipin/liuwanr/ClassServiceTest.java +++ b/src/test/java/com/yipin/liuwanr/ClassServiceTest.java @@ -1,6 +1,6 @@ package com.yipin.liuwanr; -import com.yipin.liuwanr.entity.SutdentClass; +import com.yipin.liuwanr.entity.Class; import com.yipin.liuwanr.service.ClassService; import org.junit.Test; import org.junit.runner.RunWith; @@ -24,7 +24,7 @@ public class ClassServiceTest { Integer retcode = (Integer) map.get("retcode"); System.out.println(retcode); if (retcode == 200) { - List classes = (List) map.get("retvalue"); + List classes = (List) map.get("retvalue"); classes.forEach(item -> { System.out.println(item.toString()); });