日期默认生成yyyy-mm-dd HH:mm:ss 自动生成方法的说明.

pull/309/head
fjlinhua 3 years ago
parent fc9bb69c85
commit 3ce2d6ffa5

@ -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;

@ -78,6 +78,12 @@
<artifactId>ruoyi-common-swagger</artifactId>
</dependency>
<dependency>
<groupId>org.nutz</groupId>
<artifactId>nutz</artifactId>
<version>1.r.69.20210929</version>
</dependency>
</dependencies>
<build>

@ -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,197 @@
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;
/** 阅读时间 */
@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;
/**
* 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,237 @@
package com.ruoyi.system.service.impl;
import java.util.List;
import java.util.stream.Collectors;
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 ecc.c3.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;
/**
*
*
* @param bulletinId
* @return
*/
@Override
public BulletinInfo selectBulletinInfoByBulletinId(String bulletinId)
{
List<BulletinRecive> reciveUserIdAndbulletinId=bulletinReciveMapper.selectBulletinReciveUserIdByBulletinIds(new String[] {bulletinId});
BulletinInfo info= bulletinInfoMapper.selectBulletinInfoByBulletinId(bulletinId);
//TODO 把员工换算成名称
info.setCreateBy(info.getCreateUserId()+"");
info.setUpdateBy(info.getUpdateUserId()+"");
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->{
//TODO 这里要把reciveUserId换算成用户名
reciveUserNameMap.addv2(reciveUserIdAndBulletinId.getBulletinId(), reciveUserIdAndBulletinId.getReciveUserId()+"");
reciveBulletinReciveMap.addv2(reciveUserIdAndBulletinId.getBulletinId(), reciveUserIdAndBulletinId);
});
list.forEach(info->{
String reciveStaffNames=String.join(",", reciveUserNameMap.getList(info.getBulletinId(), String.class, Collections.emptyList()));
info.setReciveStaffNames(reciveStaffNames);
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,157 @@
package com.ruoyi.system.service.impl;
import java.util.Collections;
import java.util.List;
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;
@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();
}
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 ecc.c3.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,146 @@
package ecc.c3.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);
}
}
}

@ -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,24 @@
<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" />
<!-- 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>
Loading…
Cancel
Save