| | |
| | | id serial primary key, |
| | | name varchar(256), |
| | | tab varchar(100), |
| | | tab_guid varchar(40), |
| | | guid varchar(40) default new_guid(), |
| | | path varchar(512), |
| | | create_user integer default 1, |
| | |
| | | comment on column lf.sys_attach.update_user is '更新人ID'; |
| | | comment on column lf.sys_attach.update_time is '更新时间'; |
| | | --insert into lf.sys_attach (name,tab,path) values ('a.jpg','public.data_dir','c:\a.jpg'); |
| | | --alter table lf.sys_attach add tab_guid varchar(40); |
| | | |
| | | select length(guid) from lf.sys_attach limit 1; select * from lf.sys_attach; |
| | | select * from lf.sys_attach; select length(guid) from lf.sys_attach limit 1; select * from lf.sys_attach; |
| | | ----------------------------------------------------------------------------------------------------- 19.版本表 |
| | | -- DROP TABLE IF EXISTS lf.sys_ver; |
| | | create table lf.sys_ver( |
| | |
| | | package com.lf.server.controller.all; |
| | | |
| | | import com.lf.server.aspect.LogAspect; |
| | | import com.lf.server.aspect.SysLog; |
| | | import com.lf.server.config.PropertiesConfig; |
| | | import com.lf.server.entity.all.ResponseMsg; |
| | |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.logging.Log; |
| | | import org.apache.commons.logging.LogFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | |
| | | if (str != null) { |
| | | return fail(str, -1); |
| | | } |
| | | |
| | | if (ue != null) { |
| | | entity.setCreateUser(ue.getId()); |
| | | } |
| | |
| | | |
| | | private String tab; |
| | | |
| | | private String tabGuid; |
| | | |
| | | private String guid; |
| | | |
| | | private String path; |
| | |
| | | this.tab = tab; |
| | | } |
| | | |
| | | public String getTabGuid() { |
| | | return tabGuid; |
| | | } |
| | | |
| | | public void setTabGuid(String tabGuid) { |
| | | this.tabGuid = tabGuid; |
| | | } |
| | | |
| | | public String getGuid() { |
| | | return guid; |
| | | } |
| | |
| | | |
| | | private static final String NO_LOGIN = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.NO_LOGIN_ERROR, "用户未登录")); |
| | | |
| | | private static final String USER_LOCK = JSON.toJSONString(new ResponseMsg<String>(HttpStatus.USER_LOCK_ERROR, "用户ID已禁用")); |
| | | |
| | | public AuthInterceptor(TokenService tokenService) { |
| | | this.tokenService = tokenService; |
| | | } |
| | |
| | | |
| | | if (tokenService.isUidDisable(ue)) { |
| | | tokenService.logout(token, request, response); |
| | | return WebHelper.write2Page(response, JSON.toJSONString(new ResponseMsg<String>(HttpStatus.USER_LOCK_ERROR, SettingData.PWD_ERR_TIME + "分钟内禁止登录"))); |
| | | return WebHelper.write2Page(response, USER_LOCK); |
| | | } |
| | | |
| | | // noinspection AlibabaRemoveCommentedCode |
| | |
| | | // 清除Cookie |
| | | WebHelper.deleteCookies(req, res); |
| | | |
| | | // 获取当前用户 |
| | | UserEntity ue = getCurrentUser(req); |
| | | if (ue == null) { |
| | | return false; |
| | | } |
| | | |
| | | // 清除缓存 |
| | | String tokenKey = RedisCacheKey.signTokenKey(token); |
| | | if (redisService.hasKey(tokenKey)) { |
| | |
| | | String userKey = RedisCacheKey.signUserKey(te.getToken()); |
| | | if (redisService.hasKey(userKey)) { |
| | | redisService.delete(userKey); |
| | | } |
| | | |
| | | // 获取当前用户 |
| | | UserEntity ue = getCurrentUser(req); |
| | | if (ue == null) { |
| | | return false; |
| | | } |
| | | |
| | | // db,设置令牌过期 |
| | |
| | | Object objCount = redisService.get(key); |
| | | |
| | | return objCount != null && (int) objCount >= SettingData.PWD_ERR_COUNT; |
| | | } |
| | | |
| | | public void logoffToken(String token) { |
| | | // |
| | | } |
| | | } |
| | |
| | | package com.lf.server.service.sys; |
| | | |
| | | import com.lf.server.entity.all.RedisCacheKey; |
| | | import com.lf.server.entity.all.SettingData; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.Md5Helper; |
| | | import com.lf.server.helper.RsaHelper; |
| | |
| | | import com.lf.server.mapper.sys.UserMapper; |
| | | import com.lf.server.service.all.RedisService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.cache.RedisCache; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * 用户表 |
| | |
| | | |
| | | @Autowired |
| | | RedisService redisService; |
| | | |
| | | @Autowired |
| | | LoginService loginService; |
| | | |
| | | @Autowired |
| | | TokenService tokenService; |
| | | |
| | | @Override |
| | | public Integer selectCount(String uname) { |
| | |
| | | entity.setUid(uid); |
| | | entity.setPwd(pwd); |
| | | |
| | | if (tokenService.isUidDisable(entity)) { |
| | | return "用户ID已禁用"; |
| | | } |
| | | |
| | | return null; |
| | | } catch (Exception ex) { |
| | | return "密码解密失败"; |
| | | return "解密失败"; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return null; |
| | | } catch (Exception ex) { |
| | | return "密码解密失败"; |
| | | return "解密失败"; |
| | | } |
| | | } |
| | | |
| | |
| | | return "没有找到用户"; |
| | | } |
| | | if (!Md5Helper.validatePassword(pwd, ue.getPwd())) { |
| | | // |
| | | return "旧密码输入错误"; |
| | | tokenService.setPwdErrCache(ue); |
| | | return "旧密码不正确"; |
| | | } |
| | | if (!StringHelper.checkPwdValid(salt)) { |
| | | return "密码不符合要求"; |
| | |
| | | |
| | | return null; |
| | | } catch (Exception ex) { |
| | | return "密码解密失败"; |
| | | return "解密失败"; |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | String pwd = RsaHelper.decrypt(adminPwd); |
| | | if (!Md5Helper.validatePassword(pwd, ue.getPwd())) { |
| | | tokenService.setPwdErrCache(ue); |
| | | return "管理员密码不正确"; |
| | | } |
| | | |
| | | return null; |
| | | } catch (Exception ex) { |
| | | return "密码解密失败"; |
| | | return "解密失败"; |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return null; |
| | | } catch (Exception ex) { |
| | | return "密码解密失败"; |
| | | return "解密失败"; |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | <insert id="insert" parameterType="com.lf.server.entity.sys.AttachEntity"> |
| | | insert into lf.sys_attach |
| | | (name,tab,guid,path,create_user,create_time) |
| | | (name,tab,tab_guid,guid,path,create_user,create_time) |
| | | values |
| | | (#{name},#{tab},#{guid},#{path},#{createUser},now()) |
| | | (#{name},#{tab},#{tabGuid},#{guid},#{path},#{createUser},now()) |
| | | </insert> |
| | | |
| | | <insert id="inserts"> |
| | | insert into lf.sys_attach |
| | | (name,tab,guid,path,create_user,create_time) |
| | | (name,tab,tab_guid,guid,path,create_user,create_time) |
| | | values |
| | | <foreach collection="list" item="item" index="index" separator=","> |
| | | (#{item.name},#{item.tab},#{item.guid},#{item.path},#{item.createUser},now()) |
| | | (#{item.name},#{item.tab},#{item.tabGuid},#{item.guid},#{item.path},#{item.createUser},now()) |
| | | </foreach> |
| | | </insert> |
| | | |
| | |
| | | |
| | | <update id="update"> |
| | | update lf.sys_attach |
| | | set name=#{name},tab=#{tab},guid=#{guid},path=#{path},update_user=#{updateUser},update_time=now() |
| | | set name=#{name},tab=#{tab},tab_guid=#{tabGuid},guid=#{guid},path=#{path},update_user=#{updateUser},update_time=now() |
| | | where id=#{id} |
| | | </update> |
| | | |
| | |
| | | <foreach collection="list" item="item" index="index" separator=";"> |
| | | update lf.sys_attach |
| | | <set> |
| | | name=#{item.name},tab=#{item.tab},guid=#{item.guid},path=#{item.path},update_user=#{item.updateUser},update_time=now() |
| | | name=#{item.name},tab=#{item.tab},tab_guid=#{item.tabGuid},guid=#{item.guid},path=#{item.path},update_user=#{item.updateUser},update_time=now() |
| | | </set> |
| | | where id = #{item.id} |
| | | </foreach> |