|
|
|
@ -3,6 +3,8 @@ package com.zdxt.enforcementcode.service.impl; |
|
|
|
import cn.hutool.core.util.IdUtil; |
|
|
|
import com.zdxt.enforcementcode.domain.bean.SysNoticeInfo; |
|
|
|
import com.zdxt.enforcementcode.domain.bo.enterprise.EnterpriseNoticeListInfoBo; |
|
|
|
import com.zdxt.enforcementcode.domain.vo.EnforcementCarouselBannerVo; |
|
|
|
import org.dromara.common.core.service.DictService; |
|
|
|
import org.dromara.common.core.utils.MapstructUtils; |
|
|
|
import org.dromara.common.core.utils.StringUtils; |
|
|
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
|
|
|
@ -12,12 +14,14 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.dromara.common.satoken.utils.LoginHelper; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.zdxt.enforcementcode.domain.bo.SysNoticeInfoBo; |
|
|
|
import com.zdxt.enforcementcode.domain.vo.SysNoticeInfoVo; |
|
|
|
import com.zdxt.enforcementcode.mapper.SysNoticeInfoMapper; |
|
|
|
import com.zdxt.enforcementcode.service.ISysNoticeInfoService; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Collection; |
|
|
|
@ -34,7 +38,7 @@ import java.util.Collection; |
|
|
|
public class SysNoticeInfoServiceImpl implements ISysNoticeInfoService { |
|
|
|
|
|
|
|
private final SysNoticeInfoMapper baseMapper; |
|
|
|
|
|
|
|
private final DictService dictService; |
|
|
|
/** |
|
|
|
* 企业端-系统公告信息主列表 |
|
|
|
* @param bo |
|
|
|
@ -53,7 +57,46 @@ public class SysNoticeInfoServiceImpl implements ISysNoticeInfoService { |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public SysNoticeInfoVo queryById(String id){ |
|
|
|
return baseMapper.selectVoById(id); |
|
|
|
|
|
|
|
SysNoticeInfoVo sysNoticeInfoVo = baseMapper.selectVoById(id); |
|
|
|
// 设置字典标签
|
|
|
|
setDictLabels(sysNoticeInfoVo); |
|
|
|
return sysNoticeInfoVo; |
|
|
|
} |
|
|
|
/** |
|
|
|
* 为列表设置字典标签 |
|
|
|
* |
|
|
|
* @param records 记录列表 |
|
|
|
*/ |
|
|
|
private void setDictLabels(List<SysNoticeInfoVo> records) { |
|
|
|
if (records == null || records.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
records.forEach(this::setDictLabels); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 为单条记录设置字典标签 |
|
|
|
* |
|
|
|
* @param vo 记录对象 |
|
|
|
*/ |
|
|
|
private void setDictLabels(SysNoticeInfoVo vo) { |
|
|
|
if (vo == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
// 发布平台标签
|
|
|
|
if (vo.getTargetPlatform() != null) { |
|
|
|
String targetPlatformLabel = dictService.getDictLabel("web_publishing_platform", vo.getTargetPlatform().toString()); |
|
|
|
vo.setTargetPlatformLabel(targetPlatformLabel); |
|
|
|
} |
|
|
|
|
|
|
|
//状态标签
|
|
|
|
if(vo.getStatus()!=null){ |
|
|
|
String statusLabel = dictService.getDictLabel("web_status", vo.getStatus().toString()); |
|
|
|
vo.setStatusLabel(statusLabel); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
@ -67,6 +110,10 @@ public class SysNoticeInfoServiceImpl implements ISysNoticeInfoService { |
|
|
|
public TableDataInfo<SysNoticeInfoVo> queryPageList(SysNoticeInfoBo bo, PageQuery pageQuery) { |
|
|
|
LambdaQueryWrapper<SysNoticeInfo> lqw = buildQueryWrapper(bo); |
|
|
|
Page<SysNoticeInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
|
|
|
// 为每条记录设置字典标签和已读状态
|
|
|
|
if (result.getRecords() != null && !result.getRecords().isEmpty()) { |
|
|
|
setDictLabels(result.getRecords()); |
|
|
|
} |
|
|
|
return TableDataInfo.build(result); |
|
|
|
} |
|
|
|
|
|
|
|
@ -86,8 +133,16 @@ public class SysNoticeInfoServiceImpl implements ISysNoticeInfoService { |
|
|
|
Map<String, Object> params = bo.getParams(); |
|
|
|
LambdaQueryWrapper<SysNoticeInfo> lqw = Wrappers.lambdaQuery(); |
|
|
|
lqw.orderByAsc(SysNoticeInfo::getId); |
|
|
|
lqw.eq(StringUtils.isNotBlank(bo.getNoticeContent()), SysNoticeInfo::getNoticeContent, bo.getNoticeContent()); |
|
|
|
lqw.eq(bo.getPublishTime() != null, SysNoticeInfo::getPublishTime, bo.getPublishTime()); |
|
|
|
lqw.like(StringUtils.isNotBlank(bo.getNoticeContent()), SysNoticeInfo::getNoticeContent, bo.getNoticeContent()); |
|
|
|
|
|
|
|
// 发布时间根据开始时间和结束时间进行范围过滤
|
|
|
|
if (bo.getStartTime() != null) { |
|
|
|
lqw.ge(SysNoticeInfo::getPublishTime, bo.getStartTime()); |
|
|
|
} |
|
|
|
if (bo.getEndTime() != null) { |
|
|
|
lqw.le(SysNoticeInfo::getPublishTime, bo.getEndTime()); |
|
|
|
} |
|
|
|
|
|
|
|
lqw.eq(bo.getDisplayDays() != null, SysNoticeInfo::getDisplayDays, bo.getDisplayDays()); |
|
|
|
lqw.eq(bo.getTargetPlatform() != null, SysNoticeInfo::getTargetPlatform, bo.getTargetPlatform()); |
|
|
|
lqw.eq(bo.getStatus() != null, SysNoticeInfo::getStatus, bo.getStatus()); |
|
|
|
@ -110,7 +165,18 @@ public class SysNoticeInfoServiceImpl implements ISysNoticeInfoService { |
|
|
|
public Boolean insertByBo(SysNoticeInfoBo bo) { |
|
|
|
SysNoticeInfo add = MapstructUtils.convert(bo, SysNoticeInfo.class); |
|
|
|
add.setId(IdUtil.simpleUUID()); |
|
|
|
validEntityBeforeSave(add); |
|
|
|
add.setPublishTime(new Date(System.currentTimeMillis())); |
|
|
|
add.setCreateBy(LoginHelper.getUserId()!= null ? LoginHelper.getUserId() : null); |
|
|
|
add.setCreateByName(LoginHelper.getUsername()!= null ? LoginHelper.getUsername() : null); |
|
|
|
//1.显示时长为0,则表示永久显示
|
|
|
|
//2.显示时长不为0,则根据显示时长计算有效时间
|
|
|
|
if (bo.getDisplayDays() != null && bo.getDisplayDays() > 0) { |
|
|
|
long effectiveTimeMillis = add.getPublishTime().getTime() + bo.getDisplayDays() * 24 * 60 * 60 * 1000; |
|
|
|
add.setEffectiveTime(new Date(effectiveTimeMillis)); |
|
|
|
} else { |
|
|
|
// 永久显示,有效时间设为null或一个很远的未来时间
|
|
|
|
add.setEffectiveTime(null); |
|
|
|
} |
|
|
|
boolean flag = baseMapper.insert(add) > 0; |
|
|
|
if (flag) { |
|
|
|
bo.setId(add.getId()); |
|
|
|
@ -127,7 +193,18 @@ public class SysNoticeInfoServiceImpl implements ISysNoticeInfoService { |
|
|
|
@Override |
|
|
|
public Boolean updateByBo(SysNoticeInfoBo bo) { |
|
|
|
SysNoticeInfo update = MapstructUtils.convert(bo, SysNoticeInfo.class); |
|
|
|
validEntityBeforeSave(update); |
|
|
|
//1.显示时长为0,则表示永久显示
|
|
|
|
//2.显示时长不为0,则根据显示时长计算有效时间
|
|
|
|
if (bo.getDisplayDays() != null && bo.getDisplayDays() > 0) { |
|
|
|
long effectiveTimeMillis = update.getPublishTime().getTime() + bo.getDisplayDays() * 24 * 60 * 60 * 1000; |
|
|
|
update.setEffectiveTime(new Date(effectiveTimeMillis)); |
|
|
|
} else { |
|
|
|
// 永久显示,有效时间设为null或一个很远的未来时间
|
|
|
|
update.setEffectiveTime(null); |
|
|
|
} |
|
|
|
update.setUpdateTime(new Date(System.currentTimeMillis())); |
|
|
|
update.setUpdateBy(LoginHelper.getUserId()!= null ? LoginHelper.getUserId() : null); |
|
|
|
update.setUpdateByName(LoginHelper.getUsername()!= null ? LoginHelper.getUsername() : null); |
|
|
|
return baseMapper.updateById(update) > 0; |
|
|
|
} |
|
|
|
|
|
|
|
|