dcs hace 9 meses
padre
commit
6944c8add9

+ 68 - 0
virgo.file/src/main/java/com/bosshand/virgo/file/controller/DownloadDataController.java

@@ -0,0 +1,68 @@
+package com.bosshand.virgo.file.controller;
+
+import com.bosshand.virgo.core.response.Response;
+import com.bosshand.virgo.file.model.DownloadData;
+import com.bosshand.virgo.file.service.DownloadDataService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@RestController
+@RequestMapping("downloadData")
+@Api(tags = {"下载数据"})
+public class DownloadDataController {
+
+    @Autowired
+    DownloadDataService downloadDataService;
+
+    @ApiOperation("获取")
+    @RequestMapping(value = "/query", method = RequestMethod.POST)
+    public Response query(@RequestBody DownloadData downloadData) {
+        return Response.ok(downloadDataService.getList(downloadData));
+    }
+
+    @ApiOperation("分页获取")
+    @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
+    public Response list(@RequestBody DownloadData downloadData, @PathVariable int currPage, @PathVariable int pageSize) {
+        int totalCount = downloadDataService.getTotalCount(downloadData);
+        List<DownloadData> dataList = downloadDataService.getLimit(downloadData, currPage, pageSize);
+        Map<String, Object> result = new HashMap<>();
+        result.put("dataList", dataList);
+        result.put("totalCount", totalCount);
+        return Response.ok(result);
+    }
+
+    @ApiOperation("新增")
+    @RequestMapping(value = "", method = RequestMethod.POST)
+    public Response insertProjectItem(@RequestBody DownloadData downloadData) {
+        downloadDataService.insert(downloadData);
+        return Response.ok();
+    }
+
+    @ApiOperation("删除")
+    @RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
+    public Response deleteProjectItem(@PathVariable long id) {
+        downloadDataService.delete(id);
+        return Response.ok();
+    }
+
+    @ApiOperation("修改")
+    @RequestMapping(value = "/update", method = RequestMethod.PUT)
+    public Response updateProjectItem(@RequestBody DownloadData downloadData) {
+        downloadDataService.update(downloadData);
+        return Response.ok();
+    }
+
+    @ApiOperation("详情")
+    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
+    public Response get(@PathVariable long id) {
+        return Response.ok(downloadDataService.get(id));
+    }
+
+
+}

+ 27 - 0
virgo.file/src/main/java/com/bosshand/virgo/file/dao/DownloadDataDao.java

@@ -0,0 +1,27 @@
+package com.bosshand.virgo.file.dao;
+
+
+import com.bosshand.virgo.file.model.DownloadData;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface DownloadDataDao {
+
+    DownloadData get(long id);
+
+    int insert(DownloadData downloadData);
+
+    int delete(long id);
+
+    int update(DownloadData downloadData);
+
+    List<DownloadData> getList(DownloadData downloadData);
+
+    int getTotalCount(DownloadData downloadData);
+
+    List<DownloadData> getLimit(@Param("p") DownloadData downloadData , @Param("currIndex") int currIndex, @Param("pageSize") int pageSize);
+
+}

+ 126 - 0
virgo.file/src/main/java/com/bosshand/virgo/file/model/DownloadData.java

@@ -0,0 +1,126 @@
+package com.bosshand.virgo.file.model;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.util.Date;
+
+/**
+ * 下载数据
+ */
+public class DownloadData {
+
+    private long id;
+
+    /**
+     * 用户id
+     */
+    private long userId;
+
+    /**
+     * 组织id
+     */
+    private long organizationId;
+
+    /**
+     * 项目id
+     */
+    private long projectId;
+
+    /**
+     * 文件名称
+     */
+    private String fileName;
+
+    /**
+     * 文件类型
+     */
+    private String type;
+
+    /**
+     * 文件大小
+     */
+    private int size;
+
+    /**
+     * 微信链接
+     */
+    private String wxUrl;
+
+    /**
+     * 下载时间
+     */
+    @JsonFormat(shape=JsonFormat.Shape.STRING,pattern="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+    private Date date;
+
+    public long getId() {
+        return id;
+    }
+
+    public void setId(long id) {
+        this.id = id;
+    }
+
+    public long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(long userId) {
+        this.userId = userId;
+    }
+
+    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 getFileName() {
+        return fileName;
+    }
+
+    public void setFileName(String fileName) {
+        this.fileName = fileName;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public int getSize() {
+        return size;
+    }
+
+    public void setSize(int size) {
+        this.size = size;
+    }
+
+    public String getWxUrl() {
+        return wxUrl;
+    }
+
+    public void setWxUrl(String wxUrl) {
+        this.wxUrl = wxUrl;
+    }
+
+    public Date getDate() {
+        return date;
+    }
+
+    public void setDate(Date date) {
+        this.date = date;
+    }
+}

+ 45 - 0
virgo.file/src/main/java/com/bosshand/virgo/file/service/DownloadDataService.java

@@ -0,0 +1,45 @@
+package com.bosshand.virgo.file.service;
+
+import com.bosshand.virgo.file.dao.DownloadDataDao;
+import com.bosshand.virgo.file.model.DownloadData;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class DownloadDataService {
+
+    @Autowired
+    DownloadDataDao downloadDataDao;
+
+    public DownloadData get(long id) {
+        return downloadDataDao.get(id);
+    }
+
+    public int insert(DownloadData downloadData) {
+        return downloadDataDao.insert(downloadData);
+    }
+
+    public int delete(long id) {
+        return downloadDataDao.delete(id);
+    }
+
+    public int update(DownloadData downloadData) {
+        return downloadDataDao.update(downloadData);
+    }
+
+    public List<DownloadData> getList(DownloadData downloadData) {
+        return downloadDataDao.getList(downloadData);
+    }
+
+    public int getTotalCount(DownloadData downloadData) {
+        return downloadDataDao.getTotalCount(downloadData);
+    }
+
+    public List<DownloadData> getLimit(DownloadData downloadData, int currPage, int pageSize) {
+        int currIndex = (currPage - 1) * pageSize;
+        return downloadDataDao.getLimit(downloadData, currIndex, pageSize);
+    }
+
+}

+ 88 - 0
virgo.file/src/main/resources/mapper/DownloadDataMapper.xml

@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="com.bosshand.virgo.file.dao.DownloadDataDao">
+
+    <resultMap type="com.bosshand.virgo.file.model.DownloadData" id="result">
+        <id column="id" property="id"/>
+        <result column="userId" property="userId"/>
+        <result column="organizationId" property="organizationId"/>
+        <result column="projectId" property="projectId"/>
+        <result column="fileName" property="fileName"/>
+        <result column="type" property="type"/>
+        <result column="size" property="size"/>
+        <result column="wxUrl" property="wxUrl"/>
+        <result column="date" property="date"/>
+    </resultMap>
+
+    <insert id="insert" parameterType="com.bosshand.virgo.file.model.DownloadData" useGeneratedKeys="true" keyProperty="id">
+        INSERT INTO download_data(`userId`,`organizationId`,`projectId`,`fileName`,`type`,`size`,`wxUrl`, `date`) VALUES
+                          (#{userId},#{organizationId},#{projectId},#{fileName},#{type},#{size},#{wxUrl},now())
+    </insert>
+
+    <delete id="delete">
+        DELETE FROM download_data WHERE id = #{id}
+    </delete>
+
+    <select id="get" resultMap="result">
+        SELECT * FROM download_data where id = #{id}
+    </select>
+
+    <select id="getList" resultMap="result">
+        SELECT * FROM download_data
+        <where>
+            <if test="userId != 0">and userId = #{userId}</if>
+            <if test="organizationId != 0">and organizationId = #{organizationId}</if>
+            <if test="projectId != 0">and projectId = #{projectId}</if>
+            <if test="fileName != null">and fileName = #{fileName}</if>
+            <if test="type != null">and type = #{type}</if>
+            <if test="size != 0">and size = #{size}</if>
+            <if test="wxUrl != null">and wxUrl = #{wxUrl}</if>
+            <if test="date != null">and date like #{date}</if>
+        </where>
+    </select>
+
+    <select id="getTotalCount" parameterType="com.bosshand.virgo.file.model.DownloadData" resultType="Integer">
+        SELECT count(*) FROM download_data
+        <where>
+            <if test="userId != 0">and userId = #{userId}</if>
+            <if test="organizationId != 0">and organizationId = #{organizationId}</if>
+            <if test="projectId != 0">and projectId = #{projectId}</if>
+            <if test="fileName != null">and fileName = #{fileName}</if>
+            <if test="type != null">and type = #{type}</if>
+            <if test="size != 0">and size = #{size}</if>
+            <if test="wxUrl != null">and wxUrl = #{wxUrl}</if>
+            <if test="date != null">and date like #{date}</if>
+        </where>
+    </select>
+
+    <select id="getLimit" resultMap="result">
+        SELECT * FROM download_data
+        <where>
+            <if test="p.userId != 0">and userId = #{p.userId}</if>
+            <if test="p.organizationId != 0">and organizationId = #{p.organizationId}</if>
+            <if test="p.projectId != 0">and projectId = #{p.projectId}</if>
+            <if test="p.fileName != null">and fileName = #{p.fileName}</if>
+            <if test="p.type != null">and type = #{p.type}</if>
+            <if test="p.size != 0">and size = #{p.size}</if>
+            <if test="p.wxUrl != null">and wxUrl = #{p.wxUrl}</if>
+            <if test="p.date != null">and date like #{p.date}</if>
+        </where>
+        limit #{currIndex} , #{pageSize}
+    </select>
+
+    <update id="update" parameterType="com.bosshand.virgo.file.model.DownloadData">
+        UPDATE download_data
+        <trim prefix="set" suffixOverrides=",">
+            <if test="userId != 0">userId = #{userId},</if>
+            <if test="organizationId != 0">organizationId = #{organizationId},</if>
+            <if test="projectId != 0">projectId = #{projectId},</if>
+            <if test="fileName != null">fileName = #{fileName},</if>
+            <if test="type != null">type = #{type},</if>
+            <if test="size != 0">size = #{size},</if>
+            <if test="wxUrl != null">wxUrl = #{wxUrl},</if>
+            <if test="date == null">date = now(),</if>
+        </trim>
+        WHERE id=#{id}
+    </update>
+
+</mapper>