上传代码

master
zhiyong.ning 4 years ago
parent 06f3fc8507
commit 6eebe5f946
  1. 108
      src/main/java/com/yipin/liuwanr/JwtUtils.java
  2. 12
      src/main/java/com/yipin/liuwanr/controller/CityController.java
  3. 6
      src/main/java/com/yipin/liuwanr/controller/UserController.java
  4. 25
      src/main/java/com/yipin/liuwanr/controller/UserInfoController.java
  5. 6
      src/main/java/com/yipin/liuwanr/entity/Class.java
  6. 6
      src/main/java/com/yipin/liuwanr/entity/Grade.java
  7. 4
      src/main/java/com/yipin/liuwanr/entity/StudentCity.java
  8. 4
      src/main/java/com/yipin/liuwanr/mapper/AssesmentMapper.java
  9. 13
      src/main/java/com/yipin/liuwanr/mapper/CityMapper.java
  10. 4
      src/main/java/com/yipin/liuwanr/mapper/ClassMapper.java
  11. 2
      src/main/java/com/yipin/liuwanr/mapper/CourseMapper.java
  12. 6
      src/main/java/com/yipin/liuwanr/mapper/StuProfessionalArchitectureMapper.java
  13. 4
      src/main/java/com/yipin/liuwanr/mapper/UserInfoMapper.java
  14. 4
      src/main/java/com/yipin/liuwanr/mapper/UserMapper.java
  15. 5
      src/main/java/com/yipin/liuwanr/service/AssesmentService.java
  16. 10
      src/main/java/com/yipin/liuwanr/service/CityService.java
  17. 25
      src/main/java/com/yipin/liuwanr/service/UserInfoService.java
  18. 16
      src/test/java/com/yipin/liuwanr/CityServiceTest.java
  19. 4
      src/test/java/com/yipin/liuwanr/ClassServiceTest.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 <UserEntity> 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);
// }
//}

@ -2,6 +2,7 @@ package com.yipin.liuwanr.controller;
import java.util.HashMap; import java.util.HashMap;
import com.yipin.liuwanr.entity.StudentCity;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping; 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.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.yipin.liuwanr.entity.City;
import com.yipin.liuwanr.entity.Response; import com.yipin.liuwanr.entity.Response;
import com.yipin.liuwanr.helper.RedisHelper; import com.yipin.liuwanr.helper.RedisHelper;
import com.yipin.liuwanr.service.CityService; import com.yipin.liuwanr.service.CityService;
@ -32,9 +32,9 @@ public class CityController {
* 添加城市 * 添加城市
*/ */
@PostMapping("/addCity") @PostMapping("/addCity")
Response addCustomer(@RequestBody City city) { Response addCustomer(@RequestBody StudentCity studentCity) {
Response resp = new Response(); Response resp = new Response();
HashMap<String, Object> ret = cityService.addCity(city); HashMap<String, Object> ret = cityService.addCity(studentCity);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
resp.setStatus(status); resp.setStatus(status);
@ -91,13 +91,13 @@ public class CityController {
* 更新城市 * 更新城市
*/ */
@RequestMapping(value="/updateCity",method = RequestMethod.POST) @RequestMapping(value="/updateCity",method = RequestMethod.POST)
Response updateCity(@RequestBody City city) { Response updateCity(@RequestBody StudentCity studentCity) {
Response resp = new Response(); Response resp = new Response();
if (city==null) { if (studentCity ==null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("Parameter Invalid"); resp.setErrmessage("Parameter Invalid");
} else { } else {
HashMap<String, Object> ret = cityService.updateCity(city); HashMap<String, Object> ret = cityService.updateCity(studentCity);
int status = (int) ret.get("retcode"); int status = (int) ret.get("retcode");
if (200 == status) { if (200 == status) {
resp.setStatus(status); resp.setStatus(status);

@ -459,14 +459,14 @@ public class UserController {
Response updateLogInNumber(@RequestBody UserM user) { Response updateLogInNumber(@RequestBody UserM user) {
Response resp = new Response(); Response resp = new Response();
Integer userId = user.getUserId(); Integer userId = user.getUserId();
String phone = user.getPhone(); String account = user.getUserAccount();
Integer accountRole = user.getAccountRole(); Integer accountRole = user.getAccountRole();
if (userId==null) { if (userId==null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id不能为空!"); resp.setErrmessage("用户id不能为空!");
}else if(phone==null||phone==""){ }else if(account==null||account==""){
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户电话不能为空!"); resp.setErrmessage("用户账号不能为空!");
} else if(accountRole==null){ } else if(accountRole==null){
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户角色不能为空!"); resp.setErrmessage("用户角色不能为空!");

@ -521,22 +521,23 @@ public class UserInfoController {
* 更新登录次数和时间 * 更新登录次数和时间
*/ */
@PostMapping("/updateLogInNumber") @PostMapping("/updateLogInNumber")
Response updateLogInNumber(@RequestBody UserM user) { Response updateLogInNumber(@RequestBody UserInfo userInfo) {
Response resp = new Response(); Response resp = new Response();
Integer userId = user.getUserId(); Integer userId = userInfo.getUserId();
String phone = user.getPhone(); String phone = userInfo.getPhone();
Integer accountRole = user.getAccountRole(); String roleId = userInfo.getRoleId();
if (userId==null) { if (userId==null) {
resp.setStatus(300); resp.setStatus(300);
resp.setErrmessage("用户id不能为空!"); resp.setErrmessage("用户id不能为空!");
}else if(phone==null||phone==""){ // }else if(phone==null||phone==""){
resp.setStatus(300); // resp.setStatus(300);
resp.setErrmessage("用户电话不能为空!"); // resp.setErrmessage("用户电话不能为空!");
} else if(accountRole==null){ // } else if(accountRole==null){
resp.setStatus(300); // resp.setStatus(300);
resp.setErrmessage("用户角色不能为空!"); // resp.setErrmessage("用户角色不能为空!");
} else { }
HashMap<String, Object> ret = userInfoService.updateLogInNumber(user); else {
HashMap<String, Object> ret = userInfoService.updateLogInNumber(userInfo);
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,10 +3,10 @@ package com.yipin.liuwanr.entity;
/** /**
* 班级 * 班级
* *
* @author 全承珠 * @author Ning
* *
*/ */
public class SutdentClass { public class Class {
private Integer classId; private Integer classId;
private String className; private String className;
@ -38,7 +38,7 @@ public class SutdentClass {
@Override @Override
public String toString() { public String toString() {
return "SutdentClass{" + return "Class{" +
"classId=" + classId + "classId=" + classId +
", className='" + className + '\'' + ", className='" + className + '\'' +
", gradeId=" + gradeId + ", gradeId=" + gradeId +

@ -14,13 +14,13 @@ public class Grade {
private String gradeName; private String gradeName;
private Integer professionalArchitectureId; private Integer professionalArchitectureId;
private List<ExperimentalClass> experimentalClass; private List<ExperimentalClass> experimentalClass;
private List<SutdentClass> classes; private List<Class> classes;
public List<SutdentClass> getClasses() { public List<Class> getClasses() {
return classes; return classes;
} }
public void setClasses(List<SutdentClass> classes) { public void setClasses(List<Class> classes) {
this.classes = classes; this.classes = classes;
} }

@ -1,6 +1,6 @@
package com.yipin.liuwanr.entity; package com.yipin.liuwanr.entity;
public class City { public class StudentCity {
//城市主键ID //城市主键ID
private Integer cityId; private Integer cityId;
@ -29,7 +29,7 @@ public class City {
@Override @Override
public String toString() { public String toString() {
return "City{" + return "StudentCity{" +
"cityId=" + cityId + "cityId=" + cityId +
", cityName='" + cityName + '\'' + ", cityName='" + cityName + '\'' +
", provinceId=" + provinceId + ", provinceId=" + provinceId +

@ -1,9 +1,9 @@
package com.yipin.liuwanr.mapper; package com.yipin.liuwanr.mapper;
import java.util.HashMap;
import java.util.List; import java.util.List;
import com.yipin.liuwanr.entity.*; import com.yipin.liuwanr.entity.*;
import com.yipin.liuwanr.entity.Class;
import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Many; import org.apache.ibatis.annotations.Many;
@ -233,7 +233,7 @@ public interface AssesmentMapper {
* @return * @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}") @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<SutdentClass> queryClass(Integer assesmentId); List<Class> queryClass(Integer assesmentId);
//s.isdel=0 and //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} ") @Select("select s.studentId,studentName from student s left join experimental_class_student ecs on s.studentId=ecs.studentId where ecs.experimentalClassId=#{experimentalClassId} ")

@ -2,26 +2,25 @@ package com.yipin.liuwanr.mapper;
import java.util.List; import java.util.List;
import com.yipin.liuwanr.entity.StudentCity;
import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update; import org.apache.ibatis.annotations.Update;
import com.yipin.liuwanr.entity.City;
public interface CityMapper { public interface CityMapper {
@Insert("INSERT INTO city(cityName,provinceId,isdel)" @Insert("INSERT INTO studentCity(cityName,provinceId,isdel)"
+ "VALUES(#{cityName},#{provinceId},0)") + "VALUES(#{cityName},#{provinceId},0)")
void addCity(City city); void addCity(StudentCity studentCity);
@Select({"<script>", @Select({"<script>",
"SELECT cityId,cityName,provinceId from city where isdel = 0 and provinceId=#{provinceId} order by cityId ", "SELECT cityId,cityName,provinceId from city where isdel = 0 and provinceId=#{provinceId} order by cityId ",
"</script> "}) "</script> "})
List<City> queryCity(Integer provinceId); List<StudentCity> queryCity(Integer provinceId);
@Update("UPDATE city SET isdel = 1 where cityId = #{cityId}") @Update("UPDATE city SET isdel = 1 where cityId = #{cityId}")
void deleteCity(Integer cityId); void deleteCity(Integer cityId);
@Update("UPDATE city SET cityName = #{cityName} where cityId = #{cityId}") @Update("UPDATE studentCity SET cityName = #{cityName} where cityId = #{cityId}")
void updateCity(City city); void updateCity(StudentCity studentCity);
} }

@ -2,9 +2,9 @@ package com.yipin.liuwanr.mapper;
import java.util.List; import java.util.List;
import com.yipin.liuwanr.entity.Class;
import org.apache.ibatis.annotations.Select; 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 { public interface ClassMapper {
@Select("select classId,className from class where className like concat(#{className},'%') ") @Select("select classId,className from class where className like concat(#{className},'%') ")
List<SutdentClass> queryGetByClassName(String className); List<Class> queryGetByClassName(String className);
} }

@ -58,7 +58,7 @@ public interface CourseMapper {
" <if test='professionalClassId!=null'>and c.professionalClassId = #{professionalClassId} </if>", " <if test='professionalClassId!=null'>and c.professionalClassId = #{professionalClassId} </if>",
" <if test='professionalId!=null'>and c.professionalId = #{professionalId} </if>", " <if test='professionalId!=null'>and c.professionalId = #{professionalId} </if>",
" <if test='searchContent!=null'> and c.courseName like CONCAT('%',#{searchContent},'%')</if>", " <if test='searchContent!=null'> and c.courseName like CONCAT('%',#{searchContent},'%')</if>",
"GROUP BY courseId", "GROUP BY c.courseId",
"order by c.creationTime desc", "order by c.creationTime desc",
"</script> "}) "</script> "})
List<Course> queryCourse(Course course); List<Course> queryCourse(Course course);

@ -2,6 +2,7 @@ package com.yipin.liuwanr.mapper;
import java.util.List; import java.util.List;
import com.yipin.liuwanr.entity.Class;
import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options; import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select; 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.Grade;
import com.yipin.liuwanr.entity.StuProfessionalArchitecture; import com.yipin.liuwanr.entity.StuProfessionalArchitecture;
import com.yipin.liuwanr.entity.Student; import com.yipin.liuwanr.entity.Student;
import com.yipin.liuwanr.entity.SutdentClass;
public interface StuProfessionalArchitectureMapper { public interface StuProfessionalArchitectureMapper {
@ -55,12 +55,12 @@ public interface StuProfessionalArchitectureMapper {
@Select({"<script>", @Select({"<script>",
"SELECT classId,className from class where gradeId = #{gradeId} and isdel = 0", "SELECT classId,className from class where gradeId = #{gradeId} and isdel = 0",
"</script> "}) "</script> "})
List<SutdentClass> queryStuClass(Integer gradeId); List<Class> queryStuClass(Integer gradeId);
@Select({"<script>", @Select({"<script>",
"SELECT classId,className from class where classId = #{classId}", "SELECT classId,className from class where classId = #{classId}",
"</script> "}) "</script> "})
List<SutdentClass> queryStuClassD(Integer classId); List<Class> queryStuClassD(Integer classId);
@Insert("INSERT INTO class(className,gradeId)" @Insert("INSERT INTO class(className,gradeId)"
+ "VALUES(#{className},#{gradeId})") + "VALUES(#{className},#{gradeId})")

@ -262,8 +262,8 @@ public interface UserInfoMapper {
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}"}) @Update({"UPDATE hr_user_info SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE userId=#{userId}"})
void updateLogInNumber(UserM user); void updateLogInNumber(UserInfo userInfo);
//更新学生登录次数和最后一次登录时间 //更新学生登录次数和最后一次登录时间
@Update({"UPDATE student SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE phone=#{phone}"}) @Update({"UPDATE student SET logInNumber=logInNumber+1, lastLoginTime=now() WHERE phone=#{phone}"})

@ -263,11 +263,11 @@ public interface UserMapper {
void updateLogInNumber(UserM user); 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); 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); void updateStaffLogInNumber(UserM user);
//查询账号是否存在 //查询账号是否存在

@ -19,10 +19,9 @@ import com.yipin.liuwanr.entity.PointRecord;
import com.yipin.liuwanr.entity.Record; import com.yipin.liuwanr.entity.Record;
import com.yipin.liuwanr.entity.Score; import com.yipin.liuwanr.entity.Score;
import com.yipin.liuwanr.entity.Student; 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.helper.AssesmentHelper;
import com.yipin.liuwanr.mapper.AssesmentMapper; import com.yipin.liuwanr.mapper.AssesmentMapper;
import com.yipin.liuwanr.vo.AssesmentStudentVo;
@Service @Service
public class AssesmentService { public class AssesmentService {
@ -383,7 +382,7 @@ public class AssesmentService {
HashMap<String, Object> obj = new HashMap<String, Object>(); HashMap<String, Object> obj = new HashMap<String, Object>();
try { try {
List<ExperimentalClass> experimentalClasses = mapper.queryExperimental(assesmentId); List<ExperimentalClass> experimentalClasses = mapper.queryExperimental(assesmentId);
List<SutdentClass> classes = mapper.queryClass(assesmentId); List<Class> classes = mapper.queryClass(assesmentId);
obj.put("experimentalClass", experimentalClasses); obj.put("experimentalClass", experimentalClasses);
obj.put("class", classes); obj.put("class", classes);

@ -2,11 +2,11 @@ package com.yipin.liuwanr.service;
import java.util.HashMap; import java.util.HashMap;
import com.yipin.liuwanr.entity.StudentCity;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
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 com.yipin.liuwanr.entity.City;
import com.yipin.liuwanr.mapper.CityMapper; import com.yipin.liuwanr.mapper.CityMapper;
@Service @Service
@ -17,10 +17,10 @@ public class CityService {
@Autowired @Autowired
private CityMapper cityMapper; private CityMapper cityMapper;
public HashMap<String, Object> addCity(City city){ public HashMap<String, Object> addCity(StudentCity studentCity){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
cityMapper.addCity(city); cityMapper.addCity(studentCity);
resp.put("retcode", 200); resp.put("retcode", 200);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());
@ -60,10 +60,10 @@ public class CityService {
return resp; return resp;
} }
public HashMap<String, Object> updateCity(City city){ public HashMap<String, Object> updateCity(StudentCity studentCity){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
cityMapper.updateCity(city); cityMapper.updateCity(studentCity);
resp.put("retcode", 200); resp.put("retcode", 200);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());

@ -449,7 +449,8 @@ public class UserInfoService {
List<Student> studentList = userInfoMapper.queryStudentAll(id,roleId,schoolId); List<Student> studentList = userInfoMapper.queryStudentAll(id,roleId,schoolId);
obj.put("studentList",studentList); obj.put("studentList",studentList);
ValueOperations<String, String> redis = stringRedisTemplate.opsForValue(); ValueOperations<String, String> 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("retcode", 200);
resp.put("retvalue", obj); resp.put("retvalue", obj);
}else { }else {
@ -611,19 +612,19 @@ public class UserInfoService {
} }
//更新登录次数和时间 //更新登录次数和时间
public HashMap<String, Object> updateLogInNumber(UserM user){ public HashMap<String, Object> updateLogInNumber(UserInfo userInfo){
HashMap<String, Object> resp = new HashMap<String, Object>(); HashMap<String, Object> resp = new HashMap<String, Object>();
try { try {
Integer accountRole = user.getAccountRole(); // Integer accountRole = user.getAccountRole();
userInfoMapper.updateLogInNumber(user); userInfoMapper.updateLogInNumber(userInfo);
if (accountRole==3){ // if (accountRole==3){
//更新员工登录次数和时间 // //更新员工登录次数和时间
userInfoMapper.updateStaffLogInNumber(user); // userInfoMapper.updateStaffLogInNumber(user);
} // }
if (accountRole==4){ // if (accountRole==4){
//更新学生登录次数和时间 // //更新学生登录次数和时间
userInfoMapper.updateStudentLogInNumber(user); // userInfoMapper.updateStudentLogInNumber(user);
} // }
resp.put("retcode", 200); resp.put("retcode", 200);
} catch (RuntimeException e) { } catch (RuntimeException e) {
logger.error(e.getMessage()); logger.error(e.getMessage());

@ -1,6 +1,6 @@
package com.yipin.liuwanr; 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.mapper.CityMapper;
import com.yipin.liuwanr.service.CityService; import com.yipin.liuwanr.service.CityService;
import org.junit.Test; import org.junit.Test;
@ -29,7 +29,7 @@ public class CityServiceTest {
/*@Test /*@Test
@Transactional @Transactional
public void testAddCity() { public void testAddCity() {
City city = new City(); StudentCity city = new StudentCity();
city.setCityName("hhhh"); city.setCityName("hhhh");
city.setProvinceId(2); city.setProvinceId(2);
HashMap<String, Object> map = cityService.addCity(city); HashMap<String, Object> map = cityService.addCity(city);
@ -45,7 +45,7 @@ public class CityServiceTest {
Integer retcode = (Integer) map.get("retcode"); Integer retcode = (Integer) map.get("retcode");
System.out.println(retcode); System.out.println(retcode);
if (retcode == 200) { if (retcode == 200) {
List<City> cities = (List<City>) map.get("retvalue"); List<StudentCity> cities = (List<StudentCity>) map.get("retvalue");
cities.forEach(item -> { cities.forEach(item -> {
System.out.println(item.toString()); System.out.println(item.toString());
}); });
@ -71,11 +71,11 @@ public class CityServiceTest {
@Test @Test
@Transactional @Transactional
public void testUpdateCity() { public void testUpdateCity() {
City city = new City(); StudentCity studentCity = new StudentCity();
city.setCityId(1); studentCity.setCityId(1);
city.setCityName("hhhh"); studentCity.setCityName("hhhh");
city.setProvinceId(2); studentCity.setProvinceId(2);
HashMap<String, Object> map = cityService.updateCity(city); HashMap<String, Object> map = cityService.updateCity(studentCity);
map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString())); map.forEach((key, value) -> System.out.println("key = " + key + " ===> value = " + value.toString()));
} }
} }

@ -1,6 +1,6 @@
package com.yipin.liuwanr; package com.yipin.liuwanr;
import com.yipin.liuwanr.entity.SutdentClass; import com.yipin.liuwanr.entity.Class;
import com.yipin.liuwanr.service.ClassService; import com.yipin.liuwanr.service.ClassService;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -24,7 +24,7 @@ public class ClassServiceTest {
Integer retcode = (Integer) map.get("retcode"); Integer retcode = (Integer) map.get("retcode");
System.out.println(retcode); System.out.println(retcode);
if (retcode == 200) { if (retcode == 200) {
List<SutdentClass> classes = (List<SutdentClass>) map.get("retvalue"); List<Class> classes = (List<Class>) map.get("retvalue");
classes.forEach(item -> { classes.forEach(item -> {
System.out.println(item.toString()); System.out.println(item.toString());
}); });

Loading…
Cancel
Save