whycxzp
2021-10-18 1ac311015e102ac1f259e7b98d76c29c141b7fdb
提交
1 文件已重命名
2个文件已添加
6个文件已修改
308 ■■■■ 已修改文件
src/main/java/com/whyc/App.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/constant/RoleEnum.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/Menu.java 49 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/pojo/User.java 178 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/realm/CustomRealm.java 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/UserBridgeService.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/service/UserService.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/swagger/SwaggerConfig4Knife.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/util/CipherUtil.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/whyc/App.java
File was renamed from src/main/java/com/whyc/Application.java
@@ -4,13 +4,9 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
/**
 * @Description : 启动类
@@ -20,10 +16,10 @@
@EnableWebMvc
@ServletComponentScan(basePackages = {"com.whyc.filter","com.whyc.servlet"})
@EnableCaching
public class Application extends WebMvcConfigurerAdapter  implements WebMvcConfigurer {
public class App extends WebMvcConfigurerAdapter  implements WebMvcConfigurer {
    public static void main(String[] args) {
        SpringApplication.run(Application.class,args);
        SpringApplication.run(App.class,args);
    }
}
src/main/java/com/whyc/constant/RoleEnum.java
New file
@@ -0,0 +1,33 @@
package com.whyc.constant;
/**角色*/
public enum RoleEnum {
    ADMIN(0,"管理员"),
    GROUP_LEADER(1,"维护组长"),
    GROUP_MEMBER(2,"维护组员"),
    LEADER(10,"领导");
    RoleEnum(Integer id, String name) {
        this.id = id;
        this.name = name;
    }
    private Integer id;
    private String name;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
}
src/main/java/com/whyc/pojo/Menu.java
@@ -1,7 +1,13 @@
package com.whyc.pojo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.ibatis.type.Alias;
import org.springframework.scheduling.annotation.Scheduled;
import java.util.Date;
/**
 * 用户菜单
@@ -9,52 +15,9 @@
@Alias("Menu")
@TableName( schema = "`db_3.5mw_web`",value = "`tb_menu`")
public class Menu {
    private Integer id;
    private String name;
    /**菜单的路径*/
    private String url;
    /**级别:1级,2级菜单...*/
    private String level;
    /**排序*/
    private Integer order;
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public String getLevel() {
        return level;
    }
    public void setLevel(String level) {
        this.level = level;
    }
    public Integer getOrder() {
        return order;
    }
    public void setOrder(Integer order) {
        this.order = order;
    }
}
src/main/java/com/whyc/pojo/User.java
@@ -1,6 +1,7 @@
package com.whyc.pojo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.*;
@@ -8,23 +9,59 @@
import java.util.Date;
@Alias("User")
@TableName( schema = "`db_3.5mw_web`",value = "tb_user")
@TableName( schema = "`db_user`",value = "tb_user_inf")
public class User {
    @TableId("uId")
    private Integer id;
    @TableField("uSnId")
    private Integer snId;
    @TableField("name")
    private String name;
    private String password;
    private String salt;
    @TableField("uShenFenId")
    private Integer idCard;
    @TableField("uEmployeeId")
    private String employeeId;
    @TableField("uMobilephone")
    private String mobilePhone;
    @TableField("uEmail")
    private String email;
    /**录入时间*/
    @TableField("uAccessionDay")
    @JsonFormat(locale = "zh",timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;
    private Date accessDay;
    @TableField("uSex")
    private String sex;
    /**维护区*/
    @TableField("uDepartment")
    private String department;
    /**工作组*/
    @TableField("uJobGroup")
    private String jobGroup;
    /**包机人*/
    @TableField("uBaojiUsr")
    private Integer baojiUser;
    @TableField("upassword")
    private String password;
    @TableField("uPubKeyX")
    private String pubKeyX;
    @TableField("uPubKeyY")
    private String pubKeyY;
    @TableField("uKey_ID")
    private String keyId;
    public User() {
    }
    private Integer faceId;
    private Integer loginType;
    /**
     * 枚举
     * @see com.whyc.constant.RoleEnum
     */
    @TableField("uRole")
    private Integer role;
    public User(Integer id, String name) {
        this.id = id;
        this.name = name;
    }
    public Integer getId() {
        return id;
@@ -32,6 +69,14 @@
    public void setId(Integer id) {
        this.id = id;
    }
    public Integer getSnId() {
        return snId;
    }
    public void setSnId(Integer snId) {
        this.snId = snId;
    }
    public String getName() {
@@ -42,6 +87,78 @@
        this.name = name;
    }
    public Integer getIdCard() {
        return idCard;
    }
    public void setIdCard(Integer idCard) {
        this.idCard = idCard;
    }
    public String getEmployeeId() {
        return employeeId;
    }
    public void setEmployeeId(String employeeId) {
        this.employeeId = employeeId;
    }
    public String getMobilePhone() {
        return mobilePhone;
    }
    public void setMobilePhone(String mobilePhone) {
        this.mobilePhone = mobilePhone;
    }
    public String getEmail() {
        return email;
    }
    public void setEmail(String email) {
        this.email = email;
    }
    public Date getAccessDay() {
        return accessDay;
    }
    public void setAccessDay(Date accessDay) {
        this.accessDay = accessDay;
    }
    public String getSex() {
        return sex;
    }
    public void setSex(String sex) {
        this.sex = sex;
    }
    public String getDepartment() {
        return department;
    }
    public void setDepartment(String department) {
        this.department = department;
    }
    public String getJobGroup() {
        return jobGroup;
    }
    public void setJobGroup(String jobGroup) {
        this.jobGroup = jobGroup;
    }
    public Integer getBaojiUser() {
        return baojiUser;
    }
    public void setBaojiUser(Integer baojiUser) {
        this.baojiUser = baojiUser;
    }
    public String getPassword() {
        return password;
    }
@@ -50,20 +167,51 @@
        this.password = password;
    }
    public String getSalt() {
        return salt;
    public String getPubKeyX() {
        return pubKeyX;
    }
    public void setSalt(String salt) {
        this.salt = salt;
    public void setPubKeyX(String pubKeyX) {
        this.pubKeyX = pubKeyX;
    }
    public Date getCreateTime() {
        return createTime;
    public String getPubKeyY() {
        return pubKeyY;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    public void setPubKeyY(String pubKeyY) {
        this.pubKeyY = pubKeyY;
    }
    public String getKeyId() {
        return keyId;
    }
    public void setKeyId(String keyId) {
        this.keyId = keyId;
    }
    public Integer getFaceId() {
        return faceId;
    }
    public void setFaceId(Integer faceId) {
        this.faceId = faceId;
    }
    public Integer getLoginType() {
        return loginType;
    }
    public void setLoginType(Integer loginType) {
        this.loginType = loginType;
    }
    public Integer getRole() {
        return role;
    }
    public void setRole(Integer role) {
        this.role = role;
    }
}
src/main/java/com/whyc/realm/CustomRealm.java
@@ -32,13 +32,13 @@
    @Override
    protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authenticationToken) throws AuthenticationException {
        String userName = (String) authenticationToken.getPrincipal();
        User user = userBridgeService.findPasswordAndSlatByUserName(userName);
        User user = userBridgeService.findPasswordByUserName(userName);
        if(user.getId()==0){
            System.out.printf("账号不存在");
            throw new UnknownAccountException("账号不存在");
        }
        return new SimpleAuthenticationInfo(user,user.getPassword(), ByteSource.Util.bytes(user.getSalt()),getName());
        return new SimpleAuthenticationInfo(user,user.getPassword(),getName());
    }
    /**
@@ -51,10 +51,10 @@
    }
    /**加密*/
    @PostConstruct
    /*@PostConstruct
    public void initCredentialsMatcher() {
        HashedCredentialsMatcher matcher = new HashedCredentialsMatcher(SuperConstant.HASH_ALGORITHM);
        matcher.setHashIterations(SuperConstant.HASH_INTERATIONS);
        setCredentialsMatcher(matcher);
    }
    }*/
}
src/main/java/com/whyc/service/UserBridgeService.java
@@ -45,9 +45,9 @@
    @Resource
    private CacheManager caffeineCacheManager;
    public User findPasswordAndSlatByUserName(String userName) {
    public User findPasswordByUserName(String userName) {
        QueryWrapper<User> queryWrapper = Wrappers.query();
        queryWrapper.select("id","name","password","salt").eq("name",userName);
        queryWrapper.select("uId","uName","upassword").eq("uName",userName);
        try{
            return userMapper.selectOne(queryWrapper);
        }catch (Exception e){
src/main/java/com/whyc/service/UserService.java
@@ -31,14 +31,13 @@
    public Response add(User user) {
        try {
            User userFound = userBridgeService.findPasswordAndSlatByUserName(user.getName());
            User userFound = userBridgeService.findPasswordByUserName(user.getName());
            if (userFound.getId() != 0) {
                return new Response<>().set(1, false, "用户已存在");
            }
            user.setCreateTime(new Date());
            //user.setCreateTime(new Date());
            Map<String, String> encryptMap = DigestsUtil.encryptPassword(user.getPassword());
            user.setPassword(encryptMap.get("password"));
            user.setSalt(encryptMap.get("salt"));
            if (userMapper.insert(user) > 0) {
                return new Response<>().set(1, true);
            } else {
src/main/java/com/whyc/swagger/SwaggerConfig4Knife.java
@@ -22,7 +22,7 @@
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .groupName("通用框架平台")
                .groupName("fg蓄电池监控平台v2.0")
                .select()
                .apis(RequestHandlerSelectors.any())
                .apis(RequestHandlerSelectors.basePackage("com.whyc.controller"))
@@ -31,9 +31,9 @@
    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("通用框架平台")               //大标题 title
                .title("fg蓄电池监控平台v2.0")               //大标题 title
                .contact(new Contact("PerryHsu","todo","todo"))
                .description("通用框架平台,请根据具体应用平台修改名称")             //小标题
                .description("fg蓄电池监控平台v2.0")             //小标题
                .version("1.0")                           //版本
//                .termsOfServiceUrl("http://xxx.xxx.com")    //终端服务程序
//                .license("LICENSE")                         //链接显示文字
src/main/java/com/whyc/util/CipherUtil.java
New file
@@ -0,0 +1,17 @@
package com.whyc.util;
import org.apache.commons.codec.digest.DigestUtils;
/**加密相关*/
public class CipherUtil {
    /**MD5对称加密*/
    public static Object encryptMD5(Object obj){
        String md5=null;
        if(obj!=null && obj.toString().length()>0){
            md5= DigestUtils.md5Hex(obj.toString());
        }
        return md5;
    }
}