feat(可回溯): 多租户

增加从配置取租户ID逻辑
This commit is contained in:
BrandWang
2023-05-15 10:26:11 +08:00
parent 6312fb6070
commit db4fffcda2
22 changed files with 1274 additions and 0 deletions
@@ -0,0 +1,51 @@
package com.wabestway.recall.trace.dao;
import com.wabestway.recall.trace.entity.RecallApiEntity;
import com.wabestway.recall.trace.dto.RecallApiDTO;
import com.wabestway.recall.trace.vo.RecallApiVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Mapper
public interface RecallApiDao extends BaseMapper<RecallApiEntity> {
/**
* 分页查询
* @param page 分页对象
* @param recallApiDTO
* @return
*/
IPage<RecallApiVO> queryRecallApiByCondition(Page<RecallApiDTO> page, @Param("recallApiDTO")RecallApiDTO recallApiDTO);
/**
* 条件查询,不分页
* @param recallApiDTO
* @return
*/
List<RecallApiVO> queryRecallApiListNoPage(@Param("recallApiDTO")RecallApiDTO recallApiDTO);
/**
* 根据id更新
* @param recallApi 对象
* @return
*/
void updateRecallApiById(@Param("recallApi")RecallApiEntity recallApi);
/**
* 根据id查询详情
* @param id
* @return
*/
RecallApiVO queryRecallApiById(@Param("id") String id);
}
@@ -0,0 +1,51 @@
package com.wabestway.recall.trace.dao;
import com.wabestway.recall.trace.entity.RecallProductEntity;
import com.wabestway.recall.trace.dto.RecallProductDTO;
import com.wabestway.recall.trace.vo.RecallProductVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Mapper
public interface RecallProductDao extends BaseMapper<RecallProductEntity> {
/**
* 分页查询
* @param page 分页对象
* @param recallProductDTO
* @return
*/
IPage<RecallProductVO> queryRecallProductByCondition(Page<RecallProductDTO> page, @Param("recallProductDTO")RecallProductDTO recallProductDTO);
/**
* 条件查询,不分页
* @param recallProductDTO
* @return
*/
List<RecallProductVO> queryRecallProductListNoPage(@Param("recallProductDTO")RecallProductDTO recallProductDTO);
/**
* 根据id更新
* @param recallProduct 对象
* @return
*/
void updateRecallProductById(@Param("recallProduct")RecallProductEntity recallProduct);
/**
* 根据id查询详情
* @param id
* @return
*/
RecallProductVO queryRecallProductById(@Param("id") String id);
}
@@ -0,0 +1,35 @@
package com.wabestway.recall.trace.dto;
import java.io.Serializable;
import lombok.Data;
import com.wabestway.commons.http.PageDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Data
@ApiModel
public class RecallApiDTO extends PageDTO implements Serializable {
private static final long serialVersionUID = 1L;
/** */
@ApiModelProperty(value = "")
private String id;
/** 可回溯调用appKey */
@ApiModelProperty(value = "可回溯调用appKey")
private String appKey;
/** 调用方名称 */
@ApiModelProperty(value = "调用方名称")
private String name;
/** 备注 */
@ApiModelProperty(value = "备注")
private String remark;
}
@@ -0,0 +1,44 @@
package com.wabestway.recall.trace.dto;
import java.io.Serializable;
import lombok.Data;
import com.wabestway.commons.http.PageDTO;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Data
@ApiModel
public class RecallProductDTO extends PageDTO implements Serializable {
private static final long serialVersionUID = 1L;
/** */
@ApiModelProperty(value = "")
private String id;
/** 产品编码 */
@ApiModelProperty(value = "产品编码")
private String productCode;
/** 产品名称 */
@ApiModelProperty(value = "产品名称")
private String productName;
/** 保险公司编码 */
@ApiModelProperty(value = "保险公司编码")
private String supplierCode;
/** 保险公司名称 */
@ApiModelProperty(value = "保险公司名称")
private String supplierName;
/** 是否归档 0-否1-是 */
@ApiModelProperty(value = "是否归档 0-否1-是 ")
private String archived;
/** 是否记录轨迹 0-否1-是 */
@ApiModelProperty(value = "是否记录轨迹 0-否1-是 ")
private String tracked;
}
@@ -0,0 +1,38 @@
package com.wabestway.recall.trace.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Data
@TableName(value = "recall_api")
public class RecallApiEntity {
/** */
@TableId
private String id;
/** 可回溯调用appKey */
private String appKey;
/** 调用方名称 */
private String name;
/** 租户Id */
private String tenantId;
/** 备注 */
private String remark;
/** 创建人 */
private String createBy;
/** 创建时间 */
private Long createTime;
/** 更新人 */
private String updateBy;
/** 更新时间 */
private Long updateTime;
}
@@ -0,0 +1,44 @@
package com.wabestway.recall.trace.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Data
@TableName(value = "recall_product")
public class RecallProductEntity {
/** */
@TableId
private String id;
/** 产品编码 */
private String productCode;
/** 产品名称 */
private String productName;
/** 保险公司编码 */
private String supplierCode;
/** 保险公司名称 */
private String supplierName;
/** 是否归档 0-否1-是 */
private String archived;
/** 是否记录轨迹 0-否1-是 */
private String tracked;
/** 租户Id */
private String tenantId;
/** 创建人 */
private String createBy;
/** 创建时间 */
private Long createTime;
/** 更新人 */
private String updateBy;
/** 更新时间 */
private Long updateTime;
}
@@ -0,0 +1,55 @@
package com.wabestway.recall.trace.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wabestway.recall.trace.entity.RecallApiEntity;
import com.wabestway.recall.trace.dto.RecallApiDTO;
import com.wabestway.recall.trace.vo.RecallApiVO;
import java.util.List;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
public interface RecallApiService extends IService<RecallApiEntity> {
/**
* 分页查询
* @param page 分页对象
* @param recallApiDTO
* @return
*/
IPage<RecallApiVO> queryRecallApiByCondition(long page, long size, RecallApiDTO recallApiDTO);
/**
* 条件查询,不分页
* @param recallApiDTO
* @return
*/
List<RecallApiVO> queryRecallApiListNoPage(RecallApiDTO recallApiDTO);
/**
* 根据id更新
* @param recallApi 对象
* @return
*/
void updateRecallApiById(RecallApiEntity recallApi);
/**
* 根据id查询详情
* @param id
* @return
*/
RecallApiVO queryRecallApiById(String id);
/**
* 查询调用app归属租户
* @param appKey
* @return
*/
String queryApiTenant(String appKey);
}
@@ -0,0 +1,48 @@
package com.wabestway.recall.trace.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wabestway.recall.trace.entity.RecallProductEntity;
import com.wabestway.recall.trace.dto.RecallProductDTO;
import com.wabestway.recall.trace.vo.RecallProductVO;
import java.util.List;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
public interface RecallProductService extends IService<RecallProductEntity> {
/**
* 分页查询
* @param page 分页对象
* @param recallProductDTO
* @return
*/
IPage<RecallProductVO> queryRecallProductByCondition(long page, long size, RecallProductDTO recallProductDTO);
/**
* 条件查询,不分页
* @param recallProductDTO
* @return
*/
List<RecallProductVO> queryRecallProductListNoPage(RecallProductDTO recallProductDTO);
/**
* 根据id更新
* @param recallProduct 对象
* @return
*/
void updateRecallProductById(RecallProductEntity recallProduct);
/**
* 根据id查询详情
* @param id
* @return
*/
RecallProductVO queryRecallProductById(String id);
}
@@ -0,0 +1,59 @@
package com.wabestway.recall.trace.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wabestway.recall.trace.dao.RecallApiDao;
import com.wabestway.recall.trace.entity.RecallApiEntity;
import com.wabestway.recall.trace.dto.RecallApiDTO;
import com.wabestway.recall.trace.vo.RecallApiVO;
import com.wabestway.recall.trace.service.RecallApiService;
import java.util.List;
/**
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Service
public class RecallApiServiceImpl extends ServiceImpl<RecallApiDao, RecallApiEntity> implements RecallApiService {
@Override
public IPage<RecallApiVO> queryRecallApiByCondition(long page, long size, RecallApiDTO recallApiDTO) {
Page<RecallApiDTO> paramReq = new Page<>(page, size);
paramReq.addOrder(new OrderItem().setColumn("create_time").setAsc(false));//创建时间降序排序
IPage<RecallApiVO> iPage = baseMapper.queryRecallApiByCondition(paramReq, recallApiDTO);
return iPage;
}
public List<RecallApiVO> queryRecallApiListNoPage(RecallApiDTO recallApiDTO) {
return baseMapper.queryRecallApiListNoPage(recallApiDTO);
}
@Override
public void updateRecallApiById(RecallApiEntity recallApi) {
baseMapper.updateRecallApiById(recallApi);
}
@Override
public RecallApiVO queryRecallApiById(String id) {
return baseMapper.queryRecallApiById(id);
}
@Override
public String queryApiTenant(String appKey) {
LambdaQueryWrapper<RecallApiEntity> query = Wrappers.lambdaQuery();
query.eq(RecallApiEntity::getAppKey, appKey);
query.last("limit 1");
RecallApiEntity recallApi = baseMapper.selectOne(query);
if (recallApi != null) {
return recallApi.getTenantId();
}
return null;
}
}
@@ -0,0 +1,46 @@
package com.wabestway.recall.trace.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wabestway.recall.trace.dao.RecallProductDao;
import com.wabestway.recall.trace.entity.RecallProductEntity;
import com.wabestway.recall.trace.dto.RecallProductDTO;
import com.wabestway.recall.trace.vo.RecallProductVO;
import com.wabestway.recall.trace.service.RecallProductService;
import java.util.List;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Service
public class RecallProductServiceImpl extends ServiceImpl<RecallProductDao, RecallProductEntity> implements RecallProductService {
@Override
public IPage<RecallProductVO> queryRecallProductByCondition(long page, long size, RecallProductDTO recallProductDTO) {
Page<RecallProductDTO> paramReq = new Page<>(page,size);
paramReq.addOrder(new OrderItem().setColumn("create_time").setAsc(false));//创建时间降序排序
IPage<RecallProductVO> iPage = baseMapper.queryRecallProductByCondition(paramReq, recallProductDTO);
return iPage;
}
public List<RecallProductVO> queryRecallProductListNoPage(RecallProductDTO recallProductDTO) {
return baseMapper.queryRecallProductListNoPage(recallProductDTO);
}
@Override
public void updateRecallProductById(RecallProductEntity recallProduct) {
baseMapper.updateRecallProductById(recallProduct);
}
@Override
public RecallProductVO queryRecallProductById(String id ) {
return baseMapper.queryRecallProductById(id);
}
}
@@ -0,0 +1,45 @@
package com.wabestway.recall.trace.vo;
import java.io.Serializable;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Data
@ApiModel
public class RecallApiVO implements Serializable {
private static final long serialVersionUID = 1L;
/** */
@ApiModelProperty(value = "")
private String id;
/** 可回溯调用appKey */
@ApiModelProperty(value = "可回溯调用appKey")
private String appKey;
/** 调用方名称 */
@ApiModelProperty(value = "调用方名称")
private String name;
/** 备注 */
@ApiModelProperty(value = "备注")
private String remark;
/** 创建人 */
@ApiModelProperty(value = "创建人")
private String createBy;
/** 创建时间 */
@ApiModelProperty(value = "创建时间")
private Long createTime;
/** 更新人 */
@ApiModelProperty(value = "更新人")
private String updateBy;
/** 更新时间 */
@ApiModelProperty(value = "更新时间")
private Long updateTime;
}
@@ -0,0 +1,54 @@
package com.wabestway.recall.trace.vo;
import java.io.Serializable;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Data
@ApiModel
public class RecallProductVO implements Serializable {
private static final long serialVersionUID = 1L;
/** */
@ApiModelProperty(value = "")
private String id;
/** 产品编码 */
@ApiModelProperty(value = "产品编码")
private String productCode;
/** 产品名称 */
@ApiModelProperty(value = "产品名称")
private String productName;
/** 保险公司编码 */
@ApiModelProperty(value = "保险公司编码")
private String supplierCode;
/** 保险公司名称 */
@ApiModelProperty(value = "保险公司名称")
private String supplierName;
/** 是否归档 0-否1-是 */
@ApiModelProperty(value = "是否归档 0-否1-是 ")
private String archived;
/** 是否记录轨迹 0-否1-是 */
@ApiModelProperty(value = "是否记录轨迹 0-否1-是 ")
private String tracked;
/** 创建人 */
@ApiModelProperty(value = "创建人")
private String createBy;
/** 创建时间 */
@ApiModelProperty(value = "创建时间")
private Long createTime;
/** 更新人 */
@ApiModelProperty(value = "更新人")
private String updateBy;
/** 更新时间 */
@ApiModelProperty(value = "更新时间")
private Long updateTime;
}
@@ -0,0 +1,96 @@
<?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.wabestway.recall.trace.dao.RecallApiDao">
<sql id="queryRecallApiSql">
t.id id,
t.app_key appKey,
t.name name,
t.tenant_id tenantId,
t.remark remark,
t.create_by createBy,
t.create_time createTime,
t.update_by updateBy,
t.update_time updateTime
</sql>
<select id="queryRecallApiByCondition"
parameterType="com.wabestway.recall.trace.dto.RecallApiDTO"
resultType="com.wabestway.recall.trace.vo.RecallApiVO">
select
<include refid="queryRecallApiSql"/>
from
recall_api t
where 1 = 1
<if test="recallApiDTO.id != null and recallApiDTO.id != '' ">
and t.id = #{recallApiDTO.id}
</if>
<if test="recallApiDTO.appKey != null and recallApiDTO.appKey != '' ">
and t.app_key = #{recallApiDTO.appKey}
</if>
<if test="recallApiDTO.name != null and recallApiDTO.name != '' ">
and t.name = #{recallApiDTO.name}
</if>
<if test="recallApiDTO.remark != null and recallApiDTO.remark != '' ">
and t.remark = #{recallApiDTO.remark}
</if>
</select>
<select id="queryRecallApiListNoPage"
parameterType="com.wabestway.recall.trace.dto.RecallApiDTO"
resultType="com.wabestway.recall.trace.vo.RecallApiVO">
select
<include refid="queryRecallApiSql"/>
from recall_api t
where 1 = 1
<if test="recallApiDTO.id != null and recallApiDTO.id != '' ">
and t.id = #{recallApiDTO.id}
</if>
<if test="recallApiDTO.appKey != null and recallApiDTO.appKey != '' ">
and t.app_key = #{recallApiDTO.appKey}
</if>
<if test="recallApiDTO.name != null and recallApiDTO.name != '' ">
and t.name = #{recallApiDTO.name}
</if>
<if test="recallApiDTO.remark != null and recallApiDTO.remark != '' ">
and t.remark = #{recallApiDTO.remark}
</if>
</select>
<select id="queryRecallApiById" resultType="com.wabestway.recall.trace.vo.RecallApiVO">
select
<include refid="queryRecallApiSql"/>
from recall_api t
where t.id= #{id}
</select>
<update id="updateRecallApiById" parameterType="com.wabestway.recall.trace.entity.RecallApiEntity">
update recall_api t
<set>
<if test="recallApi.id != null and recallApi.id != '' ">
t.id = #{recallApi.id},
</if>
<if test="recallApi.appKey != null and recallApi.appKey != '' ">
t.app_key = #{recallApi.appKey},
</if>
<if test="recallApi.name != null and recallApi.name != '' ">
t.name = #{recallApi.name},
</if>
<if test="recallApi.remark != null and recallApi.remark != '' ">
t.remark = #{recallApi.remark},
</if>
<if test="recallApi.updateBy != null and recallApi.updateBy != '' ">
t.update_by = #{recallApi.updateBy},
</if>
<if test="recallApi.updateTime != null ">
t.update_time = #{recallApi.updateTime},
</if>
</set>
where t.id= #{recallApi.id}
</update>
</mapper>
@@ -0,0 +1,126 @@
<?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.wabestway.recall.trace.dao.RecallProductDao">
<sql id="queryRecallProductSql">
t.id id,
t.product_code productCode,
t.product_name productName,
t.supplier_code supplierCode,
t.supplier_name supplierName,
t.archived archived,
t.tracked tracked,
t.tenant_id tenantId,
t.create_by createBy,
t.create_time createTime,
t.update_by updateBy,
t.update_time updateTime
</sql>
<select id="queryRecallProductByCondition"
parameterType="com.wabestway.recall.trace.dto.RecallProductDTO"
resultType="com.wabestway.recall.trace.vo.RecallProductVO">
select
<include refid="queryRecallProductSql"/>
from
recall_product t
where 1 = 1
<if test="recallProductDTO.id != null and recallProductDTO.id != '' ">
and t.id = #{recallProductDTO.id}
</if>
<if test="recallProductDTO.productCode != null and recallProductDTO.productCode != '' ">
and t.product_code = #{recallProductDTO.productCode}
</if>
<if test="recallProductDTO.productName != null and recallProductDTO.productName != '' ">
and t.product_name = #{recallProductDTO.productName}
</if>
<if test="recallProductDTO.supplierCode != null and recallProductDTO.supplierCode != '' ">
and t.supplier_code = #{recallProductDTO.supplierCode}
</if>
<if test="recallProductDTO.supplierName != null and recallProductDTO.supplierName != '' ">
and t.supplier_name = #{recallProductDTO.supplierName}
</if>
<if test="recallProductDTO.archived != null and recallProductDTO.archived != '' ">
and t.archived = #{recallProductDTO.archived}
</if>
<if test="recallProductDTO.tracked != null and recallProductDTO.tracked != '' ">
and t.tracked = #{recallProductDTO.tracked}
</if>
</select>
<select id="queryRecallProductListNoPage"
parameterType="com.wabestway.recall.trace.dto.RecallProductDTO"
resultType="com.wabestway.recall.trace.vo.RecallProductVO">
select
<include refid="queryRecallProductSql"/>
from recall_product t
where 1 = 1
<if test="recallProductDTO.id != null and recallProductDTO.id != '' ">
and t.id = #{recallProductDTO.id}
</if>
<if test="recallProductDTO.productCode != null and recallProductDTO.productCode != '' ">
and t.product_code = #{recallProductDTO.productCode}
</if>
<if test="recallProductDTO.productName != null and recallProductDTO.productName != '' ">
and t.product_name = #{recallProductDTO.productName}
</if>
<if test="recallProductDTO.supplierCode != null and recallProductDTO.supplierCode != '' ">
and t.supplier_code = #{recallProductDTO.supplierCode}
</if>
<if test="recallProductDTO.supplierName != null and recallProductDTO.supplierName != '' ">
and t.supplier_name = #{recallProductDTO.supplierName}
</if>
<if test="recallProductDTO.archived != null and recallProductDTO.archived != '' ">
and t.archived = #{recallProductDTO.archived}
</if>
<if test="recallProductDTO.tracked != null and recallProductDTO.tracked != '' ">
and t.tracked = #{recallProductDTO.tracked}
</if>
</select>
<select id="queryRecallProductById" resultType="com.wabestway.recall.trace.vo.RecallProductVO">
select
<include refid="queryRecallProductSql"/>
from recall_product t
where t.id= #{id}
</select>
<update id="updateRecallProductById" parameterType="com.wabestway.recall.trace.entity.RecallProductEntity">
update recall_product t
<set>
<if test="recallProduct.id != null and recallProduct.id != '' ">
t.id = #{recallProduct.id},
</if>
<if test="recallProduct.productCode != null and recallProduct.productCode != '' ">
t.product_code = #{recallProduct.productCode},
</if>
<if test="recallProduct.productName != null and recallProduct.productName != '' ">
t.product_name = #{recallProduct.productName},
</if>
<if test="recallProduct.supplierCode != null and recallProduct.supplierCode != '' ">
t.supplier_code = #{recallProduct.supplierCode},
</if>
<if test="recallProduct.supplierName != null and recallProduct.supplierName != '' ">
t.supplier_name = #{recallProduct.supplierName},
</if>
<if test="recallProduct.archived != null and recallProduct.archived != '' ">
t.archived = #{recallProduct.archived},
</if>
<if test="recallProduct.tracked != null and recallProduct.tracked != '' ">
t.tracked = #{recallProduct.tracked},
</if>
<if test="recallProduct.updateBy != null and recallProduct.updateBy != '' ">
t.update_by = #{recallProduct.updateBy},
</if>
<if test="recallProduct.updateTime != null ">
t.update_time = #{recallProduct.updateTime},
</if>
</set>
where t.id= #{recallProduct.id}
</update>
</mapper>
@@ -0,0 +1,63 @@
package com.wabestway.recall.trace.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.wabestway.recall.trace.dto.RecallApiDTO;
import com.wabestway.recall.trace.vo.RecallApiVO;
import com.wabestway.recall.trace.service.RecallApiApiService;
import com.wabestway.commons.http.Paging;
import com.wabestway.commons.http.ResObj;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@RestController
@RequestMapping("/trace/recallApi")
@Api(tags = {"-接口"}, description = "-接口")
public class RecallApiController {
@Autowired
private RecallApiApiService recallApiApiService;
/**
* 列表
*/
@PostMapping("/list")
@ApiOperation(value = "分页列表查询", notes = "条件分页查询列表", httpMethod = "POST")
public ResObj<Paging<RecallApiVO>> list(@RequestBody RecallApiDTO paramRequest) {
return recallApiApiService.list(paramRequest);
}
/**
* 信息
*/
@GetMapping("/info/{id}")
@ApiOperation(value = "根据id查详情", notes = "根据id查详情", httpMethod = "GET")
public ResObj<RecallApiVO> info(@PathVariable("id") String id) {
return recallApiApiService.getRecallApi(id);
}
/**
* 保存
*/
@PostMapping("/save")
@ApiOperation(value = "保存", notes = "保存", httpMethod = "POST")
public ResObj saveRecallApi(@RequestBody RecallApiDTO paramRequest) {
return recallApiApiService.saveRecallApi(paramRequest);
}
/**
* 修改
*/
@PostMapping("/update")
@ApiOperation(value = "修改", notes = "修改", httpMethod = "POST")
public ResObj updateRecallApi(@RequestBody RecallApiDTO paramRequest) {
return recallApiApiService.updateRecallApi(paramRequest);
}
}
@@ -0,0 +1,64 @@
package com.wabestway.recall.trace.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.wabestway.recall.trace.dto.RecallProductDTO;
import com.wabestway.recall.trace.vo.RecallProductVO;
import com.wabestway.recall.trace.service.RecallProductApiService;
import com.wabestway.commons.http.Paging;
import com.wabestway.commons.http.ResObj;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@RestController
@RequestMapping("/trace/recallProduct")
@Api(tags = {"-接口"}, description = "-接口")
public class RecallProductController {
@Autowired
private RecallProductApiService recallProductApiService;
/**
* 列表
*/
@PostMapping("/list")
@ApiOperation(value = "分页列表查询", notes = "条件分页查询列表", httpMethod = "POST")
public ResObj<Paging<RecallProductVO>> list(@RequestBody RecallProductDTO paramRequest) {
return recallProductApiService.list(paramRequest);
}
/**
* 信息
*/
@GetMapping("/info/{id}")
@ApiOperation(value = "根据id查详情", notes = "根据id查详情", httpMethod = "GET")
public ResObj<RecallProductVO> info(@PathVariable("id") String id) {
return recallProductApiService.getRecallProduct(id);
}
/**
* 保存
*/
@PostMapping("/save")
@ApiOperation(value = "保存", notes = "保存", httpMethod = "POST")
public ResObj saveRecallProduct(@RequestBody RecallProductDTO paramRequest) {
return recallProductApiService.saveRecallProduct(paramRequest);
}
/**
* 修改
*/
@PostMapping("/update")
@ApiOperation(value = "修改", notes = "修改", httpMethod = "POST")
public ResObj updateRecallProduct(@RequestBody RecallProductDTO paramRequest) {
return recallProductApiService.updateRecallProduct(paramRequest);
}
}
@@ -0,0 +1,47 @@
package com.wabestway.recall.trace.service;
import com.wabestway.recall.trace.dto.RecallApiDTO;
import com.wabestway.recall.trace.vo.RecallApiVO;
import com.wabestway.commons.http.Paging;
import com.wabestway.commons.http.ResObj;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
public interface RecallApiApiService {
/**
* 列表
* @param paramReq
* @return
*/
ResObj<Paging<RecallApiVO>> list(RecallApiDTO paramReq);
/**
* 查询详情
* @param id
* @return
*/
ResObj<RecallApiVO> getRecallApi(String id);
/**
* 保存
* @param paramReq
* @return
*/
ResObj saveRecallApi(RecallApiDTO paramReq);
/**
* 修改
* @param paramReq
* @return
*/
ResObj updateRecallApi(RecallApiDTO paramReq);
}
@@ -0,0 +1,46 @@
package com.wabestway.recall.trace.service;
import java.util.List;
import com.wabestway.recall.trace.dto.RecallProductDTO;
import com.wabestway.recall.trace.vo.RecallProductVO;
import com.wabestway.commons.http.Paging;
import com.wabestway.commons.http.ResObj;
/**
*
*
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
public interface RecallProductApiService {
/**
* 列表
* @param paramReq
* @return
*/
ResObj<Paging<RecallProductVO>> list(RecallProductDTO paramReq);
/**
* 查询详情
* @param id
* @return
*/
ResObj<RecallProductVO> getRecallProduct(String id);
/**
* 保存
* @param paramReq
* @return
*/
ResObj saveRecallProduct(RecallProductDTO paramReq);
/**
* 修改
* @param paramReq
* @return
*/
ResObj updateRecallProduct(RecallProductDTO paramReq);
}
@@ -0,0 +1,71 @@
package com.wabestway.recall.trace.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wabestway.commons.http.Paging;
import com.wabestway.commons.http.ResObj;
import com.wabestway.recall.util.HeaderDataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.BeanUtils;
import com.wabestway.ins.utils.UUIDUtil;
import com.wabestway.recall.trace.entity.RecallApiEntity;
import com.wabestway.recall.trace.dto.RecallApiDTO;
import com.wabestway.recall.trace.vo.RecallApiVO;
import com.wabestway.recall.trace.service.RecallApiApiService;
import com.wabestway.recall.trace.service.RecallApiService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Service
public class RecallApiApiServiceImpl implements RecallApiApiService {
@Autowired
private RecallApiService recallApiService;
@Override
public ResObj<Paging<RecallApiVO>> list(RecallApiDTO paramReq) {
IPage<RecallApiVO> resultPage = recallApiService.queryRecallApiByCondition(paramReq.getPage(), paramReq.getPageSize(), paramReq);
Paging<RecallApiVO> paging = new Paging(resultPage.getRecords(), paramReq.getPage(), resultPage.getSize(), resultPage.getTotal());
return ResObj.ok(paging);
}
@Override
public ResObj<RecallApiVO> getRecallApi(String id) {
RecallApiVO recallApiVO = recallApiService.queryRecallApiById(id);
return ResObj.ok(recallApiVO);
}
@Transactional
@Override
public ResObj saveRecallApi(RecallApiDTO paramReq) {
RecallApiEntity recallApi = new RecallApiEntity();
BeanUtils.copyProperties(paramReq, recallApi);
recallApi.setId(UUIDUtil.generate());//赋值id
recallApi.setTenantId(HeaderDataUtil.getTenantId());
recallApi.setCreateBy(HeaderDataUtil.getUserId());//创建人
recallApi.setCreateTime(System.currentTimeMillis());//创建时间
recallApi.setUpdateBy(HeaderDataUtil.getUserId());//更新人
recallApi.setUpdateTime(System.currentTimeMillis());//更新时间
recallApiService.save(recallApi);
return ResObj.ok();
}
@Transactional
@Override
public ResObj updateRecallApi(RecallApiDTO paramReq) {
RecallApiEntity recallApi = new RecallApiEntity();
BeanUtils.copyProperties(paramReq, recallApi);
recallApi.setUpdateBy(HeaderDataUtil.getUserId());//更新人
recallApi.setUpdateTime(System.currentTimeMillis());//更新时间
recallApiService.updateById(recallApi);
return ResObj.ok();
}
}
@@ -0,0 +1,73 @@
package com.wabestway.recall.trace.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wabestway.commons.http.Paging;
import com.wabestway.commons.http.ResObj;
import com.wabestway.commons.enums.DataValidEnum;
import com.wabestway.recall.util.HeaderDataUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.BeanUtils;
import com.wabestway.ins.utils.UUIDUtil;
import com.wabestway.recall.trace.entity.RecallProductEntity;
import com.wabestway.recall.trace.dto.RecallProductDTO;
import com.wabestway.recall.trace.vo.RecallProductVO;
import com.wabestway.recall.trace.service.RecallProductApiService;
import com.wabestway.recall.trace.service.RecallProductService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @author wangH
* @company 北京华焱坤泰科技有限公司
* @Time 2023-05-15 09:59:12
*/
@Service
public class RecallProductApiServiceImpl implements RecallProductApiService {
@Autowired
private RecallProductService recallProductService;
@Override
public ResObj<Paging<RecallProductVO>> list(RecallProductDTO paramReq) {
IPage<RecallProductVO> resultPage = recallProductService.queryRecallProductByCondition(paramReq.getPage(), paramReq.getPageSize(), paramReq);
Paging<RecallProductVO> paging = new Paging(resultPage.getRecords(), paramReq.getPage(), resultPage.getSize(), resultPage.getTotal());
return ResObj.ok(paging);
}
@Override
public ResObj<RecallProductVO> getRecallProduct(String id) {
RecallProductVO recallProductVO = recallProductService.queryRecallProductById(id);
return ResObj.ok(recallProductVO);
}
@Transactional
@Override
public ResObj saveRecallProduct(RecallProductDTO paramReq) {
RecallProductEntity recallProduct = new RecallProductEntity();
BeanUtils.copyProperties(paramReq, recallProduct);
recallProduct.setId(UUIDUtil.generate());//赋值id
recallProduct.setCreateBy(HeaderDataUtil.getUserId());//创建人
recallProduct.setCreateTime(System.currentTimeMillis());//创建时间
recallProduct.setUpdateBy(HeaderDataUtil.getUserId());//更新人
recallProduct.setUpdateTime(System.currentTimeMillis());//更新时间
recallProductService.save(recallProduct);
return ResObj.ok();
}
@Transactional
@Override
public ResObj updateRecallProduct(RecallProductDTO paramReq) {
RecallProductEntity recallProduct = new RecallProductEntity();
BeanUtils.copyProperties(paramReq, recallProduct);
recallProduct.setUpdateBy(HeaderDataUtil.getUserId());//更新人
recallProduct.setUpdateTime(System.currentTimeMillis());//更新时间
recallProductService.updateById(recallProduct);
return ResObj.ok();
}
}
@@ -7,6 +7,7 @@ import com.wabestway.commons.http.ResObj;
import com.wabestway.recall.trace.dto.TraceDTO; import com.wabestway.recall.trace.dto.TraceDTO;
import com.wabestway.recall.trace.entity.RecallOrderEntity; import com.wabestway.recall.trace.entity.RecallOrderEntity;
import com.wabestway.recall.trace.entity.RecallRecordEntity; import com.wabestway.recall.trace.entity.RecallRecordEntity;
import com.wabestway.recall.trace.service.RecallApiService;
import com.wabestway.recall.trace.service.RecallOrderService; import com.wabestway.recall.trace.service.RecallOrderService;
import com.wabestway.recall.trace.service.RecallRecordService; import com.wabestway.recall.trace.service.RecallRecordService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -32,6 +33,8 @@ public class RecallRecordApiServiceImpl implements RecallRecordApiService {
private RecallRecordService recallRecordService; private RecallRecordService recallRecordService;
@Autowired @Autowired
private RecallOrderService recallOrderService; private RecallOrderService recallOrderService;
@Autowired
private RecallApiService recallApiService;
@Override @Override
public ResObj save(TraceDTO record) { public ResObj save(TraceDTO record) {
@@ -55,6 +58,10 @@ public class RecallRecordApiServiceImpl implements RecallRecordApiService {
newOrder.setAppKey(record.getAppKey()); newOrder.setAppKey(record.getAppKey());
newOrder.setArchived("0"); newOrder.setArchived("0");
newOrder.setComplete(isLastEvent ? "1" : "0"); newOrder.setComplete(isLastEvent ? "1" : "0");
String tenantId = recallApiService.queryApiTenant(record.getAppKey());
if (tenantId != null) {
newOrder.setTenantId(tenantId);
}
if (isLastEvent) { if (isLastEvent) {
newOrder.setCompleteDate(System.currentTimeMillis()); newOrder.setCompleteDate(System.currentTimeMillis());
} }
@@ -0,0 +1,111 @@
package com.wabestway.recall.util;
import com.google.gson.Gson;
import com.wabestway.auth.api.user.ReqOrgInfo;
import com.wabestway.auth.api.user.ReqTenantInfo;
import com.wabestway.auth.api.user.ReqUser;
import com.wabestway.auth.api.user.TokenObj;
import com.wabestway.commons.exception.AlertException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import javax.servlet.http.HttpServletRequest;
import java.net.URLDecoder;
public class HeaderDataUtil {
private static Logger logger = LoggerFactory.getLogger(HeaderDataUtil.class);
public HeaderDataUtil() {
}
public static ReqUser getUserData() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
.getRequest();
ReqUser reqUser = null;
try {
String header = request.getHeader(TokenObj._USER);
if (header != null) {
String str = URLDecoder.decode(header, "UTF-8");
logger.info("用户信息:{}", str);
reqUser = new Gson().fromJson(str, ReqUser.class);
}
} catch (Exception e) {
logger.error("用户信息转化异常", e);
throw new AlertException("未获取到header用户信息!");
}
return reqUser;
}
public static ReqOrgInfo getOrgInfoData() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
.getRequest();
ReqOrgInfo orgInfo = null;
try {
String header = request.getHeader(TokenObj._ORG);
if (header != null) {
String str = URLDecoder.decode(header, "UTF-8");
logger.info("机构信息:{}", str);
orgInfo = new Gson().fromJson(str, ReqOrgInfo.class);
}
} catch (Exception e) {
logger.error("机构信息转化异常", e);
throw new AlertException("未获取到header机构信息!");
}
return orgInfo;
}
public static ReqTenantInfo getTenantData() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
.getRequest();
ReqTenantInfo tenant = null;
try {
String header = request.getHeader(TokenObj._TENANT);
if (header != null) {
String str = URLDecoder.decode(header, "UTF-8");
logger.info("机构信息:{}", str);
tenant = new Gson().fromJson(str, ReqTenantInfo.class);
}
} catch (Exception e) {
logger.error("租户信息转化异常", e);
}
return tenant;
}
public static String getUserId() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
.getRequest();
String userId = null;
try {
String header = request.getHeader(TokenObj._USERID);
if (header != null) {
userId = URLDecoder.decode(header, "UTF-8");
}
} catch (Exception e) {
logger.error("用户ID信息转化异常", e);
}
return userId;
}
public static String getTenantId() {
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
.getRequest();
String tenantId = null;
try {
String header = request.getHeader(TokenObj._TENANTID);
if (header != null) {
tenantId = URLDecoder.decode(header, "UTF-8");
}
} catch (Exception e) {
logger.error("租户id信息转化异常", e);
}
return tenantId;
}
}