Commit b6bc4379 by 谢海旭

触达方式查询、圈人方式查询、新增模板 接口

1 parent 08f066f7
Showing 16 changed files with 316 additions and 10 deletions
......@@ -12,6 +12,7 @@ public class SopDataType {
/**
* 名称
*/
@Column(name = "`name`")
private String name;
/**
......@@ -27,12 +28,13 @@ public class SopDataType {
/**
* 圈人方式简介
*/
@Column(name = "`desc`")
private String desc;
@Column(name = "updated_time")
@Column(name = "updated_time", insertable = false, updatable = false)
private Date updatedTime;
@Column(name = "created_time")
@Column(name = "created_time", insertable = false, updatable = false)
private Date createdTime;
/**
......
......@@ -14,6 +14,12 @@ public class SopTplNode {
@Column(name = "id")
private Integer id;
/**
* 模板节点原型id
*/
@Column(name = "node_proto_id")
private Integer nodeProtoId;
@Column(name = "node_id")
private Integer nodeId;
......@@ -115,7 +121,15 @@ public class SopTplNode {
this.id = id;
}
/**
public Integer getNodeProtoId() {
return nodeProtoId;
}
public void setNodeProtoId(Integer nodeProtoId) {
this.nodeProtoId = nodeProtoId;
}
/**
* 获取节点id
*
* @return node_id - 节点id
......
......@@ -96,18 +96,19 @@ public class SopTplNodeProto {
/**
* 节点描述
*/
@Column(name = "`desc`")
private String desc;
/**
* 更新时间
*/
@Column(name = "updated_time")
@Column(name = "updated_time", insertable = false, updatable = false)
private Date updatedTime;
/**
* 创建时间
*/
@Column(name = "created_time")
@Column(name = "created_time", insertable = false, updatable = false)
private Date createdTime;
/**
......
......@@ -2,6 +2,8 @@ package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopDataType;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SopDataTypeMapper extends CommonBaseMapper<SopDataType> {
}
\ No newline at end of file
......@@ -2,6 +2,11 @@ package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.entity.SopTplNodeProto;
import com.glsx.plat.mybatis.mapper.CommonBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface SopTplNodeProtoMapper extends CommonBaseMapper<SopTplNodeProto> {
List<SopTplNodeProto> list(SopTplNodeProto search);
}
\ No newline at end of file
package cn.com.glsx.process.modules.model;
import cn.hutool.db.Page;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/12/21
**/
public class SopTplNodeProtoSearch extends Page {
@Override
public int getPageNumber() {
int pageNumber = super.getPageNumber();
return pageNumber == 0? 1: pageNumber;
}
}
package cn.com.glsx.process.modules.controller;
import cn.com.glsx.process.modules.entity.SopDataType;
import cn.com.glsx.process.modules.service.SopDataTypeService;
import com.glsx.plat.core.annotation.ResponseResultBody;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/12/20
**/
@Slf4j
@Tag(name = "SOP圈人方式开放接口")
@RestController
@RequestMapping(value = "/sop/api/sopDataTypes")
@ResponseResultBody
public class SopDataTypeController {
@Autowired
private SopDataTypeService sopDataTypeService;
@Operation(summary = "圈人方式全部列表", description = "圈人方式全部列表")
@GetMapping("/list")
public List<SopDataType> list() {
return sopDataTypeService.list();
}
}
......@@ -4,10 +4,7 @@ import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.github.pagehelper.PageInfo;
import com.glsx.plat.core.annotation.ResponseResultBody;
......@@ -48,4 +45,10 @@ public class SopTplController extends BaseController {
public SopTplDTO getById(@PathVariable("tplId") String tplId) {
return sopTplService.getById(tplId);
}
@Operation(summary = "新增模板", description = "新增模板")
@PostMapping
public SopTpl add(@RequestBody SopTplDTO sopTplDTO) {
return sopTplService.add(sopTplDTO);
}
}
package cn.com.glsx.process.modules.controller;
import cn.com.glsx.process.modules.entity.SopTplNodeProto;
import cn.com.glsx.process.modules.service.SopTplNodeProtoService;
import com.glsx.plat.core.annotation.ResponseResultBody;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/12/21
**/
@Slf4j
@Tag(name = "SOP触达类型开放接口")
@RestController
@RequestMapping(value = "/sop/api/SopTplNodeProtos")
@ResponseResultBody
public class SopTplNodeProtoController {
@Autowired
private SopTplNodeProtoService sopTplNodeProtoService;
@Operation(summary = "触达类型列表", description = "触达类型列表")
@GetMapping("/list")
public List<SopTplNodeProto> list(SopTplNodeProto search) {
return sopTplNodeProtoService.list(search);
}
}
package cn.com.glsx.process.modules.converter;
import cn.com.glsx.process.modules.entity.SopTplNode;
import cn.com.glsx.process.modules.entity.SopTplNodeProto;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;
@Mapper
public interface SopTplNodeProtoConverter {
SopTplNodeProtoConverter INSTANCE = Mappers.getMapper(SopTplNodeProtoConverter.class);
//TODO 添加必要的字段映射
// @Mappings({
// @Mapping(source = "nodeAsync", target = "nodeAsync"),
// @Mapping(source = "nodeParamDef", target = "nodeParam"),
// @Mapping(source = "nodeContentDef", target = "nodeContent")})
SopTplNode proto2tpl(SopTplNodeProto nodeProto);
}
package cn.com.glsx.process.modules.service;
import cn.com.glsx.process.modules.entity.SopDataType;
import cn.com.glsx.process.modules.mapper.SopDataTypeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/12/21
**/
@Service
public class SopDataTypeService {
@Autowired
private SopDataTypeMapper sopDataTypeMapper;
public List<SopDataType> list() {
return sopDataTypeMapper.selectAll();
}
}
package cn.com.glsx.process.modules.service;
import cn.com.glsx.process.modules.entity.SopTplNodeProto;
import cn.com.glsx.process.modules.mapper.SopTplNodeProtoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2023/12/21
**/
@Service
public class SopTplNodeProtoService {
@Autowired
private SopTplNodeProtoMapper sopTplNodeProtoMapper;
public List<SopTplNodeProto> list(SopTplNodeProto search) {
return sopTplNodeProtoMapper.list(search);
}
}
......@@ -5,7 +5,10 @@ import java.util.Objects;
import javax.annotation.Resource;
import cn.com.glsx.process.modules.assembler.KeHuLvChengAssembler;
import cn.com.glsx.process.modules.converter.SopTplConverter;
import cn.com.glsx.process.modules.entity.SopTpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
......@@ -18,6 +21,7 @@ import cn.com.glsx.process.modules.mapper.SopTplMapper;
import cn.com.glsx.process.modules.mapper.SopTplNodeMapper;
import cn.com.glsx.process.modules.model.SopTplDTO;
import cn.com.glsx.process.modules.model.SopTplSearch;
import org.springframework.transaction.annotation.Transactional;
@Service
public class SopTplService {
......@@ -31,6 +35,9 @@ public class SopTplService {
@Resource
private SopTplLinkMapper sopTplLinkMapper;
@Autowired
private KeHuLvChengAssembler keHuLvChengAssembler;
public PageInfo<SopTplDTO> page(SopTplSearch search) {
PageHelper.startPage(search.getPageNumber(), search.getPageSize());
List<SopTplDTO> list = sopTplMapper.page(search);
......@@ -69,4 +76,23 @@ public class SopTplService {
public List<SopTpl> list() {
return sopTplMapper.selectAll();
}
@Transactional
public SopTpl add(SopTplDTO sopTplDTO) {
keHuLvChengAssembler.assemble(sopTplDTO);
SopTpl sopTpl = SopTplConverter.INSTANCE.dto2do(sopTplDTO);
sopTplMapper.insert(sopTpl);
String tplId = sopTpl.getTplId();
List<SopTplNode> nodes = sopTplDTO.getNodes();
nodes.forEach(sopTplNode -> sopTplNode.setTplId(tplId));
sopTplNodeMapper.insertList(nodes);
List<SopTplLink> links = sopTplDTO.getLinks();
links.forEach(sopTplLink -> sopTplLink.setTplId(tplId));
sopTplLinkMapper.insertList(links);
return sopTpl;
}
}
......@@ -2,6 +2,9 @@ package cn.com.glsx.process.util;
import java.io.IOException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -82,4 +85,72 @@ public class JacksonUtil {
}
return null;
}
/**
* 通过路径获取json字符串里对应的值
*
* @param json
* @param path json路径,如 aaa/bbb/ccc
* @return
*/
public static String getStrValueInJsonStrByPath(String json, String path) {
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode rootNode = mapper.readTree(json);
String[] keys = path.split("/");
JsonNode currentNode = rootNode;
for (String key : keys) {
currentNode = currentNode.get(key);
if (currentNode == null) {
return null;
}
}
return currentNode.asText();
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
return null;
}
/**
* json字符串深度替换
* 存在就更新,不存在就新增
*
* @param original 原值json字符串
* @param update 新值json字符串
* @return
* @throws Exception
*/
public static String jsonStrDeepSub(String original, String update) {
try {
ObjectMapper mapper = new ObjectMapper();
JsonNode originalNode = mapper.readTree(original);
JsonNode updateNode = mapper.readTree(update);
updateJson((ObjectNode) originalNode, (ObjectNode) updateNode);
return originalNode.toString();
} catch (JsonProcessingException e) {
logger.error(e.getMessage(), e);
}
return null;
}
// 递归更新JSON节点
private static void updateJson(ObjectNode original, ObjectNode update) {
update.fields().forEachRemaining(entry -> {
String key = entry.getKey();
JsonNode value = entry.getValue();
if (original.has(key) && original.get(key).isObject() && value.isObject()) {
updateJson((ObjectNode) original.get(key), (ObjectNode) value);
} else {
original.set(key, value);
}
});
}
}
......@@ -38,7 +38,7 @@
-->
id, node_name, node_type, node_label, node_show, node_key, node_visible, node_cron,
node_expire_cron, node_skipable, node_async, daily_limit, data_type_code, group_code,
action_code, desc, updated_time, created_time
action_code, `desc`, updated_time, created_time
</sql>
<sql id="Blob_Column_List">
<!--
......@@ -46,4 +46,22 @@
-->
node_param_def, node_content_def, node_result_def
</sql>
<select id="list" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from sop_tpl_node_proto
<where>
<if test="dataTypeCode != null and dataTypeCode != ''">
and data_type_code = #{dataTypeCode}
</if>
<if test="groupCode != null and groupCode != ''">
and group_code = #{groupCode}
</if>
<if test="actionCode != null and actionCode != ''">
and action_code = #{actionCode}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!