管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2022-10-17 431af122d22e9be757510ca75e268c164d16a450
1
已修改8个文件
79 ■■■■■ 文件已修改
data/db_tab.sql 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/all/SignController.java 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/controller/sys/UserController.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/entity/sys/AttachEntity.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/interceptor/AuthInterceptor.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/sys/TokenService.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/lf/server/service/sys/UserService.java 29 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/sys/AttachMapper.xml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
data/db_tab.sql
@@ -609,6 +609,7 @@
  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,
@@ -627,8 +628,9 @@
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(
src/main/java/com/lf/server/controller/all/SignController.java
@@ -1,6 +1,5 @@
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;
@@ -17,8 +16,6 @@
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;
src/main/java/com/lf/server/controller/sys/UserController.java
@@ -217,7 +217,6 @@
                if (str != null) {
                    return fail(str, -1);
                }
                if (ue != null) {
                    entity.setCreateUser(ue.getId());
                }
src/main/java/com/lf/server/entity/sys/AttachEntity.java
@@ -16,6 +16,8 @@
    private String tab;
    private String tabGuid;
    private String guid;
    private String path;
@@ -55,6 +57,14 @@
        this.tab = tab;
    }
    public String getTabGuid() {
        return tabGuid;
    }
    public void setTabGuid(String tabGuid) {
        this.tabGuid = tabGuid;
    }
    public String getGuid() {
        return guid;
    }
src/main/java/com/lf/server/interceptor/AuthInterceptor.java
@@ -31,6 +31,8 @@
    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;
    }
@@ -64,7 +66,7 @@
            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
src/main/java/com/lf/server/service/sys/TokenService.java
@@ -145,12 +145,6 @@
        // 清除Cookie
        WebHelper.deleteCookies(req, res);
        // 获取当前用户
        UserEntity ue = getCurrentUser(req);
        if (ue == null) {
            return false;
        }
        // 清除缓存
        String tokenKey = RedisCacheKey.signTokenKey(token);
        if (redisService.hasKey(tokenKey)) {
@@ -159,6 +153,12 @@
        String userKey = RedisCacheKey.signUserKey(te.getToken());
        if (redisService.hasKey(userKey)) {
            redisService.delete(userKey);
        }
        // 获取当前用户
        UserEntity ue = getCurrentUser(req);
        if (ue == null) {
            return false;
        }
        // db,设置令牌过期
@@ -264,9 +264,5 @@
        Object objCount = redisService.get(key);
        return objCount != null && (int) objCount >= SettingData.PWD_ERR_COUNT;
    }
    public void logoffToken(String token) {
        //
    }
}
src/main/java/com/lf/server/service/sys/UserService.java
@@ -1,7 +1,5 @@
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;
@@ -9,11 +7,9 @@
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;
/**
 * 用户表
@@ -28,6 +24,12 @@
    @Autowired
    RedisService redisService;
    @Autowired
    LoginService loginService;
    @Autowired
    TokenService tokenService;
    @Override
    public Integer selectCount(String uname) {
@@ -141,9 +143,13 @@
            entity.setUid(uid);
            entity.setPwd(pwd);
            if (tokenService.isUidDisable(entity)) {
                return "用户ID已禁用";
            }
            return null;
        } catch (Exception ex) {
            return "密码解密失败";
            return "解密失败";
        }
    }
@@ -170,7 +176,7 @@
            return null;
        } catch (Exception ex) {
            return "密码解密失败";
            return "解密失败";
        }
    }
@@ -196,8 +202,8 @@
                return "没有找到用户";
            }
            if (!Md5Helper.validatePassword(pwd, ue.getPwd())) {
                //
                return "旧密码输入错误";
                tokenService.setPwdErrCache(ue);
                return "旧密码不正确";
            }
            if (!StringHelper.checkPwdValid(salt)) {
                return "密码不符合要求";
@@ -210,7 +216,7 @@
            return null;
        } catch (Exception ex) {
            return "密码解密失败";
            return "解密失败";
        }
    }
@@ -228,12 +234,13 @@
        try {
            String pwd = RsaHelper.decrypt(adminPwd);
            if (!Md5Helper.validatePassword(pwd, ue.getPwd())) {
                tokenService.setPwdErrCache(ue);
                return "管理员密码不正确";
            }
            return null;
        } catch (Exception ex) {
            return "密码解密失败";
            return "解密失败";
        }
    }
@@ -256,7 +263,7 @@
            return null;
        } catch (Exception ex) {
            return "密码解密失败";
            return "解密失败";
        }
    }
}
src/main/resources/mapper/sys/AttachMapper.xml
@@ -35,17 +35,17 @@
    <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>
@@ -62,7 +62,7 @@
    <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>
@@ -70,7 +70,7 @@
        <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>