解决部门解密问题
This commit is contained in:
parent
726e9a9af1
commit
5a0084306a
|
|
@ -0,0 +1,31 @@
|
|||
package com.bonus.app.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 手环箱实体类
|
||||
*/
|
||||
@Data
|
||||
public class BoxEntity {
|
||||
|
||||
|
||||
/**
|
||||
* 箱子名称
|
||||
*/
|
||||
private String boxName;
|
||||
/**
|
||||
* 箱子低
|
||||
*/
|
||||
private String boxId;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private long userId;
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String roleCode;
|
||||
|
||||
|
||||
private long teamId;
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.bonus.app.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 手环领用
|
||||
*/
|
||||
@Data
|
||||
public class BraceletEntity {
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 手环发放的数量
|
||||
*/
|
||||
private int boxNum;
|
||||
|
||||
/**
|
||||
* 总容量
|
||||
*/
|
||||
private int boxCapacity;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -77,9 +77,9 @@ public class ResponseEncryptFilter implements GlobalFilter, Ordered {
|
|||
return chain.filter(exchange);
|
||||
}
|
||||
//是否加密
|
||||
if(!jaData){
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
// if(!jaData){
|
||||
// return chain.filter(exchange);
|
||||
// }
|
||||
// 根据具体业务内容,修改响应体
|
||||
return modifyResponseBody(exchange, chain);
|
||||
}
|
||||
|
|
@ -121,7 +121,8 @@ public class ResponseEncryptFilter implements GlobalFilter, Ordered {
|
|||
Map map = JSON.parseObject(responseData);
|
||||
Object encrypt = map.get(SystemGlobal.KEY_DECRYPT);
|
||||
Map maps= Maps.newHashMap();
|
||||
if(encrypt==null || encrypt=="" || SystemGlobal.TRUE_STR.equals(encrypt)){
|
||||
//加密则数据 进行加密
|
||||
if(jaData){
|
||||
responseData = AesCbcUtils.encrypt(JSON.toJSONString(map));
|
||||
maps.put("data",responseData);
|
||||
maps.put(SystemGlobal.KEY_DECRYPT,true);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
@Configuration
|
||||
public class GatewayExceptionHandler implements ErrorWebExceptionHandler
|
||||
{
|
||||
@Value("${system.jie-enable}")
|
||||
@Value("${system.jia-enable}")
|
||||
public boolean jaData;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,8 +48,10 @@ spring:
|
|||
rule-type: gw-flow
|
||||
#系统 自动 加解密开关
|
||||
system:
|
||||
#返回数据加密
|
||||
jia-enable: false
|
||||
jie-enable: false
|
||||
# 接收数据解密
|
||||
jie-enable: true
|
||||
#加密组件
|
||||
jasypt:
|
||||
encryptor:
|
||||
|
|
|
|||
|
|
@ -5,11 +5,12 @@ import com.bonus.common.security.annotation.EnableRyFeignClients;
|
|||
import com.bonus.common.swagger.annotation.EnableCustomSwagger2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;
|
||||
|
||||
@EnableCustomConfig
|
||||
@EnableCustomSwagger2
|
||||
@EnableRyFeignClients
|
||||
@SpringBootApplication
|
||||
@SpringBootApplication(exclude = MongoAutoConfiguration.class)
|
||||
public class BonusAppApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(BonusAppApplication.class, args);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
package com.bonus.app.config;
|
||||
|
||||
public enum RoleConfig {
|
||||
|
||||
TEAM("team"),DEPART("depart");
|
||||
|
||||
private final String roleCode;
|
||||
|
||||
RoleConfig(String roleCode) {
|
||||
this.roleCode = roleCode;
|
||||
}
|
||||
|
||||
public String getRoleCode() {
|
||||
return roleCode;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
package com.bonus.app.controller;
|
||||
|
||||
import com.bonus.app.entity.BoxEntity;
|
||||
import com.bonus.app.entity.BraceletEntity;
|
||||
import com.bonus.app.service.BraceletService;
|
||||
import com.bonus.common.core.web.controller.BaseController;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import com.bonus.common.core.web.page.TableDataInfo;
|
||||
import com.bonus.common.log.annotation.SysLog;
|
||||
import com.bonus.common.log.enums.OperaType;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 手环管理模块
|
||||
* APP
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/bracelet/")
|
||||
@Slf4j
|
||||
public class BraceletController extends BaseController{
|
||||
|
||||
|
||||
@Autowired
|
||||
private BraceletService service;
|
||||
|
||||
/**
|
||||
* 查询班组
|
||||
* 所领取的手环箱
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("getBoxListById")
|
||||
@SysLog(title = "手环管理", businessType = OperaType.QUERY, module = "基础管理->手环管理", details = "查询手环列表")
|
||||
public AjaxResult getBoxListById(BoxEntity entity) {
|
||||
List<BoxEntity> list = service.getBoxListById(entity);
|
||||
return AjaxResult.success(list);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
package com.bonus.app.mapper;
|
||||
|
||||
import com.bonus.app.entity.BoxEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 手环管理 数据层
|
||||
*/
|
||||
@Mapper
|
||||
public interface BraceletMapper {
|
||||
/**
|
||||
* 查询班组下拉选集合
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
List<BoxEntity> getBoxListById(BoxEntity entity);
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
package com.bonus.app.service;
|
||||
|
||||
import com.bonus.app.entity.BoxEntity;
|
||||
import com.bonus.app.entity.BraceletEntity;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* APP 手环管理
|
||||
*/
|
||||
|
||||
public interface BraceletService {
|
||||
|
||||
/**
|
||||
* 查询手环箱数据
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
List<BoxEntity> getBoxListById(BoxEntity entity);
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
package com.bonus.app.service;
|
||||
|
||||
import com.bonus.app.config.RoleConfig;
|
||||
import com.bonus.app.entity.BoxEntity;
|
||||
import com.bonus.app.entity.BraceletEntity;
|
||||
import com.bonus.app.mapper.BraceletMapper;
|
||||
import com.bonus.common.security.utils.SecurityUtils;
|
||||
import com.bonus.system.api.model.LoginUser;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* app 接口实现层
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class BraceletServiceImpl implements BraceletService{
|
||||
|
||||
@Autowired
|
||||
private BraceletMapper mapper;
|
||||
@Override
|
||||
public List<BoxEntity> getBoxListById(BoxEntity entity) {
|
||||
try{
|
||||
LoginUser loginUser= SecurityUtils.getLoginUser();
|
||||
String teamCode=loginUser.getSysUser().getRoleCode();
|
||||
entity.setRoleCode(teamCode);
|
||||
entity.setTeamId(loginUser.getSysUser().getTeamId());
|
||||
List<BoxEntity> list=mapper.getBoxListById(entity);
|
||||
return list;
|
||||
}catch (Exception e){
|
||||
log.error(e.toString());
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,16 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bonus.app.mapper.DevUseMapper">
|
||||
|
||||
|
||||
<mapper namespace="com.bonus.app.mapper.BraceletMapper">
|
||||
|
||||
<select id="getBoxListById" resultType="com.bonus.app.entity.BoxEntity">
|
||||
select id boxId,box_name boxName
|
||||
FROM tb_sh_box
|
||||
WHERE team_id is not null
|
||||
<if test="roleCode!=null and roleCode!='' and roleCode=='team'">
|
||||
and team_id=#{teamId}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue