Browse Source

新增标准文件

anderx 1 year ago
parent
commit
abfc190ac6

+ 3 - 1
src/main/java/com/goafanti/common/dao/StandardDocumentMapper.java

@@ -1,11 +1,12 @@
 package com.goafanti.common.dao;
 
 import com.goafanti.common.model.StandardDocument;
+import com.goafanti.standard.bo.OutStandardDocument;
 
 /**
 * @author Administrator
 * @description 针对表【standard_document(标准文档列表)】的数据库操作Mapper
-* @createDate 2024-05-08 16:49:27
+* @createDate 2024-05-08 17:19:34
 * @Entity com.goafanti.common.model.StandardDocument
 */
 public interface StandardDocumentMapper {
@@ -22,4 +23,5 @@ public interface StandardDocumentMapper {
 
     int updateByPrimaryKey(StandardDocument record);
 
+    OutStandardDocument selectDetailsById(Integer id);
 }

+ 36 - 6
src/main/java/com/goafanti/common/mapper/StandardDocumentMapper.xml

@@ -13,6 +13,7 @@
             <result property="depId" column="dep_id" jdbcType="VARCHAR"/>
             <result property="aid" column="aid" jdbcType="VARCHAR"/>
             <result property="status" column="status" jdbcType="INTEGER"/>
+            <result property="type" column="type" jdbcType="INTEGER"/>
             <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
             <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
     </resultMap>
@@ -20,8 +21,8 @@
     <sql id="Base_Column_List">
         id,url,serial_number,
         name,reference,dep_id,
-        aid,status,create_time,
-        update_time
+        aid,status,type,
+        create_time,update_time
     </sql>
 
     <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
@@ -39,12 +40,12 @@
         insert into standard_document
         ( id,url,serial_number
         ,name,reference,dep_id
-        ,aid,status,create_time
-        ,update_time)
+        ,aid,status,type
+        ,create_time,update_time)
         values (#{id,jdbcType=INTEGER},#{url,jdbcType=VARCHAR},#{serialNumber,jdbcType=VARCHAR}
         ,#{name,jdbcType=VARCHAR},#{reference,jdbcType=VARCHAR},#{depId,jdbcType=VARCHAR}
-        ,#{aid,jdbcType=VARCHAR},#{status,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP}
-        ,#{updateTime,jdbcType=TIMESTAMP})
+        ,#{aid,jdbcType=VARCHAR},#{status,jdbcType=INTEGER},#{type,jdbcType=INTEGER}
+        ,#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})
     </insert>
     <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.StandardDocument" useGeneratedKeys="true">
         insert into standard_document
@@ -57,6 +58,7 @@
                 <if test="depId != null">dep_id,</if>
                 <if test="aid != null">aid,</if>
                 <if test="status != null">status,</if>
+                <if test="type != null">type,</if>
                 <if test="createTime != null">create_time,</if>
                 <if test="updateTime != null">update_time,</if>
         </trim>
@@ -69,6 +71,7 @@
                 <if test="depId != null">#{depId,jdbcType=VARCHAR},</if>
                 <if test="aid != null">#{aid,jdbcType=VARCHAR},</if>
                 <if test="status != null">#{status,jdbcType=INTEGER},</if>
+                <if test="type != null">#{type,jdbcType=INTEGER},</if>
                 <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
                 <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
         </trim>
@@ -97,6 +100,9 @@
                 <if test="status != null">
                     status = #{status,jdbcType=INTEGER},
                 </if>
+                <if test="type != null">
+                    type = #{type,jdbcType=INTEGER},
+                </if>
                 <if test="createTime != null">
                     create_time = #{createTime,jdbcType=TIMESTAMP},
                 </if>
@@ -116,8 +122,32 @@
             dep_id =  #{depId,jdbcType=VARCHAR},
             aid =  #{aid,jdbcType=VARCHAR},
             status =  #{status,jdbcType=INTEGER},
+            type =  #{type,jdbcType=INTEGER},
             create_time =  #{createTime,jdbcType=TIMESTAMP},
             update_time =  #{updateTime,jdbcType=TIMESTAMP}
         where   id = #{id,jdbcType=INTEGER} 
     </update>
+
+    <resultMap id="DetailsMap" type="com.goafanti.standard.bo.OutStandardDocument">
+        <id property="id" column="id" jdbcType="INTEGER"/>
+        <result property="url" column="url" jdbcType="VARCHAR"/>
+        <result property="serialNumber" column="serial_number" jdbcType="VARCHAR"/>
+        <result property="name" column="name" jdbcType="VARCHAR"/>
+        <result property="reference" column="reference" jdbcType="VARCHAR"/>
+        <result property="depId" column="dep_id" jdbcType="VARCHAR"/>
+        <result property="aid" column="aid" jdbcType="VARCHAR"/>
+        <result property="type" column="type" jdbcType="INTEGER"/>
+        <result property="status" column="status" jdbcType="INTEGER"/>
+        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
+        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+        <result property="adminName" column="adminName" jdbcType="VARCHAR"/>
+        <result property="depName" column="depName" jdbcType="VARCHAR"/>
+    </resultMap>
+    <select id="selectDetailsById"  resultMap="DetailsMap">
+        select
+            a.*,b.name adminName,c.name depName
+        from standard_document a left join admin b on a.aid=b.id
+        left join department c on a.dep_id=c.id
+        where  a.id = #{id,jdbcType=INTEGER}
+    </select>
 </mapper>

+ 23 - 0
src/main/java/com/goafanti/common/model/StandardDocument.java

@@ -1,5 +1,7 @@
 package com.goafanti.common.model;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+
 import java.io.Serializable;
 import java.util.Date;
 
@@ -49,6 +51,11 @@ public class StandardDocument implements Serializable {
     private Integer status;
 
     /**
+     * 0=国家标准,1=行业标准,2=地方标准,3=团体标准,4=国际标准
+     */
+    private Integer type;
+
+    /**
      * 发起时间
      */
     private Date createTime;
@@ -173,8 +180,23 @@ public class StandardDocument implements Serializable {
     }
 
     /**
+     * 0=国家标准,1=行业标准,2=地方标准,3=团体标准,4=国际标准
+     */
+    public Integer getType() {
+        return type;
+    }
+
+    /**
+     * 0=国家标准,1=行业标准,2=地方标准,3=团体标准,4=国际标准
+     */
+    public void setType(Integer type) {
+        this.type = type;
+    }
+
+    /**
      * 发起时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     public Date getCreateTime() {
         return createTime;
     }
@@ -189,6 +211,7 @@ public class StandardDocument implements Serializable {
     /**
      * 修改时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     public Date getUpdateTime() {
         return updateTime;
     }

+ 22 - 0
src/main/java/com/goafanti/standard/bo/InputStandardList.java

@@ -0,0 +1,22 @@
+package com.goafanti.standard.bo;
+
+public class InputStandardList {
+    private Integer pageNo;
+    private Integer pageSize;
+
+    public Integer getPageNo() {
+        return pageNo;
+    }
+
+    public void setPageNo(Integer pageNo) {
+        this.pageNo = pageNo;
+    }
+
+    public Integer getPageSize() {
+        return pageSize;
+    }
+
+    public void setPageSize(Integer pageSize) {
+        this.pageSize = pageSize;
+    }
+}

+ 26 - 0
src/main/java/com/goafanti/standard/bo/OutStandardDocument.java

@@ -0,0 +1,26 @@
+package com.goafanti.standard.bo;
+
+import com.goafanti.common.model.StandardDocument;
+
+public class OutStandardDocument extends StandardDocument {
+
+    private String adminName;
+    private String depName;
+
+
+    public String getAdminName() {
+        return adminName;
+    }
+
+    public void setAdminName(String adminName) {
+        this.adminName = adminName;
+    }
+
+    public String getDepName() {
+        return depName;
+    }
+
+    public void setDepName(String depName) {
+        this.depName = depName;
+    }
+}

+ 76 - 0
src/main/java/com/goafanti/standard/controller/StandardApiController.java

@@ -0,0 +1,76 @@
+package com.goafanti.standard.controller;
+
+import com.goafanti.common.bo.Result;
+import com.goafanti.common.controller.CertifyApiController;
+import com.goafanti.common.model.StandardDocument;
+import com.goafanti.standard.bo.InputStandardList;
+import com.goafanti.standard.service.StandardService;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+@RestController
+@RequestMapping(value = "/api/admin/standard")
+public class StandardApiController extends CertifyApiController {
+
+    @Resource
+    private StandardService standardService;
+
+    /**
+     * 标准列表
+     *
+     * @param in
+     * @return
+     */
+    @RequestMapping(value = "/list", method = RequestMethod.GET)
+    public Result list(InputStandardList in) {
+        Result res = res();
+        return res.data(standardService.list(in));
+    }
+    /**
+     * 标准详情
+     *
+     * @param in
+     * @return
+     */
+    @RequestMapping(value = "/get", method = RequestMethod.GET)
+    public Result get(StandardDocument in) {
+        Result res = res();
+        return res.data(standardService.get(in));
+    }
+
+    /**
+     * 新增标准
+     * @param in
+     * @return
+     */
+    @RequestMapping(value = "/add", method = RequestMethod.POST)
+    public Result add(StandardDocument in) {
+        Result res = res();
+        return res.data(standardService.add(in));
+    }
+
+    /**
+     * 删除标准
+     * @param in
+     * @return
+     */
+    @RequestMapping(value = "/delete", method = RequestMethod.POST)
+    public Result delete(StandardDocument in) {
+        Result res = res();
+        return res.data(standardService.delete(in));
+    }
+
+    /**
+     * 更新标准
+     * @param in
+     * @return
+     */
+    @RequestMapping(value = "/update", method = RequestMethod.POST)
+    public Result update(StandardDocument in) {
+        Result res = res();
+        return res.data(standardService.update(in));
+    }
+}

+ 17 - 0
src/main/java/com/goafanti/standard/service/StandardService.java

@@ -0,0 +1,17 @@
+package com.goafanti.standard.service;
+
+import com.goafanti.common.model.StandardDocument;
+import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.standard.bo.InputStandardList;
+
+public interface StandardService {
+    Object add(StandardDocument in);
+
+    Object delete(StandardDocument in);
+
+    Object update(StandardDocument in);
+
+    Pagination<?> list(InputStandardList in);
+
+    Object get(StandardDocument in);
+}

+ 46 - 0
src/main/java/com/goafanti/standard/service/impl/StandardServiceImpl.java

@@ -0,0 +1,46 @@
+package com.goafanti.standard.service.impl;
+
+import com.goafanti.common.dao.StandardDocumentMapper;
+import com.goafanti.common.model.StandardDocument;
+import com.goafanti.core.mybatis.BaseMybatisDao;
+import com.goafanti.core.mybatis.page.Pagination;
+import com.goafanti.standard.bo.InputStandardList;
+import com.goafanti.standard.bo.OutStandardDocument;
+import com.goafanti.standard.service.StandardService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Service
+public class StandardServiceImpl extends BaseMybatisDao<StandardDocumentMapper> implements StandardService {
+    @Autowired
+    private StandardDocumentMapper standardDocumentMapper;
+    @Override
+    public Object add(StandardDocument in) {
+        return standardDocumentMapper.insertSelective(in);
+    }
+
+    @Override
+    public Object delete(StandardDocument in) {
+        return standardDocumentMapper.deleteByPrimaryKey(Long.valueOf(in.getId()));
+    }
+
+    @Override
+    public Object update(StandardDocument in) {
+        return standardDocumentMapper.updateByPrimaryKeySelective(in);
+    }
+
+    @Override
+    public Pagination<OutStandardDocument> list(InputStandardList in) {
+        Map<String,Object> params = new HashMap();
+        return (Pagination<OutStandardDocument>) findPage("standardList","standardCount",params,in.getPageNo(),in.getPageSize());
+    }
+
+    @Override
+    public Object get(StandardDocument in) {
+        return standardDocumentMapper.selectDetailsById(in.getId());
+
+    }
+}