Pre Merge pull request !309 from 林桦/master

pull/309/MERGE
林桦 3 years ago committed by Gitee
commit 35130332e7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

@ -8,6 +8,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
@ -40,4 +41,17 @@ public class RedisConfig extends CachingConfigurerSupport
template.afterPropertiesSet();
return template;
}
@Bean
/**
*
* @param connectionFactory
* @return
*/
public RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory connectionFactory) {
RedisMessageListenerContainer container = new RedisMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
return container;
}
}

@ -40,6 +40,10 @@ public class GenUtils
column.setCreateBy(table.getCreateBy());
// 设置java字段名
column.setJavaField(StringUtils.toCamelCase(columnName));
// 如果字段全部是大写,说明字段配置成大写。要改成小写。例如:TITLE -> title
if(StringUtils.isAllUpperCase(column.getJavaField())) {
column.setJavaField(column.getJavaField().toLowerCase());
}
// 设置默认类型
column.setJavaType(GenConstants.TYPE_STRING);
column.setQueryType(GenConstants.QUERY_EQ);

@ -40,8 +40,8 @@ public class ${ClassName} extends ${Entity}
#if($parentheseIndex != -1)
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
#elseif($column.javaType == 'Date')
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
#else
@Excel(name = "${comment}")
#end
@ -62,11 +62,18 @@ public class ${ClassName} extends ${Entity}
#else
#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
#end
/**
* 设置 ${AttrName}
* @param $column.columnComment
*/
public void set${AttrName}($column.javaType $column.javaField)
{
this.$column.javaField = $column.javaField;
}
/**
* 获取 $column.columnComment
* @return
*/
public $column.javaType get${AttrName}()
{
return $column.javaField;

@ -77,6 +77,35 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common-swagger</artifactId>
</dependency>
<!-- nutz used nutmap-->
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz</artifactId>
<version>1.r.69.20210929</version>
</dependency>
<!-- ehcache -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>net.sf.ehcache</groupId>
<artifactId>ehcache</artifactId>
</dependency>
<!-- test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<exclusions>
<exclusion>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
</dependencies>

@ -0,0 +1,25 @@
package com.ruoyi.cache.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* ID
* @author Administrator
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@Documented
public @interface OrgCacheKey {
String id() default "user";
/**
* :CacheStaffInfo,CacheDeptInfo,CacheCompanyInfo
* @return
*/
OrgCacheTypeNum type() default OrgCacheTypeNum.CacheUserInfo;
}

@ -0,0 +1,11 @@
package com.ruoyi.cache.annotation;
/**
*
* @author Administrator
*
*/
public enum OrgCacheTypeNum {
CacheUserInfo, //员工的cache
CacheDeptInfo,//部门的cache
}

@ -0,0 +1,25 @@
/**
*
*/
package com.ruoyi.cache.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* pojo
* @author Condy
*
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
@Documented
public @interface OrgCacheValue {
//CacheValueNum value() default CacheStaffInfoNum.staffId;
String value() default "";
String id() default "user";
}

@ -0,0 +1,34 @@
package com.ruoyi.cache.domain;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import org.nutz.dao.entity.annotation.Column;
import org.nutz.lang.Mirror;
public class BaseCache {
/**
* POJOMap
* @return
*/
public Map<String,String> toMap(){
Mirror<?> mirror = Mirror.me(getClass());
Field[] flds = mirror.getFields();
Map<String,String> pojoMap=new HashMap<String,String>();
for (Field fld : flds) {
Object v = mirror.getValue(this, fld);
if (null == v) {//等与null就不生成map
continue;
} else if(fld.isAnnotationPresent(Column.class)){
String cv = fld.getAnnotation(Column.class).value();
pojoMap.put(cv, v.toString());
} else{
pojoMap.put(fld.getName(), v.toString());
}
}
return pojoMap;
}
}

@ -0,0 +1,70 @@
package com.ruoyi.cache.domain;
import com.ruoyi.system.api.domain.SysDept;
public class CacheSysDept extends BaseCache{
/**
* @OrgCacheValue value
*/
public final static String ANNOTAION_DEPT_ID="deptId";
public final static String ANNOTAION_PARENT_ID="parentId";
public final static String ANNOTAION_DEPT_NAME="deptName";
public final static String ANNOTAION_PARENT_NAME="parentName";
/** 部门ID */
private Long deptId;
/** 父部门ID */
private Long parentId;
/** 部门名称 */
private String deptName;
/** 父部门名称 */
private String parentName;
public CacheSysDept(SysDept dept) {
this.deptId=dept.getDeptId();
this.parentId=dept.getParentId();
this.deptName=dept.getDeptName();
this.parentName=dept.getParentName();
}
public CacheSysDept() {
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public String getParentName() {
return parentName;
}
public void setParentName(String parentName) {
this.parentName = parentName;
}
}

@ -0,0 +1,77 @@
package com.ruoyi.cache.domain;
import com.ruoyi.system.api.domain.SysUser;
/**
* redis
* @author condy
*
*/
public class CacheSysUser extends BaseCache {
/**
* @OrgCacheValue value
*/
public final static String ANNOTAION_USER_ID="userId";
public final static String ANNOTAION_USER_NAME="userName";
public final static String ANNOTAION_DEPT_ID="deptId";
public final static String ANNOTAION_EMAIL="email";
public final static String ANNOTAION_PHONENUMBER="phonenumber";
private Long userId;
private String userName;
private Long deptId;
private String nickName;
private String email;
private String phonenumber;
public CacheSysUser(SysUser user) {
this.userId=user.getUserId();
this.userName=user.getUserName();
this.deptId=user.getDeptId();
this.nickName=user.getNickName();
this.email=user.getEmail();
this.phonenumber=user.getEmail();
}
public CacheSysUser()
{
}
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPhonenumber() {
return phonenumber;
}
public void setPhonenumber(String phonenumber) {
this.phonenumber = phonenumber;
}
}

@ -0,0 +1,179 @@
package com.ruoyi.cache.service;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.nutz.lang.ContinueLoop;
import org.nutz.lang.Each;
import org.nutz.lang.ExitLoop;
import org.nutz.lang.LoopException;
import org.nutz.lang.Mirror;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import com.ruoyi.cache.annotation.OrgCacheKey;
import com.ruoyi.cache.annotation.OrgCacheTypeNum;
import com.ruoyi.cache.annotation.OrgCacheValue;
import com.ruoyi.cache.domain.BaseCache;
import com.ruoyi.cache.domain.CacheSysDept;
import com.ruoyi.cache.domain.CacheSysUser;
import com.ruoyi.common.core.utils.SpringUtils;
/**
* @OrgCacheKey
* @OrgCacheValue
* @author
*
* @param <T>
*/
public class CacheCallBack<T> implements Each<T> {
private Log log=Logs.get();
private class InnerCacheCallBack {
//@OrgCacheKey的注解的属性
private Field orgCacheKeyField;
private OrgCacheKey orgCacheKey;// @OrgCacheKey对象
//与OrgCacheKey的key相关的OrgCacheValue注解对象及对象的Field
private Map<OrgCacheValue,Field> orgCacheValueFieldMap=new HashMap<OrgCacheValue,Field>();
//CacheStaffInfo,CacheDeptInfo,CacheCopanyInfo的放射封装类
private Mirror<?> cacheBaseMirror;
public Field getOrgCacheKeyField() {
return orgCacheKeyField;
}
public void setOrgCacheKeyField(Field orgCacheKeyField) {
this.orgCacheKeyField = orgCacheKeyField;
}
public Mirror<?> getCacheBaseMirror() {
return cacheBaseMirror;
}
public void setCacheBaseMirror(Mirror<?> cacheBaseMirror) {
this.cacheBaseMirror = cacheBaseMirror;
}
public OrgCacheKey getOrgCacheKey() {
return orgCacheKey;
}
public void setOrgCacheKey(OrgCacheKey orgCacheKey) {
this.orgCacheKey = orgCacheKey;
}
public void addOrgCacheValueField(OrgCacheValue orgCacheValue,Field orgCacheValueField){
orgCacheValueFieldMap.put(orgCacheValue,orgCacheValueField);
}
public Map<OrgCacheValue, Field> getOrgCacheValueFieldMap() {
return orgCacheValueFieldMap;
}
}
/**
* orgCacheService
*/
public CacheCallBack(){
this.orgCacheService=SpringUtils.getBean(IOrgCacheService.class);
}
/**
* .
* @param orgCacheService
*/
public CacheCallBack(IOrgCacheService orgCacheService){
this.orgCacheService=orgCacheService;
}
private IOrgCacheService orgCacheService;
private Mirror<?> elemirror=null;
private Map<String,InnerCacheCallBack> innerCacheCallBackMap=new HashMap<String,InnerCacheCallBack>();
/**
* .
* @param ele
*/
private void init(T ele){
elemirror = Mirror.me(ele.getClass());//获取ele对象的反射类
//获取含有:OrgCacheKey的属性对象,初始化InnerCacheCallBack对象.
Field[] orgCacheKeyField=elemirror.getFields(OrgCacheKey.class);
for (int i = 0; i < orgCacheKeyField.length; i++) {
InnerCacheCallBack innerCacheCallBack=new InnerCacheCallBack();
innerCacheCallBack.setOrgCacheKeyField(orgCacheKeyField[i]);
innerCacheCallBack.setOrgCacheKey(orgCacheKeyField[i].getAnnotation(OrgCacheKey.class));
innerCacheCallBackMap.put(innerCacheCallBack.getOrgCacheKey().id(), innerCacheCallBack);
OrgCacheTypeNum typeNum=innerCacheCallBack.getOrgCacheKey().type();
switch(typeNum){
case CacheUserInfo:
innerCacheCallBack.setCacheBaseMirror( Mirror.me(CacheSysUser.class));
break;
case CacheDeptInfo:
innerCacheCallBack.setCacheBaseMirror( Mirror.me(CacheSysDept.class));
break;
default:
log.warnf("无法识别的枚举类型:%s",typeNum.toString());
continue;
}
}
Field[] aOrgCacheValueField=elemirror.getFields(OrgCacheValue.class);
for (int i = 0; i < aOrgCacheValueField.length; i++) {
OrgCacheValue orgCacheValue=aOrgCacheValueField[i].getAnnotation(OrgCacheValue.class);
if(innerCacheCallBackMap.containsKey(orgCacheValue.id())){
innerCacheCallBackMap.get(orgCacheValue.id()).addOrgCacheValueField(orgCacheValue,aOrgCacheValueField[i]);
} else{
log.warnf("找不到id:%s对应的Cache对象.请检查的@OrgCacheValue注解 id值类:%s,属性:%s注解",
orgCacheValue.id(),ele.getClass(),aOrgCacheValueField[i].getName());
}
}
}
@Override
public void invoke(int index, T ele, int length) throws ExitLoop, ContinueLoop, LoopException {
if(elemirror==null){
init(ele);
}
for (Iterator<Map.Entry<String, InnerCacheCallBack>> iterator = innerCacheCallBackMap.entrySet().iterator(); iterator.hasNext();) {
/**
* BaseCache.
*/
Map.Entry<String, InnerCacheCallBack> type = iterator.next();
InnerCacheCallBack innerCacheCallBack=type.getValue();
Mirror<?> cacheBaseMirror=innerCacheCallBack.getCacheBaseMirror();
Object orgCacheKeyFieldValue=cacheBaseMirror.getValue(ele, innerCacheCallBack.getOrgCacheKeyField());
if(orgCacheKeyFieldValue==null)//获取的orgCacheKeyFieldValue 对应的值为null 就不需要在进入后续的循环了.
continue;
OrgCacheTypeNum typeNum=innerCacheCallBack.getOrgCacheKey().type();
BaseCache baseCache=null;
switch(typeNum){
case CacheUserInfo:
baseCache=orgCacheService.getSysUser((Long)orgCacheKeyFieldValue).orElse(null);
if(baseCache==null){
log.warnf("userId:%s获取到CacheStaffInfo的缓存数据是空。请检查Redis服务器.",orgCacheKeyFieldValue);
continue;
}
break;
case CacheDeptInfo:
baseCache=orgCacheService.getDeptInfo((Long)orgCacheKeyFieldValue).orElse(null);
if(baseCache==null){
log.warnf("deptId:%s获取到CacheDeptInfo的缓存数据是空。请检查Redis服务器.",orgCacheKeyFieldValue);
continue;
}
break;
default:
log.warnf("无法识别的枚举类型:%s",typeNum.toString());
continue;
}
/**
* BaseCacheele.
*/
for (Iterator<Map.Entry<OrgCacheValue,Field>> iterator2 = innerCacheCallBack.getOrgCacheValueFieldMap().entrySet().iterator(); iterator2.hasNext();) {
Map.Entry<OrgCacheValue,Field> type2 = iterator2.next();
OrgCacheValue orgCacheValue=type2.getKey();
Field orgCacheValueField=type2.getValue();
Object orgCacheValueFieldValue=cacheBaseMirror.getValue(baseCache, orgCacheValue.value());
elemirror.setValue(ele, orgCacheValueField, orgCacheValueFieldValue);
}
}
}
}

@ -0,0 +1,58 @@
package com.ruoyi.cache.service;
import java.util.Optional;
import com.ruoyi.cache.domain.CacheSysDept;
import com.ruoyi.cache.domain.CacheSysUser;
/**
*
* ecache. :redis.
* @author Condy
*
*/
public interface IOrgCacheService {
/**
* redis.
* @param staffInfo
* @return
*/
public CacheSysUser saveSysUser(CacheSysUser cacheSysUser);
/**
*
* @param userId
*/
public void deleteSysUser(Long userId);
/**
* redis,ecacheredis.
* @param staffId
* @return CacheStaffInfo staffIdnull
*/
public Optional<CacheSysUser> getSysUser(long userId);
/**
* redis.
* @param deptId
* @return null
*/
public Optional<CacheSysDept> getDeptInfo(long deptId);
/**
* redis
* @param cacheDeptInfo
* @return
*/
public CacheSysDept saveDeptInfo(CacheSysDept cacheDeptInfo);
/**
*
* @param deptId
*/
public void deleteDeptInfo(Long deptId);
}

@ -0,0 +1,29 @@
package com.ruoyi.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.util.RedisNotifyService;
import com.ruoyi.util.SpringLoadComplete;
@Configuration
@EnableCaching
@Component
public class CacheConfigurer {
@Autowired
private RedisService redisService;
@Bean
public SpringLoadComplete getSpringLoadComplete() {
return new SpringLoadComplete();
}
@Bean
public RedisNotifyService getRedisNotifyService() {
RedisNotifyService notifyService= new RedisNotifyService(redisService);
return notifyService;
}
}

@ -0,0 +1,173 @@
package com.ruoyi.system.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.BulletinInfo;
import com.ruoyi.system.domain.BulletinRecive;
import com.ruoyi.system.service.IBulletinInfoService;
import com.ruoyi.system.service.IBulletinReciveService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
/**
* Controller
*
* @author ruoyi
* @date 2023-03-09
*/
@RestController
@RequestMapping("/bulletin")
public class BulletinInfoController extends BaseController
{
@Autowired
private IBulletinInfoService bulletinInfoService;
@Autowired
private IBulletinReciveService bulletinReciveService;
/**
*
*/
@RequiresPermissions("system:bulletin:list")
@GetMapping("/list")
public TableDataInfo list(BulletinInfo bulletinInfo)
{
startPage();
List<BulletinInfo> list = bulletinInfoService.selectBulletinInfoList(bulletinInfo);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("system:bulletin:query")
@GetMapping(value = "/{bulletinId}")
public AjaxResult getInfo(@PathVariable("bulletinId") String bulletinId)
{
return success(bulletinInfoService.selectBulletinInfoByBulletinId(bulletinId));
}
/**
*
*/
@RequiresPermissions("system:bulletin:add")
@Log(title = "公告栏", businessType = BusinessType.OTHER)
@PostMapping("/batchSend/{bulletinIds}")
public AjaxResult batchSend(@PathVariable String[] bulletinIds)
{
return toAjax(bulletinInfoService.sendBulletinInfo(bulletinIds));
}
/**
*
*/
@RequiresPermissions("system:bulletin:add")
@Log(title = "公告栏", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody BulletinInfo bulletinInfo)
{
return toAjax(bulletinInfoService.insertBulletinInfo(bulletinInfo));
}
/**
*
*/
@RequiresPermissions("system:bulletin:edit")
@Log(title = "公告栏", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody BulletinInfo bulletinInfo)
{
return toAjax(bulletinInfoService.updateBulletinInfo(bulletinInfo));
}
/**
*
*/
@RequiresPermissions("system:bulletin:remove")
@Log(title = "公告栏", businessType = BusinessType.DELETE)
@DeleteMapping("/delete/{bulletinIds}")
public AjaxResult removePysical(@PathVariable String[] bulletinIds)
{
return toAjax(bulletinInfoService.deleteBulletinInfoByBulletinIds(bulletinIds,"D"));
}
/**
*
*/
@RequiresPermissions("system:bulletin:remove")
@Log(title = "公告栏", businessType = BusinessType.DELETE)
@DeleteMapping("/{bulletinIds}")
public AjaxResult remove(@PathVariable String[] bulletinIds)
{
return toAjax(bulletinInfoService.deleteBulletinInfoByBulletinIds(bulletinIds,"B"));
}
/**
*
*/
@RequiresPermissions("system:bulletin:edit")
@PutMapping("/recive/batchRead/{reciveIds}")
public AjaxResult batchRead(@PathVariable String[] reciveIds)
{
return toAjax(bulletinReciveService.batchRead(reciveIds));
}
/**
*
*/
@RequiresPermissions("system:bulletin:list")
@GetMapping("/recive/list")
public TableDataInfo reciveList(BulletinRecive bulletinRecive)
{
startPage();
List<BulletinInfo> list = bulletinReciveService.selectBulletinReciveList(bulletinRecive);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("system:bulletin:remove")
@Log(title = "公告接收者", businessType = BusinessType.DELETE)
@DeleteMapping("/recive/{reciveIds}")
public AjaxResult reciveRemove(@PathVariable String[] reciveIds)
{
return toAjax(bulletinReciveService.deleteBulletinReciveByReciveIds(reciveIds));
}
/**
*
*/
@RequiresPermissions("system:bulletin:remove")
@Log(title = "公告接收者", businessType = BusinessType.DELETE)
@DeleteMapping("/recive/delete/{reciveIds}")
public AjaxResult recivePhysicalRemove(@PathVariable String[] reciveIds)
{
return toAjax(bulletinReciveService.deletePhysicalBulletinReciveByReciveIds(reciveIds));
}
/**
*
*/
@RequiresPermissions("system:bulletin:query")
@GetMapping(value = "/recive/{reciveId}")
public AjaxResult getReciveInfo(@PathVariable("reciveId") String reciveId)
{
return success(bulletinReciveService.selectBulletinReciveByReciveId(reciveId));
}
}

@ -0,0 +1,242 @@
package com.ruoyi.system.domain;
import java.util.List;
import javax.validation.constraints.NotEmpty;
import java.util.Collections;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* t_bulletin_info
*
* @author ruoyi
* @date 2023-03-09
*/
public class BulletinInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 公告ID */
private String bulletinId;
/** 公告标题 */
@Excel(name = "公告标题")
@NotEmpty(message = "公告标题不允许为空")
private String title;
/** 公告内容 */
@Excel(name = "公告内容")
private String content;
/** 已读人数 */
@Excel(name = "已读人数")
private Long readNum;
/** 公告的发送时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "公告的发送时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date sendTime;
/** 员工ID */
@Excel(name = "员工ID")
private Long createUserId;
/** 更新员工 */
@Excel(name = "更新员工")
private Long updateUserId;
/** 状态 */
@Excel(name = "状态")
@NotEmpty(message = "状态不允许为空")
private String sts;
/** 公告接收者信息 */
private List<BulletinRecive> bulletinReciveList;
/**
* BulletinRecive
*/
private List<Long> receiveStaffIds;
/**
*
*/
private String reciveStaffNames;
public String getReciveStaffNames() {
return reciveStaffNames;
}
public void setReciveStaffNames(String reciveStaffNames) {
this.reciveStaffNames = reciveStaffNames;
}
public List<Long> getReceiveStaffIds() {
if(receiveStaffIds==null) {
receiveStaffIds=Collections.emptyList();
}
return receiveStaffIds;
}
public void setReceiveStaffIds(List<Long> receiveStaffIds) {
this.receiveStaffIds = receiveStaffIds;
}
/**
* BulletinId
* @param ID
*/
public void setBulletinId(String bulletinId)
{
this.bulletinId = bulletinId;
}
/**
* ID
* @return
*/
public String getBulletinId()
{
return bulletinId;
}
/**
* Title
* @param
*/
public void setTitle(String title)
{
this.title = title;
}
/**
*
* @return
*/
public String getTitle()
{
return title;
}
/**
* Content
* @param
*/
public void setContent(String content)
{
this.content = content;
}
/**
*
* @return
*/
public String getContent()
{
return content;
}
/**
* ReadNum
* @param
*/
public void setReadNum(Long readNum)
{
this.readNum = readNum;
}
/**
*
* @return
*/
public Long getReadNum()
{
return readNum;
}
/**
* SendTime
* @param
*/
public void setSendTime(Date sendTime)
{
this.sendTime = sendTime;
}
/**
*
* @return
*/
public Date getSendTime()
{
return sendTime;
}
/**
* CreateUserId
* @param ID
*/
public void setCreateUserId(Long createUserId)
{
this.createUserId = createUserId;
}
/**
* ID
* @return
*/
public Long getCreateUserId()
{
return createUserId;
}
/**
* UpdateUserId
* @param
*/
public void setUpdateUserId(Long updateUserId)
{
this.updateUserId = updateUserId;
}
/**
*
* @return
*/
public Long getUpdateUserId()
{
return updateUserId;
}
/**
* Sts
* @param
*/
public void setSts(String sts)
{
this.sts = sts;
}
/**
*
* @return
*/
public String getSts()
{
return sts;
}
public List<BulletinRecive> getBulletinReciveList()
{
return bulletinReciveList;
}
public void setBulletinReciveList(List<BulletinRecive> bulletinReciveList)
{
this.bulletinReciveList = bulletinReciveList;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("bulletinId", getBulletinId())
.append("title", getTitle())
.append("content", getContent())
.append("createTime", getCreateTime())
.append("readNum", getReadNum())
.append("sendTime", getSendTime())
.append("createUserId", getCreateUserId())
.append("updateUserId", getUpdateUserId())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("sts", getSts())
.append("bulletinReciveList", getBulletinReciveList())
.toString();
}
}

@ -0,0 +1,209 @@
package com.ruoyi.system.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* t_bulletin_recive
*
* @author ruoyi
* @date 2023-03-09
*/
public class BulletinRecive extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 接收ID */
private String reciveId;
/** 接收员工ID */
@Excel(name = "接收员工ID")
private Long reciveUserId;
/**
* ID
*/
private Long reciveDeptId;
/** 阅读时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "阅读时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date readTime;
/** 阅读次数 */
@Excel(name = "阅读次数")
private Long readNum;
/** 员工ID */
@Excel(name = "员工ID")
private Long createUserId;
/** 更新员工 */
@Excel(name = "更新员工")
private Long updateUserId;
/** 公告ID */
@Excel(name = "公告ID")
private String bulletinId;
/** A:已阅读B:已删除 C:未阅读 */
@Excel(name = "A:已阅读B:已删除 C:未阅读")
private String sts;
public Long getReciveDeptId() {
return reciveDeptId;
}
public void setReciveDeptId(Long reciveDeptId) {
this.reciveDeptId = reciveDeptId;
}
/**
* ReciveId
* @param ID
*/
public void setReciveId(String reciveId)
{
this.reciveId = reciveId;
}
/**
* ID
* @return
*/
public String getReciveId()
{
return reciveId;
}
/**
* ReciveUserId
* @param ID
*/
public void setReciveUserId(Long reciveUserId)
{
this.reciveUserId = reciveUserId;
}
/**
* ID
* @return
*/
public Long getReciveUserId()
{
return reciveUserId;
}
/**
* ReadTime
* @param
*/
public void setReadTime(Date readTime)
{
this.readTime = readTime;
}
/**
*
* @return
*/
public Date getReadTime()
{
return readTime;
}
/**
* ReadNum
* @param
*/
public void setReadNum(Long readNum)
{
this.readNum = readNum;
}
/**
*
* @return
*/
public Long getReadNum()
{
return readNum;
}
/**
* CreateUserId
* @param ID
*/
public void setCreateUserId(Long createUserId)
{
this.createUserId = createUserId;
}
/**
* ID
* @return
*/
public Long getCreateUserId()
{
return createUserId;
}
/**
* UpdateUserId
* @param
*/
public void setUpdateUserId(Long updateUserId)
{
this.updateUserId = updateUserId;
}
/**
*
* @return
*/
public Long getUpdateUserId()
{
return updateUserId;
}
/**
* BulletinId
* @param ID
*/
public void setBulletinId(String bulletinId)
{
this.bulletinId = bulletinId;
}
/**
* ID
* @return
*/
public String getBulletinId()
{
return bulletinId;
}
/**
* Sts
* @param A:B: C:
*/
public void setSts(String sts)
{
this.sts = sts;
}
/**
* A:B: C:
* @return
*/
public String getSts()
{
return sts;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("reciveId", getReciveId())
.append("reciveUserId", getReciveUserId())
.append("readTime", getReadTime())
.append("readNum", getReadNum())
.append("createTime", getCreateTime())
.append("createUserId", getCreateUserId())
.append("updateUserId", getUpdateUserId())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.append("bulletinId", getBulletinId())
.append("sts", getSts())
.toString();
}
}

@ -0,0 +1,95 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.BulletinInfo;
import com.ruoyi.system.domain.BulletinRecive;
/**
* Mapper
*
* @author ruoyi
* @date 2023-03-09
*/
public interface BulletinInfoMapper
{
/**
*
*
* @param bulletinId
* @return
*/
public BulletinInfo selectBulletinInfoByBulletinId(String bulletinId);
/**
*
*
* @param bulletinInfo
* @return
*/
public List<BulletinInfo> selectBulletinInfoList(BulletinInfo bulletinInfo);
/**
* bulletinId
* @param bulletinIds
* @return
*/
public List<BulletinInfo> selectBulletinInfoListbyBulletinIds(String[] bulletinIds);
/**
*
*
* @param bulletinInfo
* @return
*/
public int insertBulletinInfo(BulletinInfo bulletinInfo);
/**
*
*
* @param bulletinInfo
* @return
*/
public int updateBulletinInfo(BulletinInfo bulletinInfo);
/**
*
*
* @param bulletinId
* @return
*/
public int deleteBulletinInfoByBulletinId(String bulletinId);
/**
*
*
* @param bulletinIds
* @return
*/
public int deleteBulletinInfoByBulletinIds(String[] bulletinIds);
/**
*
*
* @param bulletinIds
* @return
*/
public int deleteBulletinReciveByBulletinIds(String[] bulletinIds);
/**
*
*
* @param bulletinReciveList
* @return
*/
public int batchBulletinRecive(List<BulletinRecive> bulletinReciveList);
/**
*
*
* @param bulletinId ID
* @return
*/
public int deleteBulletinReciveByBulletinId(String bulletinId);
}

@ -0,0 +1,74 @@
package com.ruoyi.system.mapper;
import java.util.List;
import com.ruoyi.system.domain.BulletinRecive;
/**
* Mapper
*
* @author ruoyi
* @date 2023-03-09
*/
public interface BulletinReciveMapper
{
/**
*
* @param bulletinRecive
* @return
*/
public int batchUpdateRead(String[] reciveIds);
/**
* bulletinIdreciveUserId
* @param bulletinIds
* @return
*/
public List<BulletinRecive> selectBulletinReciveUserIdByBulletinIds(String[] bulletinIds);
/**
*
*
* @param reciveId
* @return
*/
public BulletinRecive selectBulletinReciveByReciveId(String reciveId);
/**
*
*
* @param bulletinRecive
* @return
*/
public List<BulletinRecive> selectBulletinReciveList(BulletinRecive bulletinRecive);
/**
*
*
* @param bulletinRecive
* @return
*/
public int insertBulletinRecive(BulletinRecive bulletinRecive);
/**
*
*
* @param bulletinRecive
* @return
*/
public int updateBulletinRecive(BulletinRecive bulletinRecive);
/**
*
*
* @param reciveId
* @return
*/
public int deleteBulletinReciveByReciveId(String reciveId);
/**
*
*
* @param reciveIds
* @return
*/
public int deleteBulletinReciveByReciveIds(String[] reciveIds);
}

@ -0,0 +1,69 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.BulletinInfo;
/**
* Service
*
* @author ruoyi
* @date 2023-03-09
*/
public interface IBulletinInfoService
{
/**
*
*
* @param bulletinId
* @return
*/
public BulletinInfo selectBulletinInfoByBulletinId(String bulletinId);
/**
*
*
* @param bulletinInfo
* @return
*/
public List<BulletinInfo> selectBulletinInfoList(BulletinInfo bulletinInfo);
/**
*
*
* @param bulletinInfo
* @return
*/
public int insertBulletinInfo(BulletinInfo bulletinInfo);
/**
*
*
* @param bulletinInfo
* @return
*/
public int updateBulletinInfo(BulletinInfo bulletinInfo);
/**
*
*
* @param bulletinIds
* @param sts B:D:
* @return
*/
public int deleteBulletinInfoByBulletinIds(String[] bulletinIds,String sts);
/**
*
*
* @param bulletinId
* @return
*/
public int deleteBulletinInfoByBulletinId(String bulletinId);
/**
*
* @param bulletinIds
* @return
*/
int sendBulletinInfo(String[] bulletinIds);
}

@ -0,0 +1,78 @@
package com.ruoyi.system.service;
import java.util.List;
import com.ruoyi.system.domain.BulletinInfo;
import com.ruoyi.system.domain.BulletinRecive;
/**
* Service
*
* @author ruoyi
* @date 2023-03-09
*/
public interface IBulletinReciveService
{
/**
*
*
* @param reciveId
* @return
*/
public BulletinRecive selectBulletinReciveByReciveId(String reciveId);
/**
*
*
* @param bulletinRecive
* @return
*/
public List<BulletinInfo> selectBulletinReciveList(BulletinRecive bulletinRecive);
/**
*
*
* @param bulletinRecive
* @return
*/
public int insertBulletinRecive(BulletinRecive bulletinRecive);
/**
*
*
* @param bulletinRecive
* @return
*/
public int updateBulletinRecive(BulletinRecive bulletinRecive);
/**
*
*
* @param reciveIds
* @return
*/
public int deleteBulletinReciveByReciveIds(String[] reciveIds);
/**
*
*
* @param reciveId
* @return
*/
public int deleteBulletinReciveByReciveId(String reciveId);
/**
*
* @param reciveIds
* @return
*/
int batchRead(String[] reciveIds);
/**
*
*
* @param reciveIds
* @return
*/
int deletePhysicalBulletinReciveByReciveIds(String[] reciveIds);
}

@ -0,0 +1,239 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import java.util.stream.Collectors;
import com.ruoyi.cache.service.IOrgCacheService;
import com.ruoyi.common.core.utils.DateUtils;
import org.apache.commons.lang3.StringUtils;
import org.nutz.lang.util.NutMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.system.domain.BulletinRecive;
import com.ruoyi.system.mapper.BulletinInfoMapper;
import com.ruoyi.system.mapper.BulletinReciveMapper;
import com.ruoyi.system.domain.BulletinInfo;
import com.ruoyi.system.service.IBulletinInfoService;
import com.ruoyi.util.IDUtil;
/**
* Service
*
* @author ruoyi
* @date 2023-03-09
*/
@Service
public class BulletinInfoServiceImpl implements IBulletinInfoService
{
private Logger log=LoggerFactory.getLogger(BulletinInfoServiceImpl.class);
@Autowired
private BulletinInfoMapper bulletinInfoMapper;
@Autowired
private BulletinReciveMapper bulletinReciveMapper;
@Autowired
private IOrgCacheService orgCacheService;
/**
*
*
* @param bulletinId
* @return
*/
@Override
public BulletinInfo selectBulletinInfoByBulletinId(String bulletinId)
{
List<BulletinRecive> reciveUserIdAndbulletinId=bulletinReciveMapper.selectBulletinReciveUserIdByBulletinIds(new String[] {bulletinId});
BulletinInfo info= bulletinInfoMapper.selectBulletinInfoByBulletinId(bulletinId);
info.setCreateBy(orgCacheService.getSysUser(info.getCreateUserId()).map(sysUser->sysUser.getUserName()).orElse(""));
info.setUpdateBy(orgCacheService.getSysUser(info.getUpdateUserId()).map(sysUser->sysUser.getUserName()).orElse(""));
List<Long> reciveUserIdList=reciveUserIdAndbulletinId.stream().map(userId->userId.getReciveUserId()).collect(Collectors.toList());
info.setReceiveStaffIds(reciveUserIdList);
info.setReciveStaffNames(StringUtils.join(reciveUserIdList.iterator(), ","));
return info;
}
/**
*
*
* @param bulletinInfo
* @return
*/
@Override
public List<BulletinInfo> selectBulletinInfoList(BulletinInfo bulletinInfo)
{
bulletinInfo.setCreateUserId(SecurityUtils.getUserId());
List<BulletinInfo> list=bulletinInfoMapper.selectBulletinInfoList(bulletinInfo);
String[] bulletinIds=list.stream().map(info->info.getBulletinId()).toArray(String[]::new);
if(bulletinIds.length>0) {
final NutMap reciveUserNameMap=NutMap.NEW();
final NutMap reciveBulletinReciveMap=NutMap.NEW();
List<BulletinRecive> reciveUserIdAndbulletinIdList=bulletinReciveMapper.selectBulletinReciveUserIdByBulletinIds(bulletinIds);
reciveUserIdAndbulletinIdList.forEach(reciveUserIdAndBulletinId->{
String reciveUserName=orgCacheService.getSysUser(reciveUserIdAndBulletinId.getReciveUserId()).map(sysUser->sysUser.getUserName()).orElse("");
reciveUserNameMap.addv2(reciveUserIdAndBulletinId.getBulletinId(), reciveUserName);
reciveBulletinReciveMap.addv2(reciveUserIdAndBulletinId.getBulletinId(), reciveUserIdAndBulletinId);
});
list.forEach(info->{
String reciveStaffNames=String.join(",", reciveUserNameMap.getList(info.getBulletinId(), String.class, Collections.emptyList()));
info.setReciveStaffNames(reciveStaffNames);
info.setCreateBy(orgCacheService.getSysUser(info.getCreateUserId()).map(sysUser->sysUser.getUserName()).orElse(""));
info.setBulletinReciveList(reciveBulletinReciveMap.getList(info.getBulletinId(), BulletinRecive.class,Collections.emptyList()));
});
}
return list;
}
/**
*
* @param bulletinIds
* @return
*/
@Override
public int sendBulletinInfo(String[] bulletinIds) {
int updateCount=0;
for (String bulletinId : bulletinIds) {
log.info("发送公告,bulletinId:{}",bulletinId);
BulletinInfo info=new BulletinInfo();
info.setBulletinId(bulletinId);
info.setSendTime(DateUtils.getNowDate());
info.setUpdateUserId(SecurityUtils.getUserId());
info.setUpdateTime(info.getSendTime());
info.setSts("A");
updateCount+=bulletinInfoMapper.updateBulletinInfo(info);
}
return updateCount;
}
/**
*
* @param bulletinId
* @return
*/
private boolean pushBulletinToClient(String bulletinId) {
//TODO 发送公告的业务逻辑还没做,需要获取在线用户,推送给对方
log.info("发送公告,bulletinId:{} 业务逻辑还是空的",bulletinId);
return true;
}
/**
*
*
* @param bulletinInfo
* @return
*/
@Transactional
@Override
public int insertBulletinInfo(BulletinInfo bulletinInfo)
{
bulletinInfo.setBulletinId(IDUtil.getStrId());
Long userId=SecurityUtils.getUserId();
bulletinInfo.setCreateUserId(userId);
Date currDate=DateUtils.getNowDate();
bulletinInfo.setCreateTime(currDate);
bulletinInfo.setUpdateTime(currDate);
bulletinInfo.setUpdateUserId(userId);
if("A".equals(bulletinInfo.getSts())) {
bulletinInfo.setSendTime(bulletinInfo.getCreateTime());
}
bulletinInfo.setReadNum(0L);
int rows = bulletinInfoMapper.insertBulletinInfo(bulletinInfo);
insertBulletinRecive(bulletinInfo);
pushBulletinToClient(bulletinInfo.getBulletinId());
return rows;
}
/**
*
*
* @param bulletinInfo
* @return
*/
@Transactional
@Override
public int updateBulletinInfo(BulletinInfo bulletinInfo)
{
bulletinInfo.setUpdateTime(DateUtils.getNowDate());
bulletinInfo.setUpdateUserId(SecurityUtils.getUserId());
if(!bulletinInfo.getReceiveStaffIds().isEmpty()) {
bulletinInfoMapper.deleteBulletinReciveByBulletinId(bulletinInfo.getBulletinId());
insertBulletinRecive(bulletinInfo);
}
return bulletinInfoMapper.updateBulletinInfo(bulletinInfo);
}
/**
*
*
* @param bulletinIds
* @return
*/
@Transactional
@Override
public int deleteBulletinInfoByBulletinIds(String[] bulletinIds,String sts)
{
int iCount=0;
for (String bulletinId : bulletinIds) {
BulletinInfo bulletinInfo=new BulletinInfo();
bulletinInfo.setBulletinId(bulletinId);
bulletinInfo.setUpdateTime(DateUtils.getNowDate());
bulletinInfo.setUpdateUserId(SecurityUtils.getUserId());
bulletinInfo.setSts(sts);
iCount+=bulletinInfoMapper.updateBulletinInfo(bulletinInfo);
}
return iCount;
}
/**
*
*
* @param bulletinId
* @return
*/
@Transactional
@Override
public int deleteBulletinInfoByBulletinId(String bulletinId)
{
return deleteBulletinInfoByBulletinIds(new String[] {bulletinId},"B");
}
/**
*
*
* @param bulletinInfo
*/
public void insertBulletinRecive(BulletinInfo bulletinInfo)
{
List<Long> reciveUserIdList=bulletinInfo.getReceiveStaffIds();
String bulletinId = bulletinInfo.getBulletinId();
List<BulletinRecive> reciveList=new ArrayList<>(reciveUserIdList.size());
Date now=DateUtils.getNowDate();
bulletinInfo.setBulletinReciveList(reciveList);
Long userId=SecurityUtils.getUserId();
for (Long reciveUserId : reciveUserIdList) {
BulletinRecive bulletinRecive=new BulletinRecive();
bulletinRecive.setBulletinId(bulletinId);
bulletinRecive.setCreateTime(now);
bulletinRecive.setCreateUserId(userId);
bulletinRecive.setUpdateTime(now);
bulletinRecive.setUpdateUserId(userId);
bulletinRecive.setReadNum(0L);
bulletinRecive.setSts("C");
bulletinRecive.setReciveUserId(reciveUserId);
bulletinRecive.setReciveId(IDUtil.getStrId());
reciveList.add(bulletinRecive);
}
if (reciveList.size() > 0)
{
bulletinInfoMapper.batchBulletinRecive(reciveList);
}
}
}

@ -0,0 +1,166 @@
package com.ruoyi.system.service.impl;
import java.util.Collections;
import java.util.List;
import com.ruoyi.cache.service.IOrgCacheService;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.nutz.lang.util.NutMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.system.mapper.BulletinInfoMapper;
import com.ruoyi.system.mapper.BulletinReciveMapper;
import com.ruoyi.system.domain.BulletinInfo;
import com.ruoyi.system.domain.BulletinRecive;
import com.ruoyi.system.service.IBulletinReciveService;
/**
* Service
*
* @author ruoyi
* @date 2023-03-09
*/
@Service
public class BulletinReciveServiceImpl implements IBulletinReciveService
{
@Autowired
private BulletinReciveMapper bulletinReciveMapper;
@Autowired
private BulletinInfoMapper bulletinInfoMapper;
@Autowired
private IOrgCacheService orgCacheService;
@Transactional
/**
*
* @param reciveIds
* @return
*/
@Override
public int batchRead(String[] reciveIds) {
return bulletinReciveMapper.batchUpdateRead(reciveIds);
}
/**
*
*
* @param reciveId
* @return
*/
@Override
public BulletinRecive selectBulletinReciveByReciveId(String reciveId)
{
return bulletinReciveMapper.selectBulletinReciveByReciveId(reciveId);
}
/**
*
*
* @param bulletinRecive
* @return
*/
@Override
public List<BulletinInfo> selectBulletinReciveList(BulletinRecive bulletinRecive)
{
bulletinRecive.setReciveUserId(SecurityUtils.getUserId());
List<BulletinRecive> reciveList= bulletinReciveMapper.selectBulletinReciveList(bulletinRecive);
if(reciveList.isEmpty()) {
return Collections.emptyList();
}
reciveList.forEach(recive->{
orgCacheService.getSysUser(recive.getReciveUserId()).ifPresent(cacheSysUser->{
recive.setCreateBy(cacheSysUser.getUserName());
recive.setReciveDeptId(cacheSysUser.getDeptId());
});
});
NutMap map=NutMap.NEW();
String[] bulletinIds=new String[reciveList.size()];
for (int i = 0; i < bulletinIds.length; i++) {
BulletinRecive recive=reciveList.get(i);
map.addv2(recive.getBulletinId(), recive);
bulletinIds[i]=recive.getBulletinId();
}
List<BulletinInfo> infoList=bulletinInfoMapper.selectBulletinInfoListbyBulletinIds(bulletinIds);
infoList.forEach(info->{
info.setBulletinReciveList(map.getList(info.getBulletinId(), BulletinRecive.class,Collections.emptyList()));
});
return infoList;
}
/**
*
*
* @param bulletinRecive
* @return
*/
@Override
public int insertBulletinRecive(BulletinRecive bulletinRecive)
{
bulletinRecive.setCreateTime(DateUtils.getNowDate());
return bulletinReciveMapper.insertBulletinRecive(bulletinRecive);
}
/**
*
*
* @param bulletinRecive
* @return
*/
@Override
public int updateBulletinRecive(BulletinRecive bulletinRecive)
{
bulletinRecive.setUpdateTime(DateUtils.getNowDate());
bulletinRecive.setUpdateUserId(SecurityUtils.getUserId());
return bulletinReciveMapper.updateBulletinRecive(bulletinRecive);
}
/**
*
*
* @param reciveIds
* @return
*/
@Override
public int deletePhysicalBulletinReciveByReciveIds(String[] reciveIds)
{
return bulletinReciveMapper.deleteBulletinReciveByReciveIds(reciveIds);
}
/**
*
*
* @param reciveIds
* @return
*/
@Override
@Transactional
public int deleteBulletinReciveByReciveIds(String[] reciveIds)
{
int iCount=0;
for (String reciveId : reciveIds) {
BulletinRecive bulletinRecive=new BulletinRecive();
bulletinRecive.setReciveId(reciveId);
bulletinRecive.setSts("B");
bulletinRecive.setUpdateTime(DateUtils.getNowDate());
bulletinRecive.setUpdateUserId(SecurityUtils.getUserId());
iCount+=bulletinReciveMapper.updateBulletinRecive(bulletinRecive);
}
return iCount;
}
/**
*
*
* @param reciveId
* @return
*/
@Override
public int deleteBulletinReciveByReciveId(String reciveId)
{
return bulletinReciveMapper.deleteBulletinReciveByReciveId(reciveId);
}
}

@ -0,0 +1,160 @@
package com.ruoyi.system.service.impl;
import java.util.Optional;
import org.nutz.lang.util.NutMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;
import com.ruoyi.cache.domain.CacheSysDept;
import com.ruoyi.cache.domain.CacheSysUser;
import com.ruoyi.cache.service.IOrgCacheService;
import com.ruoyi.common.redis.service.RedisService;
import com.ruoyi.system.api.domain.SysDept;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.util.IDUtil;
import com.ruoyi.util.IRedisNotifyHandle;
import com.ruoyi.util.RedisNotifyService;
@Component
/**
*
* @author condy
*
*/
public class OrgCacheServiceImpl implements IOrgCacheService,IRedisNotifyHandle {
@Autowired
private RedisService redisService;
@Autowired
private RedisNotifyService redisNotifyService;
@Autowired
private CacheManager cacheManager;
@Autowired
private SysDeptMapper sysDeptMapper;
@Autowired
private SysUserMapper sysUserMapper;
private final String USER_PRE="RUOYI_USER:";
private final String DEPT_PRE="RUOYI_DEPT:";
private long selfId=IDUtil.getId();
private Logger log=LoggerFactory.getLogger(getClass());
public OrgCacheServiceImpl() {
RedisNotifyService.register(this);
}
@Override
@CachePut(value="org",key="'RUOYI_USER:'+#cacheSysUser.getUserId()")
public CacheSysUser saveSysUser(CacheSysUser cacheSysUser) {
if(cacheSysUser==null || cacheSysUser.getUserId()==null) {
log.warn("保存员工到缓存错误, 员工ID是空的");
return null;
}
redisService.setCacheObject(USER_PRE+cacheSysUser.getUserId(), cacheSysUser);
NutMap params=NutMap.NEW().addv("type", "RUOYI_USER").addv("userId", cacheSysUser.getUserId());
params.addv("selfId", selfId);
redisNotifyService.publish(getRegisterId(), params);
return cacheSysUser;
}
@Override
@Cacheable(value="org",key="'RUOYI_USER:'+#userId")
public Optional<CacheSysUser> getSysUser(long userId) {
CacheSysUser cacheSysUser=redisService.getCacheObject(USER_PRE+userId);
if(cacheSysUser==null) {
SysUser sysUser=sysUserMapper.selectUserById(userId);
if(sysUser!=null) {
cacheSysUser=new CacheSysUser(sysUser);
saveSysUser(cacheSysUser);
}
}
return Optional.ofNullable(cacheSysUser);
}
//除非,#result是空就不缓存
@Override
@Cacheable(value="org",key="'RUOYI_DEPT:'+#deptId")
public Optional<CacheSysDept> getDeptInfo(long deptId) {
CacheSysDept cacheSysDept=redisService.getCacheObject(DEPT_PRE+deptId);
if(cacheSysDept==null) {
SysDept sysDept=sysDeptMapper.selectDeptById(deptId);
if(sysDept!=null) {
cacheSysDept=new CacheSysDept(sysDept);
saveDeptInfo(cacheSysDept);
}
}
return Optional.ofNullable(cacheSysDept);
}
@Override
@CachePut(value="org",key="'RUOYI_DEPT:'+#cacheDeptInfo.getDeptId()")
public CacheSysDept saveDeptInfo(CacheSysDept cacheDeptInfo) {
if(cacheDeptInfo==null || cacheDeptInfo.getDeptId()==null) {
log.warn("保存部门到缓存错误, 部门ID是空的");
return null;
}
redisService.setCacheObject(DEPT_PRE+cacheDeptInfo.getDeptId(), cacheDeptInfo);
NutMap params=NutMap.NEW().addv("type", "RUOYI_DEPT").addv("deptId", cacheDeptInfo.getDeptId());
params.addv("selfId", selfId);
redisNotifyService.publish(getRegisterId(), params);
return cacheDeptInfo;
}
@Override
public void handle(String methodName,NutMap params) {
String type=params.getString("type");
long notifySelfId=params.getLong("selfId");
if(notifySelfId==selfId) {
log.info("selfId:{} 是自己发出的,不做任何处理");
return ;
}
if(USER_PRE.substring(0, USER_PRE.length()-1).equals(type)) {
log.info("把组织架构的staffId:{}的缓存作废",params.getLong("userId"));
cacheManager.getCache("org").evict(USER_PRE+params.getLong("userId"));
} else if (DEPT_PRE.substring(0, DEPT_PRE.length()-1).equals(type)) {
//把某个部门缓存作废.
log.info("把组织架构的deptId:{}的缓存作废",params.getLong("deptId"));
cacheManager.getCache("org").evict(DEPT_PRE+params.getLong("deptId"));
} else {
log.warn("无法识别的type:{}", type);
}
}
@Override
public String getRegisterId() {
return "OrgCacheService";
}
@Override
@CacheEvict(value="org",key="'RUOYI_USER:'+#userId")
public void deleteSysUser(Long userId) {
if(userId==null) {
return ;
}
redisService.deleteObject(USER_PRE+userId);
NutMap params=NutMap.NEW().addv("type", "RUOYI_USER").addv("userId", userId);
params.addv("selfId", selfId);
redisNotifyService.publish(getRegisterId(), params);
}
@Override
@CacheEvict(value="org",key="'RUOYI_DEPT:'+#deptId")
public void deleteDeptInfo(Long deptId) {
if(deptId==null) {
return ;
}
redisService.deleteObject(DEPT_PRE+deptId);
NutMap params=NutMap.NEW().addv("type", "RUOYI_DEPT").addv("deptId", deptId);
params.addv("selfId", selfId);
redisNotifyService.publish(getRegisterId(), params);
}
}

@ -6,6 +6,9 @@ import java.util.List;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.cache.domain.CacheSysDept;
import com.ruoyi.cache.service.IOrgCacheService;
import com.ruoyi.common.core.constant.UserConstants;
import com.ruoyi.common.core.exception.ServiceException;
import com.ruoyi.common.core.text.Convert;
@ -34,6 +37,8 @@ public class SysDeptServiceImpl implements ISysDeptService
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private IOrgCacheService orgCacheService;
/**
*
@ -218,7 +223,12 @@ public class SysDeptServiceImpl implements ISysDeptService
throw new ServiceException("部门停用,不允许新增");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
int updateCount= deptMapper.insertDept(dept);
if(updateCount>0) {
CacheSysDept cacheDept=new CacheSysDept(dept);
orgCacheService.saveDeptInfo(cacheDept);
}
return updateCount;
}
/**
@ -246,6 +256,10 @@ public class SysDeptServiceImpl implements ISysDeptService
// 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept);
}
if(result>0) {
CacheSysDept cacheDept=new CacheSysDept(dept);
orgCacheService.saveDeptInfo(cacheDept);
}
return result;
}

@ -0,0 +1,45 @@
package com.ruoyi.util;
import java.util.Random;
/**
* ID
* @author Condy
*
*/
public class IDUtil {
static private SnowflakeIdWorker id;
static {
Random random=new Random();
int workId=random.nextInt(32);
int datacenterId=random.nextInt(32);
id=new SnowflakeIdWorker(workId,datacenterId);
}
/**
* 18
* @return
*/
static public long getId(){
try {
return id.nextId();
}catch(RuntimeException e) {
//时间被调整回去了,可能是时间同步引起的
if(e.toString().contains("Clock moved backwards")) {
try {Thread.sleep(50);} catch (InterruptedException e1) {}
return id.nextId();
} else {
throw e;
}
}
}
/**
* 18ID
* @return
*/
static public String getStrId(){
return id.nextId()+"";
}
}

@ -0,0 +1,22 @@
package com.ruoyi.util;
import org.nutz.lang.util.NutMap;
/**
* HttpServerRedis
* @author
*
*/
public interface IRedisNotifyHandle {
/**
* json
* @param jsonMessage
*/
public void handle(String method,NutMap params);
/**
* ID,ID.
* @return
*/
public String getRegisterId();
}

@ -0,0 +1,12 @@
package com.ruoyi.util;
import org.springframework.context.ApplicationContext;
public interface ISpringLoadComplete {
/**
*
* @param applicationContext
*/
void callback(ApplicationContext applicationContext);
}

@ -0,0 +1,142 @@
package com.ruoyi.util;
import java.util.HashMap;
import java.util.Map;
import org.nutz.json.Json;
import org.nutz.lang.util.NutMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.data.redis.listener.PatternTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.stereotype.Component;
import com.ruoyi.common.redis.service.RedisService;
/**
* redis,:,.
* @author
*
*/
@Component
public class RedisNotifyService implements MessageListener,ISpringLoadComplete {
private static Map<String,IRedisNotifyHandle> registerMap=new HashMap<String,IRedisNotifyHandle>();
private static Logger LOGGER=LoggerFactory.getLogger(RedisNotifyService.class);
public static final String CHANNEL="ruoyiMessageNotify";
private RedisService redisService;
public RedisNotifyService(RedisService redisService) {
this.redisService=redisService;
SpringLoadComplete.addCallBack(this);
}
/**
*
* @param redisHandle
* @return
*/
public static boolean register(IRedisNotifyHandle redisHandle){
if(registerMap.containsKey(redisHandle.getRegisterId())){
LOGGER.info("已经存在:"+redisHandle.getRegisterId()+",无法注册成功!");
return false;
}else{
LOGGER.info("注册ID:"+redisHandle.getRegisterId()+",注册成功,处理类:"+redisHandle.getClass());
registerMap.put(redisHandle.getRegisterId(), redisHandle);
return true;
}
}
/**
* .
* @param redisHandle
* @return
*/
public static boolean unRegister(IRedisNotifyHandle redisHandle){
return unRegister(redisHandle.getRegisterId());
}
/**
*
* @param registerId
* @return
*/
public static boolean unRegister(String registerId){
if(registerId==null)
return false;
if(registerMap.containsKey(registerId)){
LOGGER.info("注册ID:"+registerId+",取消注册成功!");
registerMap.remove(registerId);
return true;
} else{
return false;
}
}
/**
*
* @param registerId
* @return
*/
public static boolean containRedisHandle(String registerId){
if(registerId==null)
return false;
return registerMap.containsKey(registerId);
}
/**
* .
* @param redisHandle
* @return
*/
public static boolean containRedisHandle(IRedisNotifyHandle redisHandle){
return containRedisHandle(redisHandle.getRegisterId());
}
/**
* JsonRpc
* @param method
* @param params params
*/
public void publish(String method,NutMap params) {
NutMap jsonRpc=NutMap.NEW().addv("method", method).addv("params", params);
redisService.redisTemplate.convertAndSend(CHANNEL,Json.toJson(jsonRpc) );
}
@Override
public void onMessage(Message message, byte[] pattern) {
/**
* Message:{ "method": "sayHello", "params": ["Hello JSON-RPC"], "id": 1}
*/
try {
NutMap jsonMessage=Json.fromJson(NutMap.class,new String(message.getBody(),"UTF-8"));
String registerId=jsonMessage.getString("method",null);
if(containRedisHandle(registerId)){
IRedisNotifyHandle redisHandle=registerMap.get(registerId);
if("casLogout".equals(registerId)) //签出的消息比多更改为debug级别.
LOGGER.debug("recive httpServerRedis message:"+message+",submit to handle class:"+redisHandle.getClass());
else
LOGGER.info("recive httpServerRedis message:"+message+",submit to handle class:"+redisHandle.getClass());
NutMap params=Json.fromJson(NutMap.class,jsonMessage.getString("params","{}"));
redisHandle.handle(registerId,params);
} else{
if("casLogout".equals(registerId))
LOGGER.debug("recive httpServerRedis message:"+message+",but not find any handle class");
else
LOGGER.info("recive httpServerRedis message:"+message+",but not find any handle class");
}
} catch(Exception e) {
LOGGER.error("recive httpServerRedis handle error:"+message,e);
}
}
@Override
public void callback(ApplicationContext applicationContext) {
RedisMessageListenerContainer redisMessageListenerContainer=applicationContext.getBean(RedisMessageListenerContainer.class);
redisMessageListenerContainer.addMessageListener(this, new PatternTopic(CHANNEL));
LOGGER.info("启动监听redischannel:"+CHANNEL);
}
}

@ -0,0 +1,146 @@
package com.ruoyi.util;
/**
* Twitter_Snowflake<br>
* SnowFlake(-):<br>
* 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br>
* 1longJava01id0<br>
* 41()41 - )
* id使IdWorkerstartTime41使69T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br>
* 1010245datacenterId5workerId<br>
* 1212()4096ID<br>
* 64Long<br>
* SnowFlakeID(IDID)SnowFlake26ID
*/
public class SnowflakeIdWorker {
// ==============================Fields===========================================
/** 开始时间截 (2015-01-01) */
private final long twepoch = 1420041600000L;
/** 机器id所占的位数 */
private final long workerIdBits = 5L;
/** 数据标识id所占的位数 */
private final long datacenterIdBits = 5L;
/** 支持的最大机器id结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */
private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
/** 支持的最大数据标识id结果是31 */
private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
/** 序列在id中占的位数 */
private final long sequenceBits = 12L;
/** 机器ID向左移12位 */
private final long workerIdShift = sequenceBits;
/** 数据标识id向左移17位(12+5) */
private final long datacenterIdShift = sequenceBits + workerIdBits;
/** 时间截向左移22位(5+5+12) */
private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
/** 生成序列的掩码这里为4095 (0b111111111111=0xfff=4095) */
private final long sequenceMask = -1L ^ (-1L << sequenceBits);
/** 工作机器ID(0~31) */
private long workerId;
/** 数据中心ID(0~31) */
private long datacenterId;
/** 毫秒内序列(0~4095) */
private long sequence = 0L;
/** 上次生成ID的时间截 */
private long lastTimestamp = -1L;
//==============================Constructors=====================================
/**
*
* @param workerId ID (0~31)
* @param datacenterId ID (0~31)
*/
public SnowflakeIdWorker(long workerId, long datacenterId) {
if (workerId > maxWorkerId || workerId < 0) {
throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
}
if (datacenterId > maxDatacenterId || datacenterId < 0) {
throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
}
this.workerId = workerId;
this.datacenterId = datacenterId;
}
// ==============================Methods==========================================
/**
* ID (线)
* @return SnowflakeId
*/
public synchronized long nextId() {
long timestamp = timeGen();
//如果当前时间小于上一次ID生成的时间戳说明系统时钟回退过这个时候应当抛出异常
if (timestamp < lastTimestamp) {
throw new RuntimeException(
String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
}
//如果是同一时间生成的,则进行毫秒内序列
if (lastTimestamp == timestamp) {
sequence = (sequence + 1) & sequenceMask;
//毫秒内序列溢出
if (sequence == 0) {
//阻塞到下一个毫秒,获得新的时间戳
timestamp = tilNextMillis(lastTimestamp);
}
}
//时间戳改变,毫秒内序列重置
else {
sequence = 0L;
}
//上次生成ID的时间截
lastTimestamp = timestamp;
//移位并通过或运算拼到一起组成64位的ID
return ((timestamp - twepoch) << timestampLeftShift) //
| (datacenterId << datacenterIdShift) //
| (workerId << workerIdShift) //
| sequence;
}
/**
*
* @param lastTimestamp ID
* @return
*/
protected long tilNextMillis(long lastTimestamp) {
long timestamp = timeGen();
while (timestamp <= lastTimestamp) {
timestamp = timeGen();
}
return timestamp;
}
/**
*
* @return ()
*/
protected long timeGen() {
return System.currentTimeMillis();
}
//==============================Test=============================================
/** 测试 */
public static void main(String[] args) {
SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
for (int i = 0; i < 1000; i++) {
long id = idWorker.nextId();
System.out.println(Long.toBinaryString(id));
System.out.println(id);
}
}
}

@ -0,0 +1,45 @@
package com.ruoyi.util;
import java.util.ArrayList;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
@Component
/**
* spring
* @author condy
*
*/
public class SpringLoadComplete implements ApplicationListener<ContextRefreshedEvent>{
private static List<ISpringLoadComplete> callbackList=new ArrayList<>();
private Logger log=LoggerFactory.getLogger(SpringLoadComplete.class);
/**
*
* @param callback
*/
public static void addCallBack(ISpringLoadComplete callback) {
if(!callbackList.contains(callback))
callbackList.add(callback);
}
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
if(event.getApplicationContext().getParent() == null){
try {
for (ISpringLoadComplete callback : callbackList) {
log.info("Spring启动完成,调用回调处理类:{}",callback);
callback.callback(event.getApplicationContext());
}
} catch(Exception e) {
log.error("初始化回调方法错误",e);
}
}
}
}

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://ehcache.org/ehcache.xsd">
<!-- 磁盘缓存位置 -->
<diskStore path="java.io.tmpdir/ehcache"/>
<!-- 默认缓存 -->
<defaultCache
maxEntriesLocalHeap="10000"
eternal="false"
timeToIdleSeconds="120"
timeToLiveSeconds="120"
maxEntriesLocalDisk="10000000"
diskExpiryThreadIntervalSeconds="120"
memoryStoreEvictionPolicy="LRU"/>
<!-- 组织架构的缓存缓存员工部门等信息保留1个小时有效时长 -->
<cache name="org"
maxEntriesLocalHeap="3000"
eternal="false"
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
maxEntriesLocalDisk="10000000"
diskExpiryThreadIntervalSeconds="3600"
memoryStoreEvictionPolicy="LRU"/>
</ehcache>

@ -3,7 +3,10 @@
<!-- 日志存放路径 -->
<property name="log.path" value="logs/ruoyi-system" />
<!-- 日志输出格式 -->
<!--
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n" />
-->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} %-5level %logger - [%method,%line] - %msg%n" />
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
@ -12,6 +15,29 @@
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_debug" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/debug.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/debug.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>4</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>DEBUG</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/info.log</file>
@ -61,14 +87,31 @@
<logger name="com.ruoyi" level="info" />
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn" />
<logger name="springfox" level="info" />
<logger name="org.apache" level="info" />
<logger name="com.alibaba" level="info" />
<logger name="org.hibernate" level="info" />
<logger name="io.lettuce" level="info" />
<logger name="druid.sql" level="info" />
<logger name="org.mybatis" level="info" />
<logger name="io.micrometer" level="info" />
<logger name="com.baomidou" level="info" />
<logger name="io.netty" level="info" />
<logger name="net.sf" level="info" />
<logger name="org.reflections" level="info" />
<!-- Spring日志级别控制 -->
<logger name="com.ruoyi.system.mapper" level="debug" />
<root level="info">
<appender-ref ref="console" />
</root>
<!--系统操作日志-->
<root level="info">
<root level="debug">
<appender-ref ref="file_info" />
<appender-ref ref="file_error" />
<appender-ref ref="file_debug" />
</root>
</configuration>

@ -0,0 +1,145 @@
<?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.ruoyi.system.mapper.BulletinInfoMapper">
<resultMap type="BulletinInfo" id="BulletinInfoResult">
<result property="bulletinId" column="BULLETIN_ID" />
<result property="title" column="TITLE" />
<result property="content" column="CONTENT" />
<result property="createTime" column="CREATE_TIME" />
<result property="readNum" column="READ_NUM" />
<result property="sendTime" column="SEND_TIME" />
<result property="createUserId" column="CREATE_USER_ID" />
<result property="updateUserId" column="UPDATE_USER_ID" />
<result property="updateTime" column="UPDATE_TIME" />
<result property="remark" column="REMARK" />
<result property="sts" column="STS" />
</resultMap>
<resultMap id="BulletinInfoBulletinReciveResult" type="BulletinInfo" extends="BulletinInfoResult">
<collection property="bulletinReciveList" notNullColumn="sub_RECIVE_ID" javaType="java.util.List" resultMap="BulletinReciveResult" />
</resultMap>
<resultMap type="BulletinRecive" id="BulletinReciveResult">
<result property="reciveId" column="sub_RECIVE_ID" />
<result property="reciveUserId" column="sub_RECIVE_USER_ID" />
<result property="readTime" column="sub_READ_TIME" />
<result property="readNum" column="sub_READ_NUM" />
<result property="createTime" column="sub_CREATE_TIME" />
<result property="createUserId" column="sub_CREATE_USER_ID" />
<result property="updateUserId" column="sub_UPDATE_USER_ID" />
<result property="updateTime" column="sub_UPDATE_TIME" />
<result property="remark" column="sub_REMARK" />
<result property="bulletinId" column="sub_BULLETIN_ID" />
<result property="sts" column="sub_STS" />
</resultMap>
<sql id="selectBulletinInfoVo">
select BULLETIN_ID, TITLE, CONTENT, CREATE_TIME, READ_NUM, SEND_TIME, CREATE_USER_ID, UPDATE_USER_ID, UPDATE_TIME, REMARK, STS from t_bulletin_info
</sql>
<select id="selectBulletinInfoList" parameterType="BulletinInfo" resultMap="BulletinInfoResult">
<include refid="selectBulletinInfoVo"/>
<where>
<if test="title != null and title != ''"> and TITLE like concat('%', #{title}, '%')</if>
<if test="createUserId != null and createUserId != ''"> and CREATE_USER_ID = #{createUserId}</if>
<if test="sts != null and sts != ''"> and STS = #{sts}</if>
</where>
order by UPDATE_TIME desc
</select>
<select id="selectBulletinInfoListbyBulletinIds" resultMap="BulletinInfoResult">
<include refid="selectBulletinInfoVo"/> where BULLETIN_ID in
<foreach item="bulletinId" collection="array" open="(" separator="," close=")">
#{bulletinId}
</foreach>
</select>
<select id="selectBulletinInfoByBulletinId" parameterType="Long" resultMap="BulletinInfoBulletinReciveResult">
select a.BULLETIN_ID, a.TITLE, a.CONTENT, a.CREATE_TIME, a.READ_NUM, a.SEND_TIME, a.CREATE_USER_ID, a.UPDATE_USER_ID, a.UPDATE_TIME, a.REMARK, a.STS,
b.RECIVE_ID as sub_RECIVE_ID, b.RECIVE_USER_ID as sub_RECIVE_USER_ID, b.READ_TIME as sub_READ_TIME, b.READ_NUM as sub_READ_NUM, b.CREATE_TIME as sub_CREATE_TIME, b.CREATE_USER_ID as sub_CREATE_USER_ID, b.UPDATE_USER_ID as sub_UPDATE_USER_ID, b.UPDATE_TIME as sub_UPDATE_TIME, b.REMARK as sub_REMARK, b.BULLETIN_ID as sub_BULLETIN_ID, b.STS as sub_STS
from t_bulletin_info a
left join t_bulletin_recive b on b.BULLETIN_ID = a.BULLETIN_ID
where a.BULLETIN_ID = #{bulletinId}
</select>
<insert id="insertBulletinInfo" parameterType="BulletinInfo">
insert into t_bulletin_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bulletinId != null">BULLETIN_ID,</if>
<if test="title != null and title != ''">TITLE,</if>
<if test="content != null and content != ''">CONTENT,</if>
<if test="createTime != null">CREATE_TIME,</if>
<if test="readNum != null">READ_NUM,</if>
<if test="sendTime != null">SEND_TIME,</if>
<if test="createUserId != null and createUserId != ''">CREATE_USER_ID,</if>
<if test="updateUserId != null">UPDATE_USER_ID,</if>
<if test="updateTime != null">UPDATE_TIME,</if>
<if test="remark != null">REMARK,</if>
<if test="sts != null and sts != ''">STS,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bulletinId != null">#{bulletinId},</if>
<if test="title != null and title != ''">#{title},</if>
<if test="content != null and content != ''">#{content},</if>
<if test="createTime != null">#{createTime},</if>
<if test="readNum != null">#{readNum},</if>
<if test="sendTime != null">#{sendTime},</if>
<if test="createUserId != null and createUserId != ''">#{createUserId},</if>
<if test="updateUserId != null">#{updateUserId},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
<if test="sts != null and sts != ''">#{sts},</if>
</trim>
</insert>
<update id="updateBulletinInfo" parameterType="BulletinInfo">
update t_bulletin_info
<trim prefix="SET" suffixOverrides=",">
<if test="title != null and title != ''">TITLE = #{title},</if>
<if test="content != null and content != ''">CONTENT = #{content},</if>
<if test="createTime != null">CREATE_TIME = #{createTime},</if>
<if test="readNum != null">READ_NUM = #{readNum},</if>
<if test="sendTime != null">SEND_TIME = #{sendTime},</if>
<if test="createUserId != null and createUserId != ''">CREATE_USER_ID = #{createUserId},</if>
<if test="updateUserId != null">UPDATE_USER_ID = #{updateUserId},</if>
<if test="updateTime != null">UPDATE_TIME = #{updateTime},</if>
<if test="remark != null">REMARK = #{remark},</if>
<if test="sts != null and sts != ''">STS = #{sts},</if>
</trim>
where BULLETIN_ID = #{bulletinId}
</update>
<delete id="deleteBulletinInfoByBulletinId" parameterType="String">
delete from t_bulletin_info where BULLETIN_ID = #{bulletinId}
</delete>
<delete id="deleteBulletinInfoByBulletinIds" parameterType="String">
delete from t_bulletin_info where BULLETIN_ID in
<foreach item="bulletinId" collection="array" open="(" separator="," close=")">
#{bulletinId}
</foreach>
</delete>
<delete id="deleteBulletinReciveByBulletinIds" parameterType="String">
delete from t_bulletin_recive where BULLETIN_ID in
<foreach item="bulletinId" collection="array" open="(" separator="," close=")">
#{bulletinId}
</foreach>
</delete>
<delete id="deleteBulletinReciveByBulletinId" parameterType="String">
delete from t_bulletin_recive where BULLETIN_ID = #{bulletinId}
</delete>
<insert id="batchBulletinRecive">
insert into t_bulletin_recive( RECIVE_ID, RECIVE_USER_ID, READ_TIME, READ_NUM, CREATE_TIME, CREATE_USER_ID, UPDATE_USER_ID, UPDATE_TIME, REMARK, BULLETIN_ID, STS) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.reciveId}, #{item.reciveUserId}, #{item.readTime}, #{item.readNum}, #{item.createTime}, #{item.createUserId}, #{item.updateUserId}, #{item.updateTime}, #{item.remark}, #{item.bulletinId}, #{item.sts})
</foreach>
</insert>
</mapper>

@ -0,0 +1,124 @@
<?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.ruoyi.system.mapper.BulletinReciveMapper">
<resultMap type="BulletinRecive" id="BulletinReciveResult">
<result property="reciveId" column="RECIVE_ID" />
<result property="reciveUserId" column="RECIVE_USER_ID" />
<result property="readTime" column="READ_TIME" />
<result property="readNum" column="READ_NUM" />
<result property="createTime" column="CREATE_TIME" />
<result property="createUserId" column="CREATE_USER_ID" />
<result property="updateUserId" column="UPDATE_USER_ID" />
<result property="updateTime" column="UPDATE_TIME" />
<result property="remark" column="REMARK" />
<result property="bulletinId" column="BULLETIN_ID" />
<result property="sts" column="STS" />
</resultMap>
<sql id="selectBulletinReciveVo">
select RECIVE_ID, RECIVE_USER_ID, READ_TIME, READ_NUM, CREATE_TIME, CREATE_USER_ID, UPDATE_USER_ID, UPDATE_TIME, REMARK, BULLETIN_ID, STS from t_bulletin_recive
</sql>
<select id="selectBulletinReciveList" parameterType="BulletinRecive" resultMap="BulletinReciveResult">
<include refid="selectBulletinReciveVo"/>
<where>
<if test="reciveUserId != null "> and RECIVE_USER_ID = #{reciveUserId}</if>
<if test="readTime != null "> and READ_TIME = #{readTime}</if>
<if test="readNum != null "> and READ_NUM = #{readNum}</if>
<if test="createTime != null "> and CREATE_TIME = #{createTime}</if>
<if test="createUserId != null and createUserId != ''"> and CREATE_USER_ID = #{createUserId}</if>
<if test="updateUserId != null "> and UPDATE_USER_ID = #{updateUserId}</if>
<if test="updateTime != null "> and UPDATE_TIME = #{updateTime}</if>
<if test="remark != null and remark != ''"> and REMARK = #{remark}</if>
<if test="bulletinId != null "> and BULLETIN_ID = #{bulletinId}</if>
<if test="sts != null and sts != ''"> and STS = #{sts}</if>
<if test="sts == null or sts == ''"> and STS in ('A','C')</if>
</where>
</select>
<select id="selectBulletinReciveUserIdByBulletinIds" parameterType="String" resultMap="BulletinReciveResult">
select RECIVE_USER_ID, BULLETIN_ID from t_bulletin_recive where BULLETIN_ID in
<foreach item="bulletinId" collection="array" open="(" separator="," close=")">
#{bulletinId}
</foreach>
</select>
<select id="selectBulletinReciveByReciveId" parameterType="String" resultMap="BulletinReciveResult">
<include refid="selectBulletinReciveVo"/>
where RECIVE_ID = #{reciveId}
</select>
<insert id="insertBulletinRecive" parameterType="BulletinRecive">
insert into t_bulletin_recive
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="reciveId != null">RECIVE_ID,</if>
<if test="reciveUserId != null">RECIVE_USER_ID,</if>
<if test="readTime != null">READ_TIME,</if>
<if test="readNum != null">READ_NUM,</if>
<if test="createTime != null">CREATE_TIME,</if>
<if test="createUserId != null and createUserId != ''">CREATE_USER_ID,</if>
<if test="updateUserId != null">UPDATE_USER_ID,</if>
<if test="updateTime != null">UPDATE_TIME,</if>
<if test="remark != null and remark != ''">REMARK,</if>
<if test="bulletinId != null">BULLETIN_ID,</if>
<if test="sts != null and sts != ''">STS,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="reciveId != null">#{reciveId},</if>
<if test="reciveUserId != null">#{reciveUserId},</if>
<if test="readTime != null">#{readTime},</if>
<if test="readNum != null">#{readNum},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createUserId != null and createUserId != ''">#{createUserId},</if>
<if test="updateUserId != null">#{updateUserId},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null and remark != ''">#{remark},</if>
<if test="bulletinId != null">#{bulletinId},</if>
<if test="sts != null and sts != ''">#{sts},</if>
</trim>
</insert>
<update id="updateBulletinRecive" parameterType="BulletinRecive">
update t_bulletin_recive
<trim prefix="SET" suffixOverrides=",">
<if test="reciveUserId != null">RECIVE_USER_ID = #{reciveUserId},</if>
<if test="readTime != null">READ_TIME = #{readTime},</if>
<if test="readNum != null">READ_NUM = #{readNum},</if>
<if test="createTime != null">CREATE_TIME = #{createTime},</if>
<if test="createUserId != null and createUserId != ''">CREATE_USER_ID = #{createUserId},</if>
<if test="updateUserId != null">UPDATE_USER_ID = #{updateUserId},</if>
<if test="updateTime != null">UPDATE_TIME = #{updateTime},</if>
<if test="remark != null and remark != ''">REMARK = #{remark},</if>
<if test="bulletinId != null">BULLETIN_ID = #{bulletinId},</if>
<if test="sts != null and sts != ''">STS = #{sts},</if>
</trim>
where RECIVE_ID = #{reciveId}
</update>
<update id="batchUpdateRead">
update t_bulletin_recive set
READ_TIME = sysdate() ,
READ_NUM = READ_NUM+1,
sts ='A',
UPDATE_TIME=sysdate(),
UPDATE_USER_ID = RECIVE_USER_ID
where RECIVE_ID in
<foreach item="reciveId" collection="array" open="(" separator="," close=")">
#{reciveId}
</foreach>
</update>
<delete id="deleteBulletinReciveByReciveId" parameterType="String">
delete from t_bulletin_recive where RECIVE_ID = #{reciveId}
</delete>
<delete id="deleteBulletinReciveByReciveIds" parameterType="String">
delete from t_bulletin_recive where RECIVE_ID in
<foreach item="reciveId" collection="array" open="(" separator="," close=")">
#{reciveId}
</foreach>
</delete>
</mapper>

@ -0,0 +1,56 @@
package com.ruoyi.system.service;
import com.ruoyi.cache.annotation.OrgCacheKey;
import com.ruoyi.cache.annotation.OrgCacheTypeNum;
import com.ruoyi.cache.annotation.OrgCacheValue;
import com.ruoyi.cache.domain.CacheSysUser;
public class CacheCallBackPojo {
@OrgCacheKey
private Long userId;
@OrgCacheValue(value = CacheSysUser.ANNOTAION_DEPT_ID)
private Long deptId;
@OrgCacheValue(value = CacheSysUser.ANNOTAION_USER_NAME)
private String userName;
@OrgCacheValue(value = CacheSysUser.ANNOTAION_PHONENUMBER)
private String phoneNumber;
private String detpName;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getDetpName() {
return detpName;
}
public void setDetpName(String detpName) {
this.detpName = detpName;
}
@Override
public String toString() {
return "CacheCallBackPojo [userId=" + userId + ", deptId=" + deptId + ", userName=" + userName
+ ", phoneNumber=" + phoneNumber + ", detpName=" + detpName + "]";
}
}

@ -0,0 +1,59 @@
package com.ruoyi.system.service;
import com.ruoyi.cache.annotation.OrgCacheKey;
import com.ruoyi.cache.annotation.OrgCacheTypeNum;
import com.ruoyi.cache.annotation.OrgCacheValue;
import com.ruoyi.cache.domain.CacheSysDept;
import com.ruoyi.cache.domain.CacheSysUser;
public class CacheCallBackPojo2 {
@OrgCacheKey(id = "user",type = OrgCacheTypeNum.CacheUserInfo)
private Long userId;
@OrgCacheValue(value = CacheSysUser.ANNOTAION_DEPT_ID)
@OrgCacheKey(id = "dept",type = OrgCacheTypeNum.CacheDeptInfo)
private Long deptId;
@OrgCacheValue(value = CacheSysUser.ANNOTAION_USER_NAME)
private String userName;
@OrgCacheValue(value = CacheSysUser.ANNOTAION_PHONENUMBER)
private String phoneNumber;
@OrgCacheValue(id="dept",value = CacheSysDept.ANNOTAION_DEPT_NAME)
private String detpName;
public Long getUserId() {
return userId;
}
public void setUserId(Long userId) {
this.userId = userId;
}
public Long getDeptId() {
return deptId;
}
public void setDeptId(Long deptId) {
this.deptId = deptId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
public String getDetpName() {
return detpName;
}
public void setDetpName(String detpName) {
this.detpName = detpName;
}
@Override
public String toString() {
return "CacheCallBackPojo [userId=" + userId + ", deptId=" + deptId + ", userName=" + userName
+ ", phoneNumber=" + phoneNumber + ", detpName=" + detpName + "]";
}
}

@ -0,0 +1,36 @@
package com.ruoyi.system.service;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
import org.nutz.lang.Lang;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import com.ruoyi.cache.service.CacheCallBack;
import com.ruoyi.cache.service.IOrgCacheService;
@SpringBootTest
class CacheCallBackTest {
@Autowired
private IOrgCacheService orgCacheService;
@Test
void testInvoke() {
CacheCallBackPojo pojo=new CacheCallBackPojo();
pojo.setUserId(1L);
Lang.each(Lang.list(pojo), new CacheCallBack<>());
assertNotNull(pojo.getUserName());
System.out.println(pojo.toString());
}
@Test
void testInvoke2() {
CacheCallBackPojo2 pojo=new CacheCallBackPojo2();
pojo.setUserId(1L);
pojo.setDeptId(103L);
Lang.each(Lang.list(pojo), new CacheCallBack<>());
assertNotNull(pojo.getUserName());
System.out.println(pojo.toString());
}
}

@ -0,0 +1,35 @@
package com.ruoyi.system.service.impl;
import static org.junit.jupiter.api.Assertions.*;
import java.util.List;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import com.ruoyi.common.core.constant.SecurityConstants;
import com.ruoyi.common.core.context.SecurityContextHolder;
import com.ruoyi.system.domain.BulletinInfo;
import com.ruoyi.system.service.IBulletinInfoService;
@SpringBootTest
class BulletinInfoServiceImplTest {
@Autowired
private IBulletinInfoService bulletinInfoService;
@BeforeEach
void setUser() {
SecurityContextHolder.set(SecurityConstants.DETAILS_USER_ID, 1);
}
@Test
void testSelectBulletinInfoList() {
BulletinInfo bulletinInfo=new BulletinInfo();
bulletinInfo.setSts("C");
List<BulletinInfo> list=bulletinInfoService.selectBulletinInfoList(bulletinInfo);
assertTrue(list.size()>0);
System.out.println("aaaaaaaaaaaaaaaa:"+list.get(0).getCreateUserId()+"="+list.get(0).getCreateBy());
}
}

@ -0,0 +1,25 @@
# Tomcat
server:
port: 9201
# Spring
spring:
application:
# 应用名称
name: ruoyi-system
profiles:
# 环境配置
active: dev
cloud:
nacos:
discovery:
# 服务注册地址
server-addr: 192.168.0.17:8848
config:
# 配置中心地址
server-addr: 192.168.0.17:8848
# 配置文件格式
file-extension: yml
# 共享配置
shared-configs:
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
Loading…
Cancel
Save