Commit c144e9f0 by songzhenmin

feat:密码强校验设置

parent 2cedafc4
package com.hs.admin.controller;
import com.hs.admin.common.Result;
import com.hs.admin.model.reqmodel.SysConfigReq;
import com.hs.admin.service.SysConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "系统配置 Api")
@RestController
public class SysConfigController {
@Autowired
private SysConfigService sysConfigService;
/**
* 根据key查询系统配置
*
* @return
*/
@PostMapping("getSysConfigByKey")
@ApiOperation("根据key查询系统配置")
public Result<Boolean> sysConfigReq(@RequestBody SysConfigReq sysConfigReq) {
boolean state = sysConfigService.getStateByKey(sysConfigReq.getKey());
return Result.success(state);
}
}
package com.hs.admin.mapper;
import com.hs.admin.model.SysConfig;
import java.util.List;
public interface SysConfigMapper {
List<SysConfig> selectByKey(String key);
}
\ No newline at end of file
package com.hs.admin.model;
import java.util.Date;
public class SysConfig {
private Long id;
private Date createDate;
private boolean state;
private String key;
private String name;
private String value;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public boolean getState() {
return state;
}
public void setState(boolean state) {
this.state = state;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
\ No newline at end of file
package com.hs.admin.model.reqmodel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
public class SysConfigReq {
@ApiModelProperty(value = "key", required = true)
@NotNull(message = "key 参数必传")
private String key;
}
......@@ -5,6 +5,7 @@ import lombok.Data;
@Data
public class SysUserList extends SysUser {
private Integer rowNum;
private Integer roleId;
private String roleName;
private String orgId;
......
package com.hs.admin.service;
public interface SysConfigService {
boolean getStateByKey(String key);
String getValueByKey(String key);
}
package com.hs.admin.service.impl;
import com.hs.admin.mapper.SysConfigMapper;
import com.hs.admin.model.SysConfig;
import com.hs.admin.service.SysConfigService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class SysConfigServiceImpl implements SysConfigService {
@Resource
private SysConfigMapper sysConfigMapper;
@Override
public boolean getStateByKey(String key) {
List<SysConfig> sysConfigList = sysConfigMapper.selectByKey(key);
if(sysConfigList.size()==0) return false;
SysConfig sysConfig = sysConfigList.get(0);
return sysConfig.getState();
}
@Override
public String getValueByKey(String key) {
List<SysConfig> sysConfigList = sysConfigMapper.selectByKey(key);
if(sysConfigList.size()==0) return null;
SysConfig sysConfig = sysConfigList.get(0);
return sysConfig.getValue();
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hs.admin.mapper.SysConfigMapper">
<resultMap id="ResultMap" type="com.hs.admin.model.SysConfig">
<id column="ID" jdbcType="DECIMAL" property="id"/>
<result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate"/>
<result column="STATE" jdbcType="BOOLEAN" property="state"/>
<result column="KEY" jdbcType="VARCHAR" property="key"/>
<result column="NAME" jdbcType="VARCHAR" property="name"/>
<result column="VALUE" jdbcType="VARCHAR" property="value"/>
</resultMap>
<select id="selectByKey" resultMap="ResultMap">
select *
from SYS_CONFIG
where `key` = #{key,jdbcType=VARCHAR}
</select>
</mapper>
\ No newline at end of file
......@@ -24,6 +24,7 @@
<result column="IS_LEADER" jdbcType="BOOLEAN" property="isLeader"/>
</resultMap>
<resultMap id="SysUserList" extends="BaseResultMap" type="com.hs.admin.model.respmodel.SysUserList">
<result column="ROW_NUM" jdbcType="INTEGER" property="rowNum"/>
<result column="ROLE_ID" jdbcType="INTEGER" property="roleId"/>
<result column="ROLE_NAME" jdbcType="VARCHAR" property="roleName"/>
<result column="ORG_ID" jdbcType="INTEGER" property="orgId"/>
......@@ -136,13 +137,15 @@
and `STATE` != 0
</select>
<select id="selectUserList" resultMap="SysUserList">
select r.ID as ROLE_ID, r.ROLE_NAME, GROUP_CONCAT(s.ID) ORG_ID, GROUP_CONCAT(s.ORG_NAME) ORG_NAME, u.*
from sys_user u
join sys_user_role_rs ur on ur.USER_ID = u.ID and ur.STATE = 1
join sys_role r on r.ID = ur.ROLE_ID and r.STATE = 1
join sys_user_sbj_rs us on us.USER_ID = u.ID and us.STATE = 1
join sys_subject s on s.ID = us.ORG_ID and s.STATE = 1 and ((s.PARENT_ID != 0 and r.ROLE_CODE != 1) or
(s.PARENT_ID = 0 and r.ROLE_CODE = 1)) group by u.id
select @rownum := @rownum + 1 AS row_num,a.* from (select r.ID as ROLE_ID, r.ROLE_NAME, GROUP_CONCAT(s.ID) ORG_ID, GROUP_CONCAT(s.ORG_NAME) ORG_NAME, u.*
from sys_user u
join sys_user_role_rs ur on ur.USER_ID = u.ID and ur.STATE = 1
join sys_role r on r.ID = ur.ROLE_ID and r.STATE = 1
join sys_user_sbj_rs us on us.USER_ID = u.ID and us.STATE = 1
join sys_subject s on s.ID = us.ORG_ID and s.STATE = 1 and ((s.PARENT_ID != 0 and r.ROLE_CODE != 1) or
(s.PARENT_ID = 0 and r.ROLE_CODE = 1)) group by u.id
order by u.LAST_UPDATE_PWD_TIME desc
)a ,(select @rownum := 0) m
</select>
<select id="selectUserById" resultMap="SysUserList">
select r.ID as ROLE_ID, r.ROLE_NAME, GROUP_CONCAT(s.ID) ORG_ID, GROUP_CONCAT(s.ORG_NAME) ORG_NAME, u.*
......
......@@ -2,9 +2,7 @@ package com.hs.admin;
import com.hs.admin.common.base.PageRequest;
import com.hs.admin.common.base.PageResult;
import com.hs.admin.model.AuditLog;
import com.hs.admin.model.reqmodel.AuditLogReq;
import com.hs.admin.model.reqmodel.UserReq;
import com.hs.admin.service.AuditLogService;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -15,7 +13,6 @@ import org.springframework.test.context.junit4.SpringRunner;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = HsAdminApplicationTests.class)
......
......@@ -99,7 +99,7 @@ public class AESUtil {
String data = "{\"appCode\":\"portal\",\"createtime\":1592981430336,\"msgContent\":\"这里是通知的正文\",\"msgSignature\":\"中心(Janson)\",\"msgStatus\":0,\"msgTitle\":\"测试通知任务\",\"msgType\":1,\"objectCreateTime\":1592981430322,\"objectId\":\"123123123Id\",\"permission\":0,\"receiveUsers\":\"450503\",\"sendObject\":1,\"status\":0,\"userType\":1}";//明文
String miwen = encrypt(" ");// 加密
System.out.println(miwen);
System.out.println(decrypt(miwen));// 解密
System.out.println(decrypt("qwEcWHy0wSOHAg3NIlyk+A=="));// 解密
}
......
......@@ -25,7 +25,6 @@ public class SysConfigController {
* @return
*/
@PostMapping("getSysConfigByKey")
@Audit(type = AuditLogType.REFRESH)
@ApiOperation("根据key查询系统配置")
public Result<Boolean> sysConfigReq(@RequestBody SysConfigReq sysConfigReq) {
boolean state = sysConfigService.getStateByKey(sysConfigReq.getKey());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment