Commit 9de13885 by 谢海旭

更新实例节点nodeParam参数接口调整

1 parent db944e54
......@@ -3,6 +3,7 @@ package cn.com.glsx.process.modules.mapper;
import cn.com.glsx.process.modules.model.task.SopTaskDTO;
import com.github.pagehelper.PageInfo;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -19,5 +20,5 @@ public interface SopInstNodeMapper extends CommonBaseMapper<SopInstNode> {
PageInfo<SopTaskDTO> findPageListByInstId(@Param("instId")String instId);
int updateNodeParamById(SopInstNode node);
int updateNodeParamById(@Param("instNodeId") Integer instNodeId, @Param("nodeParam") Map<String, Object> nodeParam);
}
\ No newline at end of file
package cn.com.glsx.process.modules.controller;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException;
import cn.com.glsx.process.modules.BaseController;
import cn.com.glsx.process.modules.entity.SopInstNode;
import cn.com.glsx.process.modules.service.SopInstNodeService;
......@@ -7,12 +9,11 @@ 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.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Map;
@Slf4j
@Tag(name = "SOP门店模板实例节点开放接口")
......@@ -25,10 +26,15 @@ public class SopInstNodeController extends BaseController {
private SopInstNodeService sopInstNodeService;
@Operation(summary = "更新SOP模板实例节点输入参数", description = "更新SOP模板实例节点输入参数")
@PostMapping("/updateParam")
public String updateNodeParam(@RequestBody SopInstNode node) {
log.info("更新节点输入参数 入参:instNodeId {} nodeParam {}", node.getInstNodeId(), node.getNodeParam());
sopInstNodeService.updateNodeParam(node);
@PostMapping("/{instNodeId}/updateParam")
public String updateNodeParam(@PathVariable Integer instNodeId, @RequestBody Map<String, Object> nodeParam) {
log.info("更新节点输入参数 入参:instNodeId {} nodeParam {}", instNodeId, nodeParam);
if (CollectionUtils.isEmpty(nodeParam)) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "参数nodeParam不能为空!");
}
sopInstNodeService.updateNodeParam(instNodeId, nodeParam);
return "success";
}
......
......@@ -9,7 +9,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Objects;
import java.util.Map;
@Service
public class SopInstNodeService {
......@@ -18,12 +18,13 @@ public class SopInstNodeService {
private SopInstNodeMapper sopInstNodeMapper;
@Transactional
public void updateNodeParam(SopInstNode node) {
if (Objects.isNull(node.getInstNodeId())) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "实例节点id必传!");
public void updateNodeParam(Integer instNodeId, Map<String, Object> nodeParam) {
boolean exists = sopInstNodeMapper.existsWithPrimaryKey(instNodeId);
if (!exists) {
throw new AdminException(ResultEnum.PARAM_ERROR.getCode(), "实例节点不存在!");
}
sopInstNodeMapper.updateNodeParamById(node);
sopInstNodeMapper.updateNodeParamById(instNodeId, nodeParam);
}
/**
......
......@@ -45,7 +45,7 @@
</update>
<update id="updateNodeParamById">
update sop_inst_node set node_param = CAST(#{nodeParam} AS JSON) where inst_node_id = #{instNodeId}
update sop_inst_node set node_param = CAST(#{nodeParam, typeHandler=cn.com.glsx.process.modules.handler.JsonTypeHandler} AS JSON) where inst_node_id = #{instNodeId}
</update>
</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!