dcs 2 months ago
parent
commit
91c06c022c

+ 59 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/controller/ProceModelController.java

@@ -0,0 +1,59 @@
+package com.bosshand.virgo.api.workark.controller;
+
+import com.bosshand.virgo.api.workark.model.ProceModel;
+import com.bosshand.virgo.api.workark.service.ProceModelService;
+import com.bosshand.virgo.core.response.Response;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+
+@RestController
+@RequestMapping("workarkProceModel")
+@Api(tags = {"过程模板"})
+public class ProceModelController {
+
+    @Autowired
+    ProceModelService proceModelService;
+
+    @ApiOperation(value = "获取", notes = "获取")
+    @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
+    public Response get(@PathVariable long id) {
+        return Response.ok(proceModelService.get(id));
+    }
+
+    @ApiOperation(value = "获取层级", notes = "获取层级")
+    @RequestMapping(value = "/getParentId/{productCouponModelId}/{parentId}", method = RequestMethod.GET)
+    public Response getParentId(@PathVariable long productCouponModelId, @PathVariable long parentId) {
+        return Response.ok(proceModelService.getParentId(productCouponModelId, parentId));
+    }
+
+    @ApiOperation(value = "获取列表", notes = "获取列表")
+    @RequestMapping(value = "/list/{productCouponModelId}", method = RequestMethod.GET)
+    public Response getList(@PathVariable long productCouponModelId) {
+        return Response.ok(proceModelService.getRoot(productCouponModelId));
+    }
+
+    @ApiOperation(value = "新增", notes = "新增")
+    @RequestMapping(value = "", method = RequestMethod.POST)
+    public Response save(@RequestBody ProceModel proceModel) {
+        proceModelService.save(proceModel);
+        return Response.ok();
+    }
+
+    @ApiOperation(value = "修改", notes = "修改")
+    @RequestMapping(value = "", method = RequestMethod.PUT)
+    public Response update(@RequestBody ProceModel proceModel) {
+        proceModelService.update(proceModel);
+        return Response.ok();
+    }
+
+    @ApiOperation(value = "删除", notes = "删除")
+    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
+    public Response delete(@PathVariable long id) {
+        proceModelService.delete(id);
+        return Response.ok();
+    }
+
+}

+ 25 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/dao/ProceModelDao.java

@@ -0,0 +1,25 @@
+package com.bosshand.virgo.api.workark.dao;
+
+import com.bosshand.virgo.api.workark.model.ProceModel;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface ProceModelDao {
+
+    public List<ProceModel> getRoot(long productCouponModelId);
+
+    public int save(ProceModel proceModel);
+
+    public int update(ProceModel proceModel);
+
+    public int delete(long id);
+
+    List<ProceModel> getList(long productCouponModelId);
+
+    List<ProceModel> getParentId(long parentId);
+
+    ProceModel get(long id);
+
+}

+ 130 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/model/ProceModel.java

