dcs 2 bulan lalu
induk
melakukan
0b55626e45

+ 60 - 0
virgo.manager/src/main/java/com/bosshand/virgo/controller/AnnouncementController.java

@@ -0,0 +1,60 @@
+package com.bosshand.virgo.controller;
+
+import com.bosshand.virgo.core.response.Response;
+import com.bosshand.virgo.model.Announcement;
+import com.bosshand.virgo.service.AnnouncementService;
+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({"announcement"})
+@Api(tags = {"公告信息管理"})
+public class AnnouncementController {
+
+    @Autowired
+    AnnouncementService announcementService;
+
+    @ApiOperation("保存")
+    @RequestMapping(value = "", method = RequestMethod.POST)
+    public Response insert(@RequestBody Announcement announcement) {
+        return Response.ok(announcementService.save(announcement));
+    }
+
+    @ApiOperation("更新")
+    @RequestMapping(value = "/update", method = RequestMethod.PUT)
+    public Response update(@RequestBody Announcement announcement) {
+        announcementService.update(announcement);
+        return Response.ok();
+    }
+
+    @ApiOperation("删除")
+    @RequestMapping(value = "/delete/{id}", method = RequestMethod.DELETE)
+    public Response delete(@PathVariable long id) {
+        announcementService.delete(id);
+        return Response.ok();
+    }
+
+    @ApiOperation("分页查询")
+    @RequestMapping(value = "/{currPage}/{pageSize}", method = RequestMethod.POST)
+    public Response list(@RequestBody Announcement announcement, @PathVariable int currPage, @PathVariable int pageSize) {
+        int totalCount = announcementService.getTotalCount(announcement);
+        List<Announcement> dataList = announcementService.getLimit(announcement, currPage, pageSize);
+        Map<String, Object> result = new HashMap<>();
+        result.put("dataList", dataList);
+        result.put("totalCount", totalCount);
+        return Response.ok(result);
+    }
+
+    @ApiOperation("详情")
+    @RequestMapping(value = "/details/{id}", method = RequestMethod.GET)
+    public Response get(@PathVariable long id) {
+        return Response.ok(announcementService.get(id));
+    }
+
+}

+ 24 - 0
virgo.manager/src/main/java/com/bosshand/virgo/dao/AnnouncementDao.java

@@ -0,0 +1,24 @@
+package com.bosshand.virgo.dao;
+
+import com.bosshand.virgo.model.Announcement;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+@Mapper
+public interface AnnouncementDao {
+
+    void delete(long id);
+
+    void save(Announcement announcement);
+
+    void update(Announcement announcement);
+
+    Announcement get(long id);
+
+    int getTotalCount(Announcement announcement);
+
+    List<Announcement> getLimit(@Param("p") Announcement p, @Param("currIndex") int currIndex, @Param("pageSize") int pageSize);
+
+}

+ 207 - 0
virgo.manager/src/main/java/com/bosshand/virgo/model/Announcement.java

@@ -0,0 +1,207 @@
+package com.bosshand.virgo.model;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+
+import java.util.Date;
+
+/**
+ * 公告信息
+ */
+public class Announcement {
+
+    private long id;
+
+    /**
+     * 组织id
+     */
+    private long organizationId;
+    /**
+     * 项目id
+     */
+    private long projectId;
+    /**
+     * 公告标题
+     */
+    private String title;
+    /**
+     * 公告内容
+     */
+    private String content;
+    /**
+     * 发布人ID(关联用户表)
+     */
+    private long publiSherId;
+    /**
+     * 公告分类(1-系统通知 2-活动公告 3-政策变更 4-紧急公告)
+     */
+    private Integer category;
+    /**
+     * 状态(0-草稿 1-已发布 2-已过期 3-已撤回)
+     */
+    private Integer status;
+    /**
+     * 优先级(0-普通 1-重要 2-紧急)
+     */
+    private Integer priority;
+    /**
+     * 发布时间
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date publishTime;
+    /**
+     * 生效时间
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date startTime;
+    /**
+     * 过期时间
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date endTime;
+    /**
+     * 展示平台(web/app/miniprogram 或 all)
+     */
+    private String platform;
+    /**
+     * 创建时间
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date createTime;
+    /**
+     * 更新时间
+     */
+    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private Date updateTime;
+    /**
+     * 删除标记(0-未删除 1-已删除)
+     */
+    private Integer isDeleted;
+
+    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 getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public long getPubliSherId() {
+        return publiSherId;
+    }
+
+    public void setPubliSherId(long publiSherId) {
+        this.publiSherId = publiSherId;
+    }
+
+    public Integer getCategory() {
+        return category;
+    }
+
+    public void setCategory(Integer category) {
+        this.category = category;
+    }
+
+    public Integer getStatus() {
+        return status;
+    }
+
+    public void setStatus(Integer status) {
+        this.status = status;
+    }
+
+    public Integer getPriority() {
+        return priority;
+    }
+
+    public void setPriority(Integer priority) {
+        this.priority = priority;
+    }
+
+    public Date getPublishTime() {
+        return publishTime;
+    }
+
+    public void setPublishTime(Date publishTime) {
+        this.publishTime = publishTime;
+    }
+
+    public Date getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(Date startTime) {
+        this.startTime = startTime;
+    }
+
+    public Date getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(Date endTime) {
+        this.endTime = endTime;
+    }
+
+    public String getPlatform() {
+        return platform;
+    }
+
+    public void setPlatform(String platform) {
+        this.platform = platform;
+    }
+
+    public Date getCreateTime() {
+        return createTime;
+    }
+
+    public void setCreateTime(Date createTime) {
+        this.createTime = createTime;
+    }
+
+    public Date getUpdateTime() {
+        return updateTime;
+    }
+
+    public void setUpdateTime(Date updateTime) {
+        this.updateTime = updateTime;
+    }
+
+    public Integer getIsDeleted() {
+        return isDeleted;
+    }
+
+    public void setIsDeleted(Integer isDeleted) {
+        this.isDeleted = isDeleted;
+    }
+}

+ 42 - 0
virgo.manager/src/main/java/com/bosshand/virgo/service/AnnouncementService.java

@@ -0,0 +1,42 @@
+package com.bosshand.virgo.service;
+
+import com.bosshand.virgo.dao.AnnouncementDao;
+import com.bosshand.virgo.model.Announcement;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class AnnouncementService {
+
+    @Autowired
+    AnnouncementDao announcementDao;
+
+    public void delete(long id) {
+        announcementDao.delete(id);
+    }
+
+    public Announcement save(Announcement announcement) {
+        announcementDao.save(announcement);
+        return announcement;
+    }
+
+    public void update(Announcement announcement) {
+        announcementDao.update(announcement);
+    }
+
+    public int getTotalCount(Announcement announcement) {
+        return announcementDao.getTotalCount(announcement);
+    }
+
+    public List<Announcement> getLimit(Announcement announcement, int currPage, int pageSize) {
+        int currIndex = (currPage - 1) * pageSize;
+        return announcementDao.getLimit(announcement, currIndex, pageSize);
+    }
+
+    public Announcement get(long id) {
+        return announcementDao.get(id);
+    }
+
+}

+ 99 - 0
virgo.manager/src/main/resources/mapper/AnnouncementMapper.xml

@@ -0,0 +1,99 @@
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="com.bosshand.virgo.dao.AnnouncementDao">
+
+    <resultMap type="com.bosshand.virgo.model.Announcement" id="result" >
+        <id column="id" property="id"/>
+        <result column="organizationId" property="organizationId"/>
+        <result column="projectId" property="projectId"/>
+        <result column="title" property="title"/>
+        <result column="content" property="content"/>
+        <result column="publiSherId" property="publiSherId"/>
+        <result column="category" property="category"/>
+        <result column="status" property="status"/>
+        <result column="priority" property="priority"/>
+        <result column="publishTime" property="publishTime"/>
+        <result column="startTime" property="startTime"/>
+        <result column="endTime" property="endTime"/>
+        <result column="platform" property="platform"/>
+        <result column="createTime" property="createTime"/>
+        <result column="updateTime" property="updateTime"/>
+    </resultMap>
+
+    <select id="get" resultMap="result">
+        select * from announcement where id = #{id}
+    </select>
+
+    <insert id="save" parameterType="com.bosshand.virgo.model.Announcement" useGeneratedKeys="true" keyProperty="id">
+        INSERT into announcement(`organizationId`, `projectId`, `title`, `content`, `publiSherId`, `category`, `priority`, `publishTime`, `startTime`, `endTime`, `platform`, `createTime`)
+        values(#{organizationId}, #{projectId}, #{title}, #{content}, #{publiSherId}, #{category}, #{priority}, #{publishTime}, #{startTime}, #{endTime}, #{platform}, now())
+    </insert>
+
+    <update id="update" parameterType="com.bosshand.virgo.model.Announcement">
+        UPDATE announcement
+        <trim prefix="set" suffixOverrides=",">
+            <if test="organizationId!=0">organizationId=#{organizationId},</if>
+            <if test="projectId!=0">projectId=#{projectId},</if>
+            <if test="title!=null">title=#{title},</if>
+            <if test="content!=null">content=#{content},</if>
+            <if test="publiSherId!=0">publiSherId=#{publiSherId},</if>
+            <if test="category!=null">category=#{category},</if>
+            <if test="status!=null">status=#{status},</if>
+            <if test="priority!=null">priority=#{priority},</if>
+            <if test="status==1">publishTime=now(),</if>
+            <if test="startTime!=null">startTime=#{startTime},</if>
+            <if test="status==2">endTime=now(),</if>
+            <if test="platform!=null">platform=#{platform},</if>
+            updateTime=now(),
+        </trim>
+        WHERE id=#{id}
+    </update>
+
+    <delete id="delete">
+        UPDATE announcement SET isDeleted = 1 WHERE id=#{id}
+    </delete>
+
+    <select id="getTotalCount" parameterType="com.bosshand.virgo.model.Announcement" resultType="Integer">
+        SELECT count(*) FROM announcement
+        <where>
+            <if test="organizationId!=0">and organizationId=#{organizationId}</if>
+            <if test="projectId!=0">and projectId=#{projectId}</if>
+            <if test="title!=null">and title=#{title}</if>
+            <if test="content!=null">and content=#{content}</if>
+            <if test="publiSherId!=0">and publiSherId=#{publiSherId}</if>
+            <if test="category!=null">and category=#{category}</if>
+            <if test="status!=null">and status=#{status}</if>
+            <if test="priority!=null">and priority=#{priority}</if>
+            <if test="publishTime!=null">and publishTime=#{publishTime}</if>
+            <if test="startTime!=null">and startTime=#{startTime}</if>
+            <if test="endTime!=null">and endTime=#{endTime}</if>
+            <if test="platform!=null">and platform=#{platform}</if>
+            <if test="createTime!=null">and createTime=#{createTime}</if>
+            and isDeleted != 1
+        </where>
+    </select>
+
+    <select id="getLimit" resultMap="result">
+        select * from announcement
+        <where>
+            <if test="p.organizationId!=0">and organizationId=#{p.organizationId}</if>
+            <if test="p.projectId!=0">and projectId=#{p.projectId}</if>
+            <if test="p.title!=null">and title=#{p.title}</if>
+            <if test="p.content!=null">and content=#{p.content}</if>
+            <if test="p.publiSherId!=0">and publiSherId=#{p.publiSherId}</if>
+            <if test="p.category!=null">and category=#{p.category}</if>
+            <if test="p.status!=null">and status=#{p.status}</if>
+            <if test="p.priority!=null">and priority=#{p.priority}</if>
+            <if test="p.publishTime!=null">and publishTime=#{p.publishTime}</if>
+            <if test="p.startTime!=null">and startTime=#{p.startTime}</if>
+            <if test="p.endTime!=null">and endTime=#{p.endTime}</if>
+            <if test="p.platform!=null">and platform=#{p.platform}</if>
+            <if test="p.createTime!=null">and createTime=#{p.createTime}</if>
+            and isDeleted != 1
+        </where>
+        order by createTime desc limit #{currIndex} , #{pageSize}
+    </select>
+
+</mapper>