Commit 9de13885 by 谢海旭

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

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