Pre Merge pull request !309 from 林桦/master
commit
35130332e7
@ -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,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 {
|
||||
|
||||
/**
|
||||
* POJO转换成Map
|
||||
* @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,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,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);
|
||||
/**
|
||||
* 只查询出bulletinId和接收的reciveUserId
|
||||
* @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,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,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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回18位字符串的唯一ID
|
||||
* @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,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…
Reference in new issue