Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
BIN
lib/access_token1.0.jar
Normal file
BIN
lib/access_token1.0.jar
Normal file
Binary file not shown.
15
pom.xml
15
pom.xml
@ -23,6 +23,12 @@
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.mall.ebtp</groupId>
|
||||
<artifactId>uboot-common</artifactId>
|
||||
<version>0.0.19-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-attachment-sdk</artifactId>
|
||||
@ -94,6 +100,15 @@
|
||||
<systemPath>${basedir}/lib/aspose-words-16.8.0-jdk16.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<!--第三方jar包-->
|
||||
<dependency>
|
||||
<groupId>cryp.access</groupId>
|
||||
<artifactId>accessToken</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/lib/access_token1.0.jar</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.velocity</groupId>
|
||||
<artifactId>velocity-tools</artifactId>
|
||||
|
@ -0,0 +1,148 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.crypconfigure.controller;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.chinaunicom.baas.util.AccessToken;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseResponse;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@Api(value = "区块链参数配置表")
|
||||
@RequestMapping("/v1/crypconfigure")
|
||||
public class CrypConfigureController{
|
||||
|
||||
@Resource
|
||||
private ICrypConfigureService iCrypConfigureService;
|
||||
|
||||
// /**
|
||||
// * 插入新数据
|
||||
// *
|
||||
// * @param crypConfigure
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @ApiOperation("插入新数据")
|
||||
// @PostMapping
|
||||
// public BaseResponse<Integer> insert(@ApiParam(value = "对象数据", required = true) @RequestBody @Valid CrypConfigure crypConfigure){
|
||||
//
|
||||
// int i = iCrypConfigureService.insert(crypConfigure);
|
||||
//
|
||||
// return BaseResponse.success(i);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改数据
|
||||
// *
|
||||
// * @param crypConfigure
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @ApiOperation("修改数据")
|
||||
// @PutMapping
|
||||
// public BaseResponse<Boolean> update(@ApiParam(value = "对象数据", required = true) @RequestBody CrypConfigure crypConfigure){
|
||||
//
|
||||
// Boolean i = iCrypConfigureService.updateCrypConfigureById(crypConfigure);
|
||||
//
|
||||
// return BaseResponse.success(i);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 查询数据
|
||||
// *
|
||||
// * @param id
|
||||
// *
|
||||
// * @return
|
||||
// */
|
||||
// @ApiOperation("根据id查询数据")
|
||||
// @GetMapping("/{id}")
|
||||
// public BaseResponse<CrypConfigure> get(@ApiParam(value = "主键id", required = true) @PathVariable String id){
|
||||
//
|
||||
// CrypConfigure crypConfigure = iCrypConfigureService.getById(id);
|
||||
//
|
||||
// return BaseResponse.success(crypConfigure);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除数据
|
||||
// * @param id 主键id
|
||||
// * @return BaseResponse<Boolean>
|
||||
// * @author dino
|
||||
// * @date 2020/10/21 14:56
|
||||
// */
|
||||
// @ApiOperation(value = "delete",notes = "删除数据")
|
||||
// @DeleteMapping("/{id}")
|
||||
// public BaseResponse<Integer> delete(@ApiParam(value = "主键id", required = true) @PathVariable Long id) {
|
||||
// int i = iCrypConfigureService.deleteById(id);
|
||||
// return BaseResponse.success(i);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("查询列表数据")
|
||||
@GetMapping("/list")
|
||||
public BaseResponse<List<CrypConfigure>> list(@ApiParam(value = "查询对象数据", required = false) CrypConfigure param) {
|
||||
//查询
|
||||
LambdaQueryWrapper<CrypConfigure> query = Wrappers.lambdaQuery(param);
|
||||
List<CrypConfigure> list = iCrypConfigureService.list(query);
|
||||
//异常处理
|
||||
//RespsExceptionEnum.FRAME_EXCEPTION_DEMO_NOT_FIND.customValid(list.isEmpty());
|
||||
return BaseResponse.success(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 区块链数据加密
|
||||
*
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("区块链数据加密")
|
||||
@PostMapping("/signObject")
|
||||
public BaseResponse<CrypBean> signObject(@RequestBody Object object) {
|
||||
|
||||
return BaseResponse.success(this.iCrypConfigureService.signObject(object));
|
||||
}
|
||||
|
||||
/**
|
||||
* 区块链数据解密
|
||||
*
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("区块链数据解密")
|
||||
@PostMapping("/verifyObject")
|
||||
public BaseResponse<Boolean> verifyObject(@RequestBody CrypBean bean) {
|
||||
|
||||
return BaseResponse.success(this.iCrypConfigureService.verifyObject(bean));
|
||||
}
|
||||
|
||||
/**
|
||||
* accessToken获取
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation("accessToken获取")
|
||||
@GetMapping("/getAccessToken")
|
||||
public BaseResponse<String> getAccessToken() {
|
||||
|
||||
return BaseResponse.success( AccessToken.tokenCreate());
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.crypconfigure.dao;
|
||||
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.dao.IBaseMapper;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface CrypConfigureMapper extends IBaseMapper<CrypConfigure> {
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<?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.chinaunicom.mall.ebtp.extend.crypconfigure.dao.CrypConfigureMapper">
|
||||
<resultMap id="crypconfigureResultMap" type="com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure">
|
||||
<result column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="c_code" jdbcType="VARCHAR" property="cCode" />
|
||||
<result column="c_show" jdbcType="VARCHAR" property="cShow" />
|
||||
<result column="type" jdbcType="INTEGER" property="type" />
|
||||
<result column="c_value" jdbcType="VARCHAR" property="cValue" />
|
||||
<result column="remarks" jdbcType="VARCHAR" property="remarks" />
|
||||
<result column="state" jdbcType="INTEGER" property="state" />
|
||||
<result column="create_by" jdbcType="VARCHAR" property="createBy" />
|
||||
<result column="create_date" jdbcType="VARCHAR" property="createDate" />
|
||||
<result column="update_by" jdbcType="VARCHAR" property="updateBy" />
|
||||
<result column="update_date" jdbcType="VARCHAR" property="updateDate" />
|
||||
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId" />
|
||||
<result column="tenant_name" jdbcType="VARCHAR" property="tenantName" />
|
||||
<result column="delete_flag" jdbcType="VARCHAR" property="deleteFlag" />
|
||||
<result column="last_update_time" jdbcType="VARCHAR" property="lastUpdateTime" />
|
||||
<result column="cutover_status" jdbcType="INTEGER" property="cutoverStatus" />
|
||||
</resultMap>
|
||||
|
||||
<!--逻辑删除方法 此方法为代码生成器生成 不允许修改 如有特殊需求 请自行新建SQL语句-->
|
||||
<update id="deleteOff" >
|
||||
update biz_bid_cryp_configure
|
||||
set
|
||||
delete_flag="1"
|
||||
where ID=#{id }
|
||||
</update>
|
||||
</mapper>
|
@ -0,0 +1,35 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.crypconfigure.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 实体类 CrypConfigure-区块链参数配置表
|
||||
*
|
||||
* @author yss
|
||||
*/
|
||||
@Data
|
||||
public class CrypBean {
|
||||
|
||||
/**
|
||||
* 签名
|
||||
*/
|
||||
@ApiModelProperty(value = "签名")
|
||||
public String sing;
|
||||
/**
|
||||
* 待签名参数
|
||||
*/
|
||||
@ApiModelProperty(value = "待签名参数")
|
||||
public Object object;
|
||||
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.crypconfigure.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.chinaunicom.mall.ebtp.common.base.entity.BaseEntity;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 实体类 CrypConfigure-区块链参数配置表
|
||||
*
|
||||
* @author yss
|
||||
*/
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@TableName(value = "biz_bid_cryp_configure", autoResultMap = true)
|
||||
@ApiModel(value = "CrypConfigure对象", description = "区块链参数配置表")
|
||||
public class CrypConfigure extends BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId
|
||||
@ApiModelProperty(value = "主键ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "配置标识")
|
||||
private String cCode;
|
||||
|
||||
@ApiModelProperty(value = "配置说明")
|
||||
private String cShow;
|
||||
|
||||
@ApiModelProperty(value = "配置类型 1-区块链")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty(value = "值")
|
||||
private String cValue;
|
||||
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remarks;
|
||||
|
||||
@ApiModelProperty(value = "状态 0-失效 1-生效")
|
||||
private Integer state;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty(value = "租户ID")
|
||||
private String tenantId;
|
||||
|
||||
@ApiModelProperty(value = "租户名称")
|
||||
private String tenantName;
|
||||
|
||||
@ApiModelProperty(value = "删除标识")
|
||||
private String deleteFlag;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "删除标识")
|
||||
private LocalDateTime lastUpdateTime;
|
||||
|
||||
@ApiModelProperty(value = "割接状态;0-割接数据,1-新数据")
|
||||
private Integer cutoverStatus;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.crypconfigure.service;
|
||||
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.IBaseService;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
||||
|
||||
/**
|
||||
* 对数据表 biz_bid_cryp_configure 操作的 service
|
||||
* @author yss
|
||||
*
|
||||
*/
|
||||
public interface ICrypConfigureService extends IBaseService<CrypConfigure> {
|
||||
|
||||
/**
|
||||
* 加密
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
CrypBean signObject(Object object);
|
||||
|
||||
/**
|
||||
* 解密
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
Boolean verifyObject(CrypBean bean);
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package com.chinaunicom.mall.ebtp.extend.crypconfigure.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.chinaunicom.mall.ebtp.common.base.service.impl.BaseServiceImpl;
|
||||
import com.chinaunicom.mall.ebtp.common.constant.CommonConstants;
|
||||
import com.chinaunicom.mall.ebtp.common.crypto.service.CrypServiceImpl;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.dao.CrypConfigureMapper;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypBean;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.entity.CrypConfigure;
|
||||
import com.chinaunicom.mall.ebtp.extend.crypconfigure.service.ICrypConfigureService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 对数据表 biz_bid_cryp_configure 操作的 serviceImpl
|
||||
* @author yss
|
||||
*
|
||||
*/
|
||||
@Service
|
||||
public class CrypConfigureServiceImpl extends BaseServiceImpl<CrypConfigureMapper,CrypConfigure> implements ICrypConfigureService {
|
||||
/**
|
||||
* 加密
|
||||
* @param object
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CrypBean signObject(Object object){
|
||||
CrypBean bean = new CrypBean();
|
||||
try{
|
||||
bean.setObject(object);
|
||||
//查询
|
||||
LambdaQueryWrapper<CrypConfigure> query = Wrappers.lambdaQuery();
|
||||
query.eq(CrypConfigure::getState,"1")
|
||||
.eq(CrypConfigure::getDeleteFlag, CommonConstants.STATUS_NORMAL)
|
||||
.eq(CrypConfigure::getType,"1")
|
||||
.eq(CrypConfigure::getCCode,"pem_key");
|
||||
|
||||
List<CrypConfigure> list = this.list(query);
|
||||
|
||||
CrypConfigure crypConfigure = list.get(0);
|
||||
|
||||
String signValue = CrypServiceImpl.signObject2(bean.getObject(),crypConfigure.getCValue());
|
||||
|
||||
bean.setSing(signValue);
|
||||
|
||||
return bean;
|
||||
}catch (Exception e){
|
||||
log.error("加密异常:"+e);
|
||||
}
|
||||
|
||||
|
||||
return bean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解密
|
||||
* @param bean
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Boolean verifyObject(CrypBean bean){
|
||||
try{
|
||||
//查询
|
||||
LambdaQueryWrapper<CrypConfigure> query = Wrappers.lambdaQuery();
|
||||
query.eq(CrypConfigure::getState,"1")
|
||||
.eq(CrypConfigure::getDeleteFlag, CommonConstants.STATUS_NORMAL)
|
||||
.eq(CrypConfigure::getType,"1")
|
||||
.eq(CrypConfigure::getCCode,"crt_key");
|
||||
|
||||
List<CrypConfigure> list = this.list(query);
|
||||
log.debug("---------获取解密秘钥--------");
|
||||
CrypConfigure crypConfigure = list.get(0);
|
||||
|
||||
Boolean b = CrypServiceImpl.verifyValue(bean.getSing(),
|
||||
bean.getObject(),
|
||||
crypConfigure.getCValue());
|
||||
return b;
|
||||
}catch (Exception e){
|
||||
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user