@@ -0,0 +1,130 @@
+package com.bosshand.virgo.api.workark.model;
+
+import java.util.List;
+
+/**
+ * 过程模板
+ */
+public class ProceModel {
+
+    private long id;
+
+    private long parentId;
+
+    /**
+     * 商品层级id
+     */
+    private long productCouponModelId;
+
+    /**
+     * 过程名称
+     */
+    private String name;
+
+    /**
+     * 排序字段
+     */
+    private int sequence;
+
+    /**
+     * 是否附件
+     */
+    private Integer attachment;
+
+    /**
+     * 附件个数
+     */
+    private Integer attachmentNumber;
+
+    /**
+     * 角色id(用户/服务商)
+     */
+    private long roleId;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    private List<ProceModel> children;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getParentId() {
+        return parentId;
+    }
+
+    public void setParentId(long parentId) {
+        this.parentId = parentId;
+    }
+
+    public long getProductCouponModelId() {
+        return productCouponModelId;
+    }
+
+    public void setProductCouponModelId(long productCouponModelId) {
+        this.productCouponModelId = productCouponModelId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getSequence() {
+        return sequence;
+    }
+
+    public void setSequence(int sequence) {
+        this.sequence = sequence;
+    }
+
+    public Integer getAttachment() {
+        return attachment;
+    }
+
+    public void setAttachment(Integer attachment) {
+        this.attachment = attachment;
+    }
+
+    public Integer getAttachmentNumber() {
+        return attachmentNumber;
+    }
+
+    public void setAttachmentNumber(Integer attachmentNumber) {
+        this.attachmentNumber = attachmentNumber;
+    }
+
+    public long getRoleId() {
+        return roleId;
+    }
+
+    public void setRoleId(long roleId) {
+        this.roleId = roleId;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+
+    public List<ProceModel> getChildren() {
+        return children;
+    }
+
+    public void setChildren(List<ProceModel> children) {
+        this.children = children;
+    }
+}

+ 91 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/workark/service/ProceModelService.java

@@ -0,0 +1,91 @@
+package com.bosshand.virgo.api.workark.service;
+
+import com.bosshand.virgo.api.workark.dao.ProceModelDao;
+import com.bosshand.virgo.api.workark.model.ProceModel;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.ArrayList;
+import java.util.List;
+
+@Service
+public class ProceModelService {
+
+    @Autowired
+    ProceModelDao proceModelDao;
+
+    public ProceModel get(long id) {
+        ProceModel proceModel = proceModelDao.get(id);
+        List<ProceModel> ls = proceModelDao.getList(proceModel.getProductCouponModelId());
+        return this.getNodeTreeById(id, ls);
+    }
+
+    public List<ProceModel> getRoot(long productCouponModelId) {
+        List<ProceModel> list = new ArrayList<>();
+        List<ProceModel> roots = proceModelDao.getRoot(productCouponModelId);
+        List<ProceModel> ls = proceModelDao.getList(productCouponModelId);
+        for (ProceModel model : roots) {
+            list.add(this.getNodeTreeById(model.getId(), ls));
+        }
+        return list;
+    }
+
+    public int save(ProceModel proceModel) {
+        return proceModelDao.save(proceModel);
+    }
+
+    public int update(ProceModel proceModel) {
+        return proceModelDao.update(proceModel);
+    }
+
+    public int delete(long id) {
+        return proceModelDao.delete(id);
+    }
+
+    private ProceModel getNodeTreeById(long id, List<ProceModel> list) {
+        ProceModel node = null;
+        List<ProceModel> proceModelList = list;
+        for (ProceModel data : proceModelList) {
+            if (data.getId() == id) {
+                node = data;
+                break;
+            }
+        }
+        if (node != null) {
+            node.setChildren(getChildNode(node.getId(), proceModelList));
+        }
+        return node;
+    }
+
+    private List<ProceModel> getChildNode(long parentId, List<ProceModel> list) {
+        List<ProceModel> nodeList = new ArrayList<>();
+        nodeList.clear();
+        for (ProceModel data : list) {
+            if (data.getParentId() == parentId) {
+                nodeList.add(data);
+            }
+        }
+        if (nodeList.size() > 0) {
+            for (ProceModel data : nodeList) {
+                List<ProceModel> childList = getChildNode(data.getId(), list);
+                data.setChildren(childList);
+            }
+        }
+        return nodeList;
+    }
+
+
+    public List<ProceModel> getParentId(long productCouponModelId, long parentId) {
+        List<ProceModel> list = proceModelDao.getParentId(parentId);
+        if (list != null) {
+            List<ProceModel> resultList = new ArrayList<>();
+            List<ProceModel> ls = proceModelDao.getList(productCouponModelId);
+            for (ProceModel proceModel : list) {
+                resultList.add(getNodeTreeById(proceModel.getId(), ls));
+            }
+            return resultList;
+        }
+        return list;
+    }
+
+}

+ 59 - 0
virgo.api/src/main/resources/mapper/ProceModelMapper.xml

@@ -0,0 +1,59 @@
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.bosshand.virgo.api.workark.dao.ProceModelDao">
+
+    <resultMap type="com.bosshand.virgo.api.workark.model.ProceModel" id="result" >
+        <id column="id" property="id"/>
+        <result column="name" property="name"/>
+        <result column="parentId" property="parentId"/>
+        <result column="productCouponModelId" property="productCouponModelId"/>
+        <result column="sequence" property="sequence"/>
+        <result column="attachment" property="attachment"/>
+        <result column="attachmentNumber" property="attachmentNumber"/>
+        <result column="roleId" property="roleId"/>
+        <result column="remark" property="remark"/>
+    </resultMap>
+
+    <select id="get" resultMap="result">
+        select * from workark_proce_model where id = #{id}
+    </select>
+
+    <select id="getParentId" resultMap="result">
+        select * from workark_proce_model where parentId = #{parentId} order by sequence
+    </select>
+
+    <select id="getList" resultMap="result">
+        select * from workark_proce_model where productCouponModelId = #{productCouponModelId} order by sequence
+    </select>
+
+    <select id="getRoot" resultMap="result">
+        select * from workark_proce_model where parentId = -1 and productCouponModelId = #{productCouponModelId} order by sequence
+    </select>
+
+    <insert id="save" parameterType="com.bosshand.virgo.api.workark.model.ProceModel" useGeneratedKeys="true" keyProperty="id">
+        INSERT into workark_proce_model(name, parentId, productCouponModelId, sequence, attachment, attachmentNumber, roleId, remark)
+        values(#{name}, #{parentId}, #{productCouponModelId}, #{sequence}, #{attachment}, #{attachmentNumber}, #{roleId}, #{remark})
+    </insert>
+
+    <update id="update" parameterType="com.bosshand.virgo.api.workark.model.ProceModel">
+        UPDATE workark_proce_model
+        <trim prefix="set" suffixOverrides=",">
+            <if test="name!=null">name=#{name},</if>
+            <if test="parentId!=0">parentId=#{parentId},</if>
+            <if test="productCouponModelId!=0">productCouponModelId=#{productCouponModelId},</if>
+            <if test="sequence!=0">sequence=#{sequence},</if>
+            <if test="attachment!=null">attachment=#{attachment},</if>
+            <if test="attachmentNumber!=null">attachmentNumber=#{attachmentNumber},</if>
+            <if test="roleId!=0">roleId=#{roleId},</if>
+            <if test="remark!=null">remark=#{remark},</if>
+        </trim>
+        WHERE id=#{id}
+    </update>
+
+    <delete id="delete">
+        DELETE FROM workark_proce_model where id = #{id}
+    </delete>
+
+</mapper>