消息公告

test
2812875475 2024-04-14 15:50:55 +08:00
parent ab00e7ece8
commit a7a14ae5fb
16 changed files with 504 additions and 20 deletions

View File

@ -15,9 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 43.142.149.172:8848
namespace: test
config:
# 配置中心地址
server-addr: 43.142.149.172:8848
namespace: test
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,9 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 43.142.149.172:8848
namespace: test
config:
# 配置中心地址
server-addr: 43.142.149.172:8848
namespace: test
# 配置文件格式
file-extension: yml
# 共享配置
@ -34,6 +36,7 @@ spring:
ds1:
nacos:
server-addr: 43.142.149.172:8848
namespace: test
dataId: sentinel-muyu-gateway
groupId: DEFAULT_GROUP
data-type: json

View File

@ -15,9 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 43.142.149.172:8848
namespace: test
config:
# 配置中心地址
server-addr: 43.142.149.172:8848
namespace: test
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,9 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 43.142.149.172:8848
namespace: test
config:
# 配置中心地址
server-addr: 43.142.149.172:8848
namespace: test
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -15,9 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 43.142.149.172:8848
namespace: test
config:
# 配置中心地址
server-addr: 43.142.149.172:8848
namespace: test
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -8,6 +8,9 @@ import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.system.domain.SysNotice;
import com.muyu.system.domain.model.NoticListModel;
import com.muyu.system.domain.model.SysNoticeModel;
import com.muyu.system.domain.resp.NoticDetailReadNumResp;
import com.muyu.system.service.SysNoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
@ -26,6 +29,39 @@ public class SysNoticeController extends BaseController {
@Autowired
private SysNoticeService noticeService;
/**
*
*/
@GetMapping("/noticList")
public Result<List<NoticListModel>> noticList () {
List<NoticListModel> list = noticeService.noticList();
return Result.success(list);
}
/**
*
*/
@GetMapping("/readNotic")
public Result<String> readNotic (@RequestParam Long noticeId) {
noticeService.readNotic(noticeId);
return Result.success();
}
/**
*
*/
@GetMapping("/noticListDetail")
public Result<List<NoticDetailReadNumResp>> noticListDetail () {
List<NoticDetailReadNumResp> list = noticeService.noticListDetail();
return Result.success(list);
}
/**
*
*/
@ -52,9 +88,8 @@ public class SysNoticeController extends BaseController {
@RequiresPermissions("system:notice:add")
@Log(title = "通知公告", businessType = BusinessType.INSERT)
@PostMapping
public Result add (@Validated @RequestBody SysNotice notice) {
notice.setCreateBy(SecurityUtils.getUsername());
return toAjax(noticeService.insertNotice(notice));
public Result add (@Validated @RequestBody SysNoticeModel sysNoticeModel) {
return toAjax(noticeService.insertNotice(sysNoticeModel));
}
/**

View File

@ -0,0 +1,69 @@
package com.muyu.system.domain.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
*
*
* @author WangLei
* @Date 2024/4/13 013 9:35
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class NoticListModel {
/**
* id
*/
private Long userId;
/**
* ID
*/
private Long noticeId;
/**
*
*/
private String noticeTitle;
/**
* 1 2
*/
private String noticeType;
/**
*
*/
private String noticeContent;
/**
*
*/
private String createBy;
/**
*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/**
*
*/
private String flag;
}

View File

@ -0,0 +1,72 @@
package com.muyu.system.domain.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.models.auth.In;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
*
*
* @author WangLei
* @Date 2024/4/13 013 9:33
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class SysNoticeModel {
/**
* id
*/
private Long noticeId;
/**
*
*/
private String noticeTitle;
/**
* 1 2
*/
private String noticeType;
/**
*
*/
private String noticeContent;
/**
* 0 1
*/
private String status;
/**
*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
/**
*
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
/**
*
*/
private String userNames;
/**
*
*/
private String createBy;
}

View File

@ -0,0 +1,34 @@
package com.muyu.system.domain.resp;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
*
* @author WangLei
* @Date 2024/4/14 014 10:18
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class NoticDetailReadNumResp {
/**
* id
*/
private Long noticeId;
/**
*
*/
private Long readNum;
/**
*
*/
private Long totalNum;
}

View File

@ -1,8 +1,17 @@
package com.muyu.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.common.system.domain.SysDept;
import com.muyu.common.system.domain.SysUser;
import com.muyu.system.domain.SysNotice;
import com.muyu.system.domain.SysPost;
import com.muyu.system.domain.SysUserPost;
import com.muyu.system.domain.model.NoticListModel;
import com.muyu.system.domain.model.SysNoticeModel;
import com.muyu.system.domain.resp.NoticDetailReadNumResp;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
/**
@ -64,4 +73,22 @@ public interface SysNoticeMapper extends BaseMapper<SysNotice> {
* @return
*/
public int deleteNoticeByIds (Long[] noticeIds);
SysUser findByName(@Param("name") String name);
void addUserNotice(@Param("noticeId") Long noticeId, @Param("userId") Long userId,@Param("createBy") String createBy, @Param("startTime") Date startTime, @Param("endTime") Date endTime);
List<SysUser> findByAllName();
List<NoticListModel> finByNoticList(@Param("userId") Long userId);
List<NoticDetailReadNumResp> findByNoticeId();
void readNotic(@Param("noticeId") Long noticeId, @Param("userId") Long userId);
List<SysNotice> selectNotice(@Param("userId") Long userId);
}

View File

@ -2,6 +2,9 @@ package com.muyu.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.muyu.system.domain.SysNotice;
import com.muyu.system.domain.model.NoticListModel;
import com.muyu.system.domain.model.SysNoticeModel;
import com.muyu.system.domain.resp.NoticDetailReadNumResp;
import java.util.List;
@ -32,11 +35,10 @@ public interface SysNoticeService extends IService<SysNotice> {
/**
*
*
* @param notice
*
* @return
*/
public int insertNotice (SysNotice notice);
public Boolean insertNotice (SysNoticeModel sysNoticeModel);
/**
*
@ -64,4 +66,10 @@ public interface SysNoticeService extends IService<SysNotice> {
* @return
*/
public int deleteNoticeByIds (Long[] noticeIds);
List<NoticListModel> noticList();
List<NoticDetailReadNumResp> noticListDetail();
void readNotic(Long noticeId);
}

View File

@ -1,13 +1,29 @@
package com.muyu.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.SysDept;
import com.muyu.common.system.domain.SysUser;
import com.muyu.system.domain.SysNotice;
import com.muyu.system.domain.SysPost;
import com.muyu.system.domain.SysUserPost;
import com.muyu.system.domain.model.NoticListModel;
import com.muyu.system.domain.model.SysNoticeModel;
import com.muyu.system.domain.resp.NoticDetailReadNumResp;
import com.muyu.system.mapper.SysNoticeMapper;
import com.muyu.system.mapper.SysUserPostMapper;
import com.muyu.system.service.SysDeptService;
import com.muyu.system.service.SysNoticeService;
import com.muyu.system.service.SysPostService;
import com.muyu.system.service.SysUserService;
import org.apache.http.auth.AUTH;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
*
@ -19,11 +35,25 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
@Autowired
private SysNoticeMapper noticeMapper;
@Autowired
private SysDeptService sysDeptService;
@Autowired
private SysUserService sysUserService;
@Autowired
private SysPostService sysPostService;
/**
*
*
* @param noticeId ID
*
* @return
*/
@Override
@ -35,7 +65,6 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
*
*
* @param notice
*
* @return
*/
@Override
@ -46,20 +75,70 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
/**
*
*
* @param notice
*
* @return
*/
@Override
public int insertNotice (SysNotice notice) {
return noticeMapper.insertNotice(notice);
public Boolean insertNotice(SysNoticeModel sysNoticeModel) {
SysNotice notice = SysNotice.builder()
.noticeTitle(sysNoticeModel.getNoticeTitle())
.noticeType(sysNoticeModel.getNoticeType())
.noticeContent(sysNoticeModel.getNoticeContent())
.status(sysNoticeModel.getStatus())
.build();
//新增公告表
notice.setCreateBy(SecurityUtils.getUsername());
noticeMapper.insertNotice(notice);
SysUser sysUser1 = sysUserService.selectUserById(SecurityUtils.getUserId());
SysDept sysDept = sysDeptService.selectDeptById(sysUser1.getDeptId());
String deptName = sysDept.getDeptName();
String postGroup = sysUserService.selectUserPostGroup(sysUser1.getUserName());
String username = SecurityUtils.getUsername();
String createBy = username+"("+deptName+"/"+postGroup+")";
if (sysNoticeModel.getNoticeType().equals("2")) {
List<SysUser> sysUserList = noticeMapper.findByAllName();
sysUserList.forEach(
sysUser -> {
noticeMapper.addUserNotice(
notice.getNoticeId(),
sysUser.getUserId(),
createBy,
sysNoticeModel.getStartTime(),
sysNoticeModel.getEndTime()
);
}
);
} else {
//新增用户表和公告表id
String names = sysNoticeModel.getUserNames();
if (names != null) {
String[] nameList = names.split(",");
for (String name : nameList) {
SysUser sysUser = noticeMapper.findByName(name);
noticeMapper.addUserNotice(
notice.getNoticeId(),
sysUser.getUserId(),
createBy,
sysNoticeModel.getStartTime(),
sysNoticeModel.getEndTime());
}
}
}
return true;
}
/**
*
*
* @param notice
*
* @return
*/
@Override
@ -71,7 +150,6 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
*
*
* @param noticeId ID
*
* @return
*/
@Override
@ -83,11 +161,71 @@ public class SysNoticeServiceImpl extends ServiceImpl<SysNoticeMapper, SysNotice
*
*
* @param noticeIds ID
*
* @return
*/
@Override
public int deleteNoticeByIds(Long[] noticeIds) {
return noticeMapper.deleteNoticeByIds(noticeIds);
}
@Override
public List<NoticListModel> noticList() {
SysUser sysUser1 = sysUserService.selectUserById(SecurityUtils.getUserId());
String postGroup = sysUserService.selectUserPostGroup(sysUser1.getUserName());
List<NoticListModel> noticeModelList = new ArrayList<>();
List<NoticListModel> fin = new ArrayList<>();
if ("董事长".equals(postGroup)) {
fin= noticeMapper.finByNoticList(null);
}else{
fin= noticeMapper.finByNoticList(sysUser1.getUserId());
}
// List<SysNotice> sysNoticeList = this.list();
List<SysNotice> sysNoticeList=noticeMapper.selectNotice(sysUser1.getUserId());
for (SysNotice sysNotice : sysNoticeList) {
noticeModelList.add(
NoticListModel.builder()
.noticeId(sysNotice.getNoticeId())
.noticeTitle(sysNotice.getNoticeTitle())
.noticeType(sysNotice.getNoticeType())
.createTime(sysNotice.getCreateTime())
.noticeContent(sysNotice.getNoticeContent())
.flag(sysNotice.getStatus())
.build()
);
}
for (NoticListModel noticListModel : fin) {
noticeModelList.stream().filter(listModel -> Objects.equals(noticListModel.getNoticeId(), listModel.getNoticeId())).forEach(listModel -> {
listModel.setFlag(noticListModel.getFlag());
listModel.setCreateBy(noticListModel.getCreateBy());
});
}
if (noticeModelList == null) {
return new ArrayList<>();
}
return noticeModelList;
}
@Override
public List<NoticDetailReadNumResp> noticListDetail() {
return noticeMapper.findByNoticeId();
}
@Override
public void readNotic(Long noticeId) {
Long userId = SecurityUtils.getUserId();
noticeMapper.readNotic(noticeId,userId);
}
}

View File

@ -15,9 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 43.142.149.172:8848
namespace: test
config:
# 配置中心地址
server-addr: 43.142.149.172:8848
namespace: test
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -50,8 +50,48 @@
</if>
</where>
</select>
<select id="findByName" resultType="com.muyu.common.system.domain.SysUser">
select * from sys_user where user_name = #{name}
</select>
<select id="findByAllName" resultType="com.muyu.common.system.domain.SysUser">
select * from sys_user
</select>
<select id="finByNoticList" resultType="com.muyu.system.domain.model.NoticListModel">
select
id,
user_id,
notice_id,
create_by,
start_time,
end_time,
flag
from a_test
<if test="userId != null">
where user_id =#{userId}
</if>
<insert id="insertNotice" parameterType="com.muyu.system.domain.SysNotice">
</select>
<select id="findByNoticeId" resultType="com.muyu.system.domain.resp.NoticDetailReadNumResp">
SELECT
notice_id,
COUNT(*) AS totalNum,
SUM(CASE WHEN flag = 1 THEN 1 ELSE 0 END) AS readNum
FROM
a_test
GROUP BY
notice_id
</select>
<select id="selectNotice" resultType="com.muyu.system.domain.SysNotice">
SELECT
*
FROM a_test a
LEFT JOIN sys_user su on a.user_id=su.user_id
LEFT JOIN sys_notice sn on a.notice_id=sn.notice_id
WHERE su.user_id =#{userId}
</select>
<insert id="insertNotice" parameterType="com.muyu.system.domain.SysNotice" keyProperty="noticeId" useGeneratedKeys="true">
insert into sys_notice (
<if test="noticeTitle != null and noticeTitle != '' ">notice_title,</if>
<if test="noticeType != null and noticeType != '' ">notice_type,</if>
@ -70,6 +110,46 @@
sysdate()
)
</insert>
<insert id="addUserNotice">
INSERT INTO `ry-cloud`.`a_test`
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null and userId != ''">
user_id,
</if>
<if test="noticeId != null and noticeId != ''">
notice_id,
</if>
<if test="createBy != null and createBy != ''">
create_by,
</if>
<if test="startTime != null">
start_time,
</if>
<if test="endTime != null">
end_time
</if>
</trim>
VALUES
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null and userId != ''">
#{userId},
</if>
<if test="noticeId != null and noticeId != ''">
#{noticeId},
</if>
<if test="createBy != null and createBy != ''">
#{createBy},
</if>
<if test="startTime != null">
#{startTime},
</if>
<if test="endTime != null">
#{endTime}
</if>
</trim>
</insert>
<update id="updateNotice" parameterType="com.muyu.system.domain.SysNotice">
update sys_notice
@ -83,6 +163,10 @@
</set>
where notice_id = #{noticeId}
</update>
<update id="readNotic">
update a_test set flag = 1
where notice_id = #{noticeId} and user_id = #{userId}
</update>
<delete id="deleteNoticeById" parameterType="Long">
delete

View File

@ -15,9 +15,11 @@ spring:
discovery:
# 服务注册地址
server-addr: 43.142.149.172:8848
namespace: test
config:
# 配置中心地址
server-addr: 43.142.149.172:8848
namespace: test
# 配置文件格式
file-extension: yml
# 共享配置

View File

@ -143,6 +143,8 @@
<version>${transmittable-thread-local.version}</version>
</dependency>
<!-- 核心模块 -->
<dependency>
<groupId>com.muyu</groupId>