dcs 5 ماه پیش
والد
کامیت
0fbcba8019

+ 52 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/operate/controller/GodownController.java

@@ -0,0 +1,52 @@
+package com.bosshand.virgo.api.operate.controller;
+
+import com.bosshand.virgo.api.operate.model.Godown;
+import com.bosshand.virgo.api.operate.service.GodownService;
+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("godown")
+@Api(tags = {"仓库设置"})
+public class GodownController {
+
+    @Autowired
+    GodownService godownService;
+
+    @ApiOperation(value = "详情", notes = "详情")
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    public Response get(@PathVariable long id) {
+        return Response.ok(godownService.get(id));
+    }
+
+    @ApiOperation(value = "新增", notes = "新增")
+    @RequestMapping(value = "", method = RequestMethod.POST)
+    public Response save(@RequestBody Godown godown) {
+        godownService.save(godown);
+        return Response.ok();
+    }
+
+    @ApiOperation(value = "删除", notes = "删除")
+    @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)
+    public Response delete(@PathVariable long id) {
+        godownService.delete(id);
+        return Response.ok();
+    }
+
+    @ApiOperation(value = "编辑", notes = "编辑")
+    @RequestMapping(value = "", method = RequestMethod.PUT)
+    public Response update(@RequestBody Godown godown) {
+        godownService.update(godown);
+        return Response.ok();
+    }
+
+    @ApiOperation(value = "获取", notes = "获取")
+    @RequestMapping(value = "/query", method = RequestMethod.POST)
+    public Response getList(@RequestBody Godown godown) {
+        return Response.ok(godownService.getList(godown));
+    }
+
+}

+ 20 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/operate/dao/GodownDao.java

@@ -0,0 +1,20 @@
+package com.bosshand.virgo.api.operate.dao;
+
+import com.bosshand.virgo.api.operate.model.Godown;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface GodownDao {
+
+    int save(Godown data);
+
+    int delete(long id);
+
+    int update(Godown data);
+
+    List<Godown> getList(Godown data);
+
+    Godown get(long id);
+}

+ 69 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/operate/model/Godown.java

@@ -0,0 +1,69 @@
+package com.bosshand.virgo.api.operate.model;
+
+/**
+ * 仓库
+ */
+public class Godown {
+
+    private long id;
+
+    /**
+     * 组织id
+     */
+    private long organizationId;
+
+    /**
+     * 项目id
+     */
+    private long projectId;
+
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 备注
+     */
+    private String remark;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getOrganizationId() {
+        return organizationId;
+    }
+
+    public void setOrganizationId(long organizationId) {
+        this.organizationId = organizationId;
+    }
+
+    public long getProjectId() {
+        return projectId;
+    }
+
+    public void setProjectId(long projectId) {
+        this.projectId = projectId;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getRemark() {
+        return remark;
+    }
+
+    public void setRemark(String remark) {
+        this.remark = remark;
+    }
+}

+ 35 - 0
virgo.api/src/main/java/com/bosshand/virgo/api/operate/service/GodownService.java

@@ -0,0 +1,35 @@
+package com.bosshand.virgo.api.operate.service;
+
+import com.bosshand.virgo.api.operate.dao.GodownDao;
+import com.bosshand.virgo.api.operate.model.Godown;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class GodownService {
+
+    @Autowired
+    GodownDao godownDao;
+
+    public int save(Godown data) {
+        return godownDao.save(data);
+    }
+
+    public int delete(long id) {
+        return godownDao.delete(id);
+    }
+
+    public int update(Godown data) {
+        return godownDao.update(data);
+    }
+
+    public List<Godown> getList(Godown data) {
+        return godownDao.getList(data);
+    }
+
+    public Godown get(long id) {
+        return godownDao.get(id);
+    }
+}

+ 57 - 0
virgo.api/src/main/resources/mapper/GodownMapper.xml

@@ -0,0 +1,57 @@
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.bosshand.virgo.api.operate.dao.GodownDao">
+
+    <resultMap type="com.bosshand.virgo.api.operate.model.Godown" id="reviewerSetResult">
+        <id column="id" property="id"/>
+        <result column="organizationId" property="organizationId"/>
+        <result column="projectId" property="projectId"/>
+        <result column="name" property="name"/>
+        <result column="remark" property="remark"/>
+    </resultMap>
+
+    <insert id="save" parameterType="com.bosshand.virgo.api.operate.model.Godown" useGeneratedKeys="true" keyProperty="id">
+        insert into godown(organizationId, projectId, name, remark) VALUES
+        (#{organizationId}, #{projectId}, #{name}, #{remark})
+    </insert>
+
+    <select id="getList" resultMap="reviewerSetResult">
+        SELECT * FROM godown
+        <where>
+            <if test="id != 0">
+                and id = #{id}
+            </if>
+            <if test="organizationId != 0">
+                and organizationId = #{organizationId}
+            </if>
+            <if test="projectId != 0">
+                and projectId = #{projectId}
+            </if>
+            <if test="name != null">
+                and name = #{name}
+            </if>
+        </where>
+    </select>
+
+    <select id="get" resultMap="reviewerSetResult">
+        SELECT * FROM godown where id = #{id}
+    </select>
+
+    <delete id="delete">
+        delete from godown where id = #{id}
+    </delete>
+
+    <update id="update" parameterType="com.bosshand.virgo.api.operate.model.Godown">
+        update godown
+        <trim prefix="set" suffixOverrides=",">
+            <if test="organizationId!=0">organizationId=#{organizationId},</if>
+            <if test="projectId!=0">projectId=#{projectId},</if>
+            <if test="name!=null">name=#{name},</if>
+            <if test="remark!=null">remark=#{remark},</if>
+        </trim>
+        where id = #{id}
+    </update>
+
+</mapper>