Commit 91c3182506eb34eed9f6e04a6718e58ef3de18dc

Authored by guzijian
1 parent 4b54669e

fix: reset config

ruoyi-admin/src/main/java/com/ruoyi/in/domain/SignIn.java
1 1 package com.ruoyi.in.domain;
2 2  
  3 +import java.io.UnsupportedEncodingException;
3 4 import java.math.BigDecimal;
4 5 import org.apache.commons.lang3.builder.ToStringBuilder;
5 6 import org.apache.commons.lang3.builder.ToStringStyle;
... ... @@ -31,6 +32,24 @@ public class SignIn extends BaseEntity
31 32 @Excel(name = "图片")
32 33 private String image;
33 34  
  35 + private byte [] content;
  36 +
  37 + public byte[] getContent(){
  38 + if(image==null){
  39 + return null;
  40 + }
  41 + try {
  42 + return image.getBytes("UTF-8");
  43 + } catch (UnsupportedEncodingException e) {
  44 + e.printStackTrace();
  45 + }
  46 + return null;
  47 + }
  48 +
  49 + public void setContent(byte [] content) {
  50 + this.content = content;
  51 + }
  52 +
34 53 /** 签到结果 */
35 54 @Excel(name = "签到结果")
36 55 private Integer status;
... ...
ruoyi-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
... ... @@ -69,7 +69,6 @@ public class SignInServiceImpl implements ISignInService
69 69 @Override
70 70 public int updateSignIn(SignIn signIn)
71 71 {
72   - signIn.setUpdateBy(SecurityUtils.getUsername());
73 72 signIn.setUpdateTime(DateUtils.getNowDate());
74 73 return signInMapper.updateSignIn(signIn);
75 74 }
... ...
ruoyi-admin/src/main/resources/mapper/in/SignInMapper.xml
... ... @@ -63,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
63 63 <if test="createTime != null">#{createTime},</if>
64 64 <if test="jobCode != null">#{jobCode},</if>
65 65 <if test="ip != null">#{ip},</if>
66   - <if test="image != null">#{image},</if>
  66 + <if test="image != null">#{content},</if>
67 67 <if test="status != null">#{status},</if>
68 68 <if test="updateBy != null">#{updateBy},</if>
69 69 <if test="singnIn != null">#{singnIn},</if>
... ...
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
... ... @@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
111 111 // 过滤请求
112 112 .authorizeRequests()
113 113 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
114   - .antMatchers("/ceshi/**","/login", "/register", "/captchaImage").permitAll()
  114 + .antMatchers("/**","/login", "/register", "/captchaImage").permitAll()
115 115 // 静态资源,可匿名访问
116 116 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
117 117 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
... ...
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
... ... @@ -97,13 +97,10 @@ public class SysLoginService
97 97 LoginUser loginUser = (LoginUser) authentication.getPrincipal();
98 98 recordLoginInfo(loginUser.getUserId());
99 99 // 返回数据库中token
100   - return getUserToken(loginUser.getUserId());
  100 + return tokenService.createToken(loginUser);
101 101 }
102 102  
103   - private String getUserToken(Long userId) {
104   - SysUser sysUser = userService.selectUserById(userId);
105   - return sysUser.getRemark();
106   - }
  103 +
107 104  
108 105 /**
109 106 * 校验验证码
... ...
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java
... ... @@ -4,6 +4,9 @@ import java.util.HashMap;
4 4 import java.util.Map;
5 5 import java.util.concurrent.TimeUnit;
6 6 import javax.servlet.http.HttpServletRequest;
  7 +
  8 +import com.ruoyi.common.core.domain.entity.SysUser;
  9 +import com.ruoyi.system.service.ISysUserService;
7 10 import org.springframework.beans.factory.annotation.Autowired;
8 11 import org.springframework.beans.factory.annotation.Value;
9 12 import org.springframework.stereotype.Component;
... ... @@ -48,6 +51,9 @@ public class TokenService
48 51 private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L;
49 52  
50 53 @Autowired
  54 + private ISysUserService userService;
  55 +
  56 + @Autowired
51 57 private RedisCache redisCache;
52 58  
53 59 /**
... ... @@ -119,6 +125,29 @@ public class TokenService
119 125 }
120 126  
121 127 /**
  128 + * 创建令牌
  129 + *
  130 + * @param loginUser 用户信息
  131 + * @return 令牌
  132 + */
  133 + public String getLocalToken(LoginUser loginUser)
  134 + {
  135 + String token = IdUtils.fastUUID();
  136 + loginUser.setToken(token);
  137 + setUserAgent(loginUser);
  138 + refreshToken(loginUser);
  139 +
  140 + Map<String, Object> claims = new HashMap<>();
  141 + claims.put(Constants.LOGIN_USER_KEY, token);
  142 + return getUserToken(loginUser.getUserId());
  143 + }
  144 + private String getUserToken(Long userId) {
  145 + SysUser sysUser = userService.selectUserById(userId);
  146 + return sysUser.getRemark();
  147 + }
  148 +
  149 +
  150 + /**
122 151 * 验证令牌有效期,相差不足20分钟,自动刷新缓存
123 152 *
124 153 * @param loginUser
... ... @@ -145,8 +174,7 @@ public class TokenService
145 174 loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
146 175 // 根据uuid将loginUser缓存
147 176 String userKey = getTokenKey(loginUser.getToken());
148   -// redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
149   - redisCache.setCacheObject(userKey, loginUser);
  177 + redisCache.setCacheObject(userKey, loginUser, expireTime, TimeUnit.MINUTES);
150 178 }
151 179  
152 180 /**
... ...