master
parent
4738f0fe2d
commit
55a0b0015f
|
|
@ -2,11 +2,8 @@ package com.fjrcloud.community.framework.mybatis.config;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.fjrcloud.community.framework.common.util.json.JsonUtils;
|
|
||||||
import com.fjrcloud.community.framework.mybatis.core.handler.DefaultDBFieldHandler;
|
|
||||||
import com.baomidou.mybatisplus.annotation.DbType;
|
import com.baomidou.mybatisplus.annotation.DbType;
|
||||||
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration;
|
||||||
import com.baomidou.mybatisplus.core.handlers.IJsonTypeHandler;
|
|
||||||
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
|
||||||
import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
|
import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
|
||||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||||
|
|
@ -16,6 +13,9 @@ import com.baomidou.mybatisplus.extension.parser.cache.JdkSerialCaffeineJsqlPars
|
||||||
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fjrcloud.community.framework.common.util.json.JsonUtils;
|
||||||
|
import com.fjrcloud.community.framework.mybatis.core.handler.DefaultDBFieldHandler;
|
||||||
|
import com.fjrcloud.community.framework.mybatis.core.handler.FjrcloudSqlInjector;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
|
|
@ -58,6 +58,11 @@ public class FjrcloudMybatisAutoConfiguration {
|
||||||
return new DefaultDBFieldHandler(); // 自动填充参数类
|
return new DefaultDBFieldHandler(); // 自动填充参数类
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public FjrcloudSqlInjector fjrcloudSqlInjector() {
|
||||||
|
return new FjrcloudSqlInjector(); // 自定义 SQL 注入器
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnProperty(prefix = "mybatis-plus.global-config.db-config", name = "id-type", havingValue = "INPUT")
|
@ConditionalOnProperty(prefix = "mybatis-plus.global-config.db-config", name = "id-type", havingValue = "INPUT")
|
||||||
public IKeyGenerator keyGenerator(ConfigurableEnvironment environment) {
|
public IKeyGenerator keyGenerator(ConfigurableEnvironment environment) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.fjrcloud.community.framework.mybatis.core.handler;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||||
|
import org.apache.ibatis.mapping.MappedStatement;
|
||||||
|
import org.apache.ibatis.mapping.SqlSource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 ID 物理删除(忽略逻辑删除)
|
||||||
|
*
|
||||||
|
* @author fjrcloud
|
||||||
|
*/
|
||||||
|
public class DeleteAbsoluteById extends AbstractMethod {
|
||||||
|
|
||||||
|
public DeleteAbsoluteById() {
|
||||||
|
super("deleteAbsoluteById");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
|
||||||
|
String sql = String.format("DELETE FROM %s WHERE %s=#{%s}",
|
||||||
|
tableInfo.getTableName(),
|
||||||
|
tableInfo.getKeyColumn(),
|
||||||
|
tableInfo.getKeyProperty());
|
||||||
|
|
||||||
|
SqlSource sqlSource = languageDriver.createSqlSource(configuration, sql, modelClass);
|
||||||
|
return addDeleteMappedStatement(mapperClass, methodName, sqlSource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.fjrcloud.community.framework.mybatis.core.handler;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.injector.AbstractMethod;
|
||||||
|
import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自定义 SQL 注入器
|
||||||
|
*
|
||||||
|
* @author fjrcloud
|
||||||
|
*/
|
||||||
|
public class FjrcloudSqlInjector extends DefaultSqlInjector {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AbstractMethod> getMethodList(Class<?> mapperClass, TableInfo tableInfo) {
|
||||||
|
List<AbstractMethod> methodList = super.getMethodList(mapperClass, tableInfo);
|
||||||
|
methodList.add(new DeleteAbsoluteById());
|
||||||
|
return methodList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,6 +20,7 @@ import com.github.yulichang.interfaces.MPJBaseJoin;
|
||||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -246,4 +247,5 @@ public interface BaseMapperX<T> extends MPJBaseMapper<T> {
|
||||||
return delete(new LambdaQueryWrapper<T>().in(field, values));
|
return delete(new LambdaQueryWrapper<T>().in(field, values));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int deleteAbsoluteById(Serializable id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,16 @@ import com.fjrcloud.community.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
import com.fjrcloud.community.framework.common.pojo.CommonResult;
|
import com.fjrcloud.community.framework.common.pojo.CommonResult;
|
||||||
import com.fjrcloud.community.framework.common.pojo.PageParam;
|
import com.fjrcloud.community.framework.common.pojo.PageParam;
|
||||||
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
||||||
|
import com.fjrcloud.community.framework.common.util.json.JsonUtils;
|
||||||
import com.fjrcloud.community.framework.common.util.object.BeanUtils;
|
import com.fjrcloud.community.framework.common.util.object.BeanUtils;
|
||||||
import com.fjrcloud.community.framework.excel.core.util.ExcelUtils;
|
import com.fjrcloud.community.framework.excel.core.util.ExcelUtils;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticePageReqVO;
|
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticePageReqVO;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticeRespVO;
|
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticeRespVO;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticeSaveReqVO;
|
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticeSaveReqVO;
|
||||||
import com.fjrcloud.community.module.community.dal.dataobject.notice.NoticeDO;
|
import com.fjrcloud.community.module.community.dal.dataobject.notice.CommunityNoticeDO;
|
||||||
import com.fjrcloud.community.module.community.dal.dataobject.notice.NoticeScopeDO;
|
import com.fjrcloud.community.module.community.dal.dataobject.notice.NoticeScopeDO;
|
||||||
import com.fjrcloud.community.module.community.dal.mysql.notice.NoticeScopeMapper;
|
import com.fjrcloud.community.module.community.dal.mysql.notice.NoticeScopeMapper;
|
||||||
import com.fjrcloud.community.module.community.service.notice.NoticeService;
|
import com.fjrcloud.community.module.community.service.notice.CommunityNoticeService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
|
@ -25,6 +26,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.fjrcloud.community.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
import static com.fjrcloud.community.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
|
|
@ -39,10 +41,10 @@ import static com.fjrcloud.community.framework.common.pojo.CommonResult.success;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/community/notice")
|
@RequestMapping("/community/notice")
|
||||||
@Validated
|
@Validated
|
||||||
public class NoticeController {
|
public class CommunityNoticeController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private NoticeService noticeService;
|
private CommunityNoticeService communityNoticeService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private NoticeScopeMapper noticeScopeMapper;
|
private NoticeScopeMapper noticeScopeMapper;
|
||||||
|
|
@ -51,14 +53,14 @@ public class NoticeController {
|
||||||
@Operation(summary = "创建通知")
|
@Operation(summary = "创建通知")
|
||||||
@PreAuthorize("@ss.hasPermission('community:notice:create')")
|
@PreAuthorize("@ss.hasPermission('community:notice:create')")
|
||||||
public CommonResult<Long> createNotice(@Valid @RequestBody NoticeSaveReqVO createReqVO) {
|
public CommonResult<Long> createNotice(@Valid @RequestBody NoticeSaveReqVO createReqVO) {
|
||||||
return success(noticeService.createNotice(createReqVO));
|
return success(communityNoticeService.createNotice(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新通知")
|
@Operation(summary = "更新通知")
|
||||||
@PreAuthorize("@ss.hasPermission('community:notice:update')")
|
@PreAuthorize("@ss.hasPermission('community:notice:update')")
|
||||||
public CommonResult<Boolean> updateNotice(@Valid @RequestBody NoticeSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updateNotice(@Valid @RequestBody NoticeSaveReqVO updateReqVO) {
|
||||||
noticeService.updateNotice(updateReqVO);
|
communityNoticeService.updateNotice(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -67,7 +69,7 @@ public class NoticeController {
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('community:notice:delete')")
|
@PreAuthorize("@ss.hasPermission('community:notice:delete')")
|
||||||
public CommonResult<Boolean> deleteNotice(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> deleteNotice(@RequestParam("id") Long id) {
|
||||||
noticeService.deleteNotice(id);
|
communityNoticeService.deleteNotice(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -76,7 +78,7 @@ public class NoticeController {
|
||||||
@Operation(summary = "批量删除通知")
|
@Operation(summary = "批量删除通知")
|
||||||
@PreAuthorize("@ss.hasPermission('community:notice:delete')")
|
@PreAuthorize("@ss.hasPermission('community:notice:delete')")
|
||||||
public CommonResult<Boolean> deleteNoticeList(@RequestParam("ids") List<Long> ids) {
|
public CommonResult<Boolean> deleteNoticeList(@RequestParam("ids") List<Long> ids) {
|
||||||
noticeService.deleteNoticeListByIds(ids);
|
communityNoticeService.deleteNoticeListByIds(ids);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,15 +87,27 @@ public class NoticeController {
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('community:notice:query')")
|
@PreAuthorize("@ss.hasPermission('community:notice:query')")
|
||||||
public CommonResult<NoticeRespVO> getNotice(@RequestParam("id") Long id) {
|
public CommonResult<NoticeRespVO> getNotice(@RequestParam("id") Long id) {
|
||||||
NoticeDO notice = noticeService.getNotice(id);
|
CommunityNoticeDO notice = communityNoticeService.getNotice(id);
|
||||||
NoticeRespVO respVO = BeanUtils.toBean(notice, NoticeRespVO.class);
|
NoticeRespVO respVO = BeanUtils.toBean(notice, NoticeRespVO.class);
|
||||||
|
|
||||||
|
// 处理附件JSON字符串转列表
|
||||||
|
if (notice.getAttachments() != null) {
|
||||||
|
respVO.setAttachments(JsonUtils.parseArray(notice.getAttachments(), String.class));
|
||||||
|
}
|
||||||
|
|
||||||
// 查询发布范围
|
// 查询发布范围
|
||||||
List<NoticeScopeDO> scopeList = noticeScopeMapper.selectListByNoticeId(id);
|
List<NoticeScopeDO> scopeList = noticeScopeMapper.selectListByNoticeId(id);
|
||||||
if (scopeList != null && !scopeList.isEmpty()) {
|
if (scopeList != null && !scopeList.isEmpty()) {
|
||||||
respVO.setCommunityIds(scopeList.stream()
|
List<Long> communityIds = scopeList.stream()
|
||||||
.map(NoticeScopeDO::getCommunityId)
|
.map(NoticeScopeDO::getCommunityId)
|
||||||
.collect(Collectors.toList()));
|
.collect(Collectors.toList());
|
||||||
|
respVO.setCommunityIds(communityIds);
|
||||||
|
|
||||||
|
List<String> communityNames = scopeList.stream()
|
||||||
|
.map(NoticeScopeDO::getCommunityName)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
respVO.setCommunityNames(communityNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
return success(respVO);
|
return success(respVO);
|
||||||
|
|
@ -103,8 +117,35 @@ public class NoticeController {
|
||||||
@Operation(summary = "获得通知分页")
|
@Operation(summary = "获得通知分页")
|
||||||
@PreAuthorize("@ss.hasPermission('community:notice:query')")
|
@PreAuthorize("@ss.hasPermission('community:notice:query')")
|
||||||
public CommonResult<PageResult<NoticeRespVO>> getNoticePage(@Valid NoticePageReqVO pageReqVO) {
|
public CommonResult<PageResult<NoticeRespVO>> getNoticePage(@Valid NoticePageReqVO pageReqVO) {
|
||||||
PageResult<NoticeDO> pageResult = noticeService.getNoticePage(pageReqVO);
|
PageResult<CommunityNoticeDO> pageResult = communityNoticeService.getNoticePage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, NoticeRespVO.class));
|
PageResult<NoticeRespVO> respVOPageResult = BeanUtils.toBean(pageResult, NoticeRespVO.class);
|
||||||
|
|
||||||
|
// 为每条通知填充小区ID、名称列表和附件列表
|
||||||
|
for (int i = 0; i < respVOPageResult.getList().size(); i++) {
|
||||||
|
NoticeRespVO respVO = respVOPageResult.getList().get(i);
|
||||||
|
CommunityNoticeDO notice = pageResult.getList().get(i);
|
||||||
|
|
||||||
|
// 处理附件JSON字符串转列表
|
||||||
|
if (notice.getAttachments() != null) {
|
||||||
|
respVO.setAttachments(JsonUtils.parseArray(notice.getAttachments(), String.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<NoticeScopeDO> scopeList = noticeScopeMapper.selectListByNoticeId(respVO.getId());
|
||||||
|
if (scopeList != null && !scopeList.isEmpty()) {
|
||||||
|
List<Long> communityIds = scopeList.stream()
|
||||||
|
.map(NoticeScopeDO::getCommunityId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
respVO.setCommunityIds(communityIds);
|
||||||
|
|
||||||
|
List<String> communityNames = scopeList.stream()
|
||||||
|
.map(NoticeScopeDO::getCommunityName)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
respVO.setCommunityNames(communityNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return success(respVOPageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/publish")
|
@PutMapping("/publish")
|
||||||
|
|
@ -112,7 +153,7 @@ public class NoticeController {
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('community:notice:publish')")
|
@PreAuthorize("@ss.hasPermission('community:notice:publish')")
|
||||||
public CommonResult<Boolean> publishNotice(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> publishNotice(@RequestParam("id") Long id) {
|
||||||
noticeService.publishNotice(id);
|
communityNoticeService.publishNotice(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -121,7 +162,7 @@ public class NoticeController {
|
||||||
@Parameter(name = "id", description = "编号", required = true)
|
@Parameter(name = "id", description = "编号", required = true)
|
||||||
@PreAuthorize("@ss.hasPermission('community:notice:revoke')")
|
@PreAuthorize("@ss.hasPermission('community:notice:revoke')")
|
||||||
public CommonResult<Boolean> revokeNotice(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> revokeNotice(@RequestParam("id") Long id) {
|
||||||
noticeService.revokeNotice(id);
|
communityNoticeService.revokeNotice(id);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -132,7 +173,7 @@ public class NoticeController {
|
||||||
public void exportNoticeExcel(@Valid NoticePageReqVO pageReqVO,
|
public void exportNoticeExcel(@Valid NoticePageReqVO pageReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<NoticeDO> list = noticeService.getNoticePage(pageReqVO).getList();
|
List<CommunityNoticeDO> list = communityNoticeService.getNoticePage(pageReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "通知管理.xls", "数据", NoticeRespVO.class,
|
ExcelUtils.write(response, "通知管理.xls", "数据", NoticeRespVO.class,
|
||||||
BeanUtils.toBean(list, NoticeRespVO.class));
|
BeanUtils.toBean(list, NoticeRespVO.class));
|
||||||
|
|
@ -31,4 +31,7 @@ public class NoticePageReqVO extends PageParam {
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
private LocalDateTime[] publishTime;
|
private LocalDateTime[] publishTime;
|
||||||
|
|
||||||
|
@Schema(description = "小区ID", example = "1")
|
||||||
|
private Long communityId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,15 @@ package com.fjrcloud.community.module.community.controller.admin.notice.vo;
|
||||||
|
|
||||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
import cn.idev.excel.annotation.ExcelProperty;
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
|
import cn.idev.excel.converters.Converter;
|
||||||
|
import cn.idev.excel.converters.WriteConverterContext;
|
||||||
|
import cn.idev.excel.metadata.data.WriteCellData;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 管理后台 - 通知管理 Response VO
|
* 管理后台 - 通知管理 Response VO
|
||||||
|
|
@ -35,8 +39,8 @@ public class NoticeRespVO {
|
||||||
private String publisher;
|
private String publisher;
|
||||||
|
|
||||||
@Schema(description = "附件URL列表", example = "[\"https://xxx.com/file1.pdf\"]")
|
@Schema(description = "附件URL列表", example = "[\"https://xxx.com/file1.pdf\"]")
|
||||||
@ExcelProperty("附件")
|
@ExcelProperty(value = "附件", converter = AttachmentsConverter.class)
|
||||||
private String attachments;
|
private List<String> attachments;
|
||||||
|
|
||||||
@Schema(description = "发布类型(1-立即发布,2-定时发布)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "发布类型(1-立即发布,2-定时发布)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@ExcelProperty("发布类型")
|
@ExcelProperty("发布类型")
|
||||||
|
|
@ -69,8 +73,35 @@ public class NoticeRespVO {
|
||||||
@Schema(description = "小区ID列表(发布范围)", example = "[1, 2, 3]")
|
@Schema(description = "小区ID列表(发布范围)", example = "[1, 2, 3]")
|
||||||
private List<Long> communityIds;
|
private List<Long> communityIds;
|
||||||
|
|
||||||
|
@Schema(description = "小区名称列表", example = "[\"阳光小区\", \"花园小区\"]")
|
||||||
|
private List<String> communityNames;
|
||||||
|
|
||||||
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@ExcelProperty("创建时间")
|
@ExcelProperty("创建时间")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 附件列表转换器,用于Excel导出时将List<String>转换为换行分隔的字符串
|
||||||
|
*/
|
||||||
|
public static class AttachmentsConverter implements Converter<List<String>> {
|
||||||
|
@Override
|
||||||
|
public Class supportJavaTypeKey() {
|
||||||
|
return List.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WriteCellData convertToExcelData(
|
||||||
|
WriteConverterContext<List<String>> context) throws Exception {
|
||||||
|
List<String> value = context.getValue();
|
||||||
|
if (value == null || value.isEmpty()) {
|
||||||
|
return new WriteCellData<>("");
|
||||||
|
}
|
||||||
|
// 使用换行符分隔,在Excel中每个URL占一行,更清晰
|
||||||
|
String result = value.stream()
|
||||||
|
.filter(url -> url != null && !url.isEmpty())
|
||||||
|
.collect(Collectors.joining("\n"));
|
||||||
|
return new WriteCellData<>(result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,8 @@ public class NoticeSaveReqVO {
|
||||||
@NotEmpty(message = "发布方不能为空")
|
@NotEmpty(message = "发布方不能为空")
|
||||||
private String publisher;
|
private String publisher;
|
||||||
|
|
||||||
@Schema(description = "附件URL列表(JSON数组)", example = "[\"https://xxx.com/file1.pdf\"]")
|
@Schema(description = "附件URL列表", example = "[\"https://xxx.com/file1.pdf\", \"https://xxx.com/file2.jpg\"]")
|
||||||
private String attachments;
|
private List<String> attachments;
|
||||||
|
|
||||||
@Schema(description = "发布类型(1-立即发布,2-定时发布)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "发布类型(1-立即发布,2-定时发布)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@NotNull(message = "发布类型不能为空")
|
@NotNull(message = "发布类型不能为空")
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fjrcloud.community.framework.mybatis.core.dataobject.BaseDO;
|
import com.fjrcloud.community.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import com.fjrcloud.community.framework.tenant.core.aop.TenantIgnore;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
@ -21,7 +22,8 @@ import java.time.LocalDateTime;
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class NoticeDO extends BaseDO {
|
@TenantIgnore
|
||||||
|
public class CommunityNoticeDO extends BaseDO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通知编号
|
* 通知编号
|
||||||
|
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fjrcloud.community.framework.mybatis.core.dataobject.BaseDO;
|
import com.fjrcloud.community.framework.mybatis.core.dataobject.BaseDO;
|
||||||
|
import com.fjrcloud.community.framework.tenant.core.aop.TenantIgnore;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -19,6 +20,7 @@ import lombok.*;
|
||||||
@Builder
|
@Builder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@TenantIgnore
|
||||||
public class NoticeScopeDO extends BaseDO {
|
public class NoticeScopeDO extends BaseDO {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -37,4 +39,9 @@ public class NoticeScopeDO extends BaseDO {
|
||||||
*/
|
*/
|
||||||
private Long communityId;
|
private Long communityId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小区名称
|
||||||
|
*/
|
||||||
|
private String communityName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.fjrcloud.community.module.community.dal.mysql.notice;
|
||||||
|
|
||||||
|
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
||||||
|
import com.fjrcloud.community.framework.mybatis.core.mapper.BaseMapperX;
|
||||||
|
import com.fjrcloud.community.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticePageReqVO;
|
||||||
|
import com.fjrcloud.community.module.community.dal.dataobject.notice.CommunityNoticeDO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知管理 Mapper
|
||||||
|
*
|
||||||
|
* @author fjrcloud
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface CommunityNoticeMapper extends BaseMapperX<CommunityNoticeDO> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分页查询通知列表
|
||||||
|
*
|
||||||
|
* @param reqVO 分页查询条件
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
default PageResult<CommunityNoticeDO> selectPage(NoticePageReqVO reqVO) {
|
||||||
|
return selectPage(reqVO, new LambdaQueryWrapperX<CommunityNoticeDO>()
|
||||||
|
// 如果指定了小区ID,使用 EXISTS 子查询过滤
|
||||||
|
.likeIfPresent(CommunityNoticeDO::getTitle, reqVO.getTitle())
|
||||||
|
.eqIfPresent(CommunityNoticeDO::getStatus, reqVO.getStatus())
|
||||||
|
.eqIfPresent(CommunityNoticeDO::getPublishType, reqVO.getPublishType())
|
||||||
|
.betweenIfPresent(CommunityNoticeDO::getPublishTime, reqVO.getPublishTime())
|
||||||
|
.apply(reqVO.getCommunityId() != null,
|
||||||
|
"EXISTS (SELECT 1 FROM comm_notice_scope WHERE notice_id = comm_notice.id AND community_id = {0})",
|
||||||
|
reqVO.getCommunityId())
|
||||||
|
.orderByDesc(CommunityNoticeDO::getId));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
package com.fjrcloud.community.module.community.dal.mysql.notice;
|
|
||||||
|
|
||||||
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
|
||||||
import com.fjrcloud.community.framework.mybatis.core.mapper.BaseMapperX;
|
|
||||||
import com.fjrcloud.community.framework.mybatis.core.query.LambdaQueryWrapperX;
|
|
||||||
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticePageReqVO;
|
|
||||||
import com.fjrcloud.community.module.community.dal.dataobject.notice.NoticeDO;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知管理 Mapper
|
|
||||||
*
|
|
||||||
* @author fjrcloud
|
|
||||||
*/
|
|
||||||
@Mapper
|
|
||||||
public interface NoticeMapper extends BaseMapperX<NoticeDO> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 分页查询通知列表
|
|
||||||
*
|
|
||||||
* @param reqVO 分页查询条件
|
|
||||||
* @return 分页结果
|
|
||||||
*/
|
|
||||||
default PageResult<NoticeDO> selectPage(NoticePageReqVO reqVO) {
|
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<NoticeDO>()
|
|
||||||
.likeIfPresent(NoticeDO::getTitle, reqVO.getTitle())
|
|
||||||
.eqIfPresent(NoticeDO::getStatus, reqVO.getStatus())
|
|
||||||
.eqIfPresent(NoticeDO::getPublishType, reqVO.getPublishType())
|
|
||||||
.betweenIfPresent(NoticeDO::getPublishTime, reqVO.getPublishTime())
|
|
||||||
.orderByDesc(NoticeDO::getId));
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -26,30 +26,45 @@ public interface NoticeScopeMapper extends BaseMapperX<NoticeScopeDO> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据通知ID删除关联
|
* 根据通知ID物理删除关联(真删除)
|
||||||
*
|
*
|
||||||
* @param noticeId 通知ID
|
* @param noticeId 通知ID
|
||||||
* @return 删除数量
|
* @return 删除数量
|
||||||
*/
|
*/
|
||||||
default int deleteByNoticeId(Long noticeId) {
|
default int deleteByNoticeId(Long noticeId) {
|
||||||
return delete(NoticeScopeDO::getNoticeId, noticeId);
|
List<NoticeScopeDO> list = selectList(NoticeScopeDO::getNoticeId, noticeId);
|
||||||
|
if (list == null || list.isEmpty()) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int count = 0;
|
||||||
|
for (NoticeScopeDO scope : list) {
|
||||||
|
count += deleteAbsoluteById(scope.getId());
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入通知小区关联
|
* 批量插入通知小区关联
|
||||||
*
|
*
|
||||||
* @param noticeId 通知ID
|
* @param noticeId 通知ID
|
||||||
* @param communityIds 小区ID列表
|
* @param communityIds 小区ID列表
|
||||||
* @return 插入数量
|
* @param communityNames 小区名称列表
|
||||||
*/
|
*/
|
||||||
default int insertBatch(@Param("noticeId") Long noticeId, @Param("communityIds") List<Long> communityIds) {
|
default void insertBatch(@Param("noticeId") Long noticeId,
|
||||||
List<NoticeScopeDO> list = communityIds.stream()
|
@Param("communityIds") List<Long> communityIds,
|
||||||
.map(communityId -> NoticeScopeDO.builder()
|
@Param("communityNames") List<String> communityNames) {
|
||||||
.noticeId(noticeId)
|
List<NoticeScopeDO> list = new java.util.ArrayList<>();
|
||||||
.communityId(communityId)
|
for (int i = 0; i < communityIds.size(); i++) {
|
||||||
.build())
|
NoticeScopeDO scopeDO = new NoticeScopeDO();
|
||||||
.collect(java.util.stream.Collectors.toList());
|
scopeDO.setNoticeId(noticeId);
|
||||||
return insertBatch(list);
|
scopeDO.setCommunityId(communityIds.get(i));
|
||||||
|
if (communityNames != null && i < communityNames.size()) {
|
||||||
|
scopeDO.setCommunityName(communityNames.get(i));
|
||||||
|
}
|
||||||
|
list.add(scopeDO);
|
||||||
|
}
|
||||||
|
insertBatch(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package com.fjrcloud.community.module.community.job.notice;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.fjrcloud.community.framework.quartz.core.handler.JobHandler;
|
import com.fjrcloud.community.framework.quartz.core.handler.JobHandler;
|
||||||
import com.fjrcloud.community.framework.tenant.core.job.TenantJob;
|
import com.fjrcloud.community.framework.tenant.core.job.TenantJob;
|
||||||
import com.fjrcloud.community.module.community.service.notice.NoticeService;
|
import com.fjrcloud.community.module.community.service.notice.CommunityNoticeService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
@ -19,12 +19,12 @@ import javax.annotation.Resource;
|
||||||
public class NoticeExpireJob implements JobHandler {
|
public class NoticeExpireJob implements JobHandler {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private NoticeService noticeService;
|
private CommunityNoticeService communityNoticeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@TenantJob
|
@TenantJob
|
||||||
public String execute(String param) {
|
public String execute(String param) {
|
||||||
int count = noticeService.autoExpireNotices();
|
int count = communityNoticeService.autoExpireNotices();
|
||||||
return StrUtil.format("自动过期通知 {} 个", count);
|
return StrUtil.format("自动过期通知 {} 个", count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package com.fjrcloud.community.module.community.job;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.fjrcloud.community.framework.quartz.core.handler.JobHandler;
|
import com.fjrcloud.community.framework.quartz.core.handler.JobHandler;
|
||||||
import com.fjrcloud.community.framework.tenant.core.job.TenantJob;
|
import com.fjrcloud.community.framework.tenant.core.job.TenantJob;
|
||||||
import com.fjrcloud.community.module.community.service.notice.NoticeService;
|
import com.fjrcloud.community.module.community.service.notice.CommunityNoticeService;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
@ -19,12 +19,12 @@ import javax.annotation.Resource;
|
||||||
public class NoticePublishJob implements JobHandler {
|
public class NoticePublishJob implements JobHandler {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private NoticeService noticeService;
|
private CommunityNoticeService communityNoticeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@TenantJob
|
@TenantJob
|
||||||
public String execute(String param) {
|
public String execute(String param) {
|
||||||
int count = noticeService.autoPublishNotices();
|
int count = communityNoticeService.autoPublishNotices();
|
||||||
return StrUtil.format("自动发布通知 {} 个", count);
|
return StrUtil.format("自动发布通知 {} 个", count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ package com.fjrcloud.community.module.community.service.notice;
|
||||||
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticePageReqVO;
|
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticePageReqVO;
|
||||||
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticeSaveReqVO;
|
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticeSaveReqVO;
|
||||||
import com.fjrcloud.community.module.community.dal.dataobject.notice.NoticeDO;
|
import com.fjrcloud.community.module.community.dal.dataobject.notice.CommunityNoticeDO;
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author fjrcloud
|
* @author fjrcloud
|
||||||
*/
|
*/
|
||||||
public interface NoticeService {
|
public interface CommunityNoticeService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建通知
|
* 创建通知
|
||||||
|
|
@ -50,7 +50,7 @@ public interface NoticeService {
|
||||||
* @param id 编号
|
* @param id 编号
|
||||||
* @return 通知
|
* @return 通知
|
||||||
*/
|
*/
|
||||||
NoticeDO getNotice(Long id);
|
CommunityNoticeDO getNotice(Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得通知分页
|
* 获得通知分页
|
||||||
|
|
@ -58,7 +58,7 @@ public interface NoticeService {
|
||||||
* @param pageReqVO 分页查询
|
* @param pageReqVO 分页查询
|
||||||
* @return 通知分页
|
* @return 通知分页
|
||||||
*/
|
*/
|
||||||
PageResult<NoticeDO> getNoticePage(NoticePageReqVO pageReqVO);
|
PageResult<CommunityNoticeDO> getNoticePage(NoticePageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发布通知
|
* 发布通知
|
||||||
|
|
@ -0,0 +1,305 @@
|
||||||
|
package com.fjrcloud.community.module.community.service.notice;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import com.fjrcloud.community.framework.common.exception.ErrorCode;
|
||||||
|
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
||||||
|
import com.fjrcloud.community.framework.common.util.json.JsonUtils;
|
||||||
|
import com.fjrcloud.community.framework.common.util.object.BeanUtils;
|
||||||
|
import com.fjrcloud.community.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
|
import com.fjrcloud.community.framework.tenant.core.context.TenantContextHolder;
|
||||||
|
import com.fjrcloud.community.framework.tenant.core.util.TenantUtils;
|
||||||
|
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticePageReqVO;
|
||||||
|
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticeSaveReqVO;
|
||||||
|
import com.fjrcloud.community.module.community.dal.dataobject.community.CommunityDO;
|
||||||
|
import com.fjrcloud.community.module.community.dal.dataobject.notice.CommunityNoticeDO;
|
||||||
|
import com.fjrcloud.community.module.community.dal.mysql.community.CommunityMapper;
|
||||||
|
import com.fjrcloud.community.module.community.dal.mysql.notice.CommunityNoticeMapper;
|
||||||
|
import com.fjrcloud.community.module.community.dal.mysql.notice.NoticeScopeMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static com.fjrcloud.community.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static com.fjrcloud.community.module.community.enums.ErrorCodeConstants.NOTICE_NOT_DRAFT;
|
||||||
|
import static com.fjrcloud.community.module.community.enums.ErrorCodeConstants.NOTICE_NOT_EXISTS;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通知管理 Service 实现类
|
||||||
|
*
|
||||||
|
* @author fjrcloud
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
public class CommunityNoticeServiceImpl implements CommunityNoticeService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 超级管理员租户ID
|
||||||
|
*/
|
||||||
|
private static final Long SYSTEM_TENANT_ID = 1L;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CommunityNoticeMapper communityNoticeMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private NoticeScopeMapper noticeScopeMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private CommunityMapper communityMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Long createNotice(NoticeSaveReqVO createReqVO) {
|
||||||
|
// 插入通知
|
||||||
|
CommunityNoticeDO notice = BeanUtils.toBean(createReqVO, CommunityNoticeDO.class);
|
||||||
|
|
||||||
|
// 处理附件列表转JSON字符串
|
||||||
|
if (createReqVO.getAttachments() != null && !createReqVO.getAttachments().isEmpty()) {
|
||||||
|
notice.setAttachments(JsonUtils.toJsonString(createReqVO.getAttachments()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据发布类型设置状态:1-立即发布直接设为已发布,2-定时发布设为草稿
|
||||||
|
if (createReqVO.getPublishType() == 1) {
|
||||||
|
notice.setStatus(1); // 已发布
|
||||||
|
notice.setPublishTime(LocalDateTime.now());
|
||||||
|
} else {
|
||||||
|
notice.setStatus(0); // 草稿
|
||||||
|
}
|
||||||
|
notice.setViewCount(0);
|
||||||
|
communityNoticeMapper.insert(notice);
|
||||||
|
|
||||||
|
// 插入通知小区关联
|
||||||
|
if (createReqVO.getCommunityIds() != null && !createReqVO.getCommunityIds().isEmpty()) {
|
||||||
|
List<String> communityNames = getCommunityNamesByIds(createReqVO.getCommunityIds());
|
||||||
|
noticeScopeMapper.insertBatch(notice.getId(), createReqVO.getCommunityIds(), communityNames);
|
||||||
|
}
|
||||||
|
|
||||||
|
return notice.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void updateNotice(NoticeSaveReqVO updateReqVO) {
|
||||||
|
// 校验存在
|
||||||
|
CommunityNoticeDO oldNotice = validateNoticeExists(updateReqVO.getId());
|
||||||
|
|
||||||
|
// 如果原状态是已发布、已过期或已撤回,不允许修改
|
||||||
|
if (oldNotice.getStatus() != 0) {
|
||||||
|
throw exception(NOTICE_NOT_DRAFT);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新通知
|
||||||
|
CommunityNoticeDO updateObj = BeanUtils.toBean(updateReqVO, CommunityNoticeDO.class);
|
||||||
|
|
||||||
|
// 处理附件列表转JSON字符串
|
||||||
|
if (updateReqVO.getAttachments() != null) {
|
||||||
|
updateObj.setAttachments(updateReqVO.getAttachments().isEmpty()
|
||||||
|
? null
|
||||||
|
: JsonUtils.toJsonString(updateReqVO.getAttachments()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据发布类型设置状态:1-立即发布直接设为已发布,2-定时发布设为草稿
|
||||||
|
if (updateReqVO.getPublishType() == 1) {
|
||||||
|
updateObj.setStatus(1); // 已发布
|
||||||
|
updateObj.setPublishTime(LocalDateTime.now());
|
||||||
|
} else {
|
||||||
|
updateObj.setStatus(0); // 草稿
|
||||||
|
}
|
||||||
|
|
||||||
|
communityNoticeMapper.updateById(updateObj);
|
||||||
|
|
||||||
|
// 更新通知小区关联:先删除旧的,再插入新的
|
||||||
|
noticeScopeMapper.deleteByNoticeId(updateReqVO.getId());
|
||||||
|
if (updateReqVO.getCommunityIds() != null && !updateReqVO.getCommunityIds().isEmpty()) {
|
||||||
|
List<String> communityNames = getCommunityNamesByIds(updateReqVO.getCommunityIds());
|
||||||
|
noticeScopeMapper.insertBatch(updateReqVO.getId(), updateReqVO.getCommunityIds(), communityNames);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void deleteNotice(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
validateNoticeExists(id);
|
||||||
|
// 删除通知
|
||||||
|
communityNoticeMapper.deleteById(id);
|
||||||
|
// 删除通知小区关联
|
||||||
|
noticeScopeMapper.deleteByNoticeId(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void deleteNoticeListByIds(List<Long> ids) {
|
||||||
|
// 删除通知
|
||||||
|
communityNoticeMapper.deleteByIds(ids);
|
||||||
|
// 删除通知小区关联
|
||||||
|
for (Long id : ids) {
|
||||||
|
noticeScopeMapper.deleteByNoticeId(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommunityNoticeDO getNotice(Long id) {
|
||||||
|
return communityNoticeMapper.selectById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<CommunityNoticeDO> getNoticePage(NoticePageReqVO pageReqVO) {
|
||||||
|
// 获取当前租户ID
|
||||||
|
Long tenantId = TenantContextHolder.getTenantId();
|
||||||
|
|
||||||
|
// 如果没有指定小区ID,则根据租户类型确定
|
||||||
|
if (pageReqVO.getCommunityId() == null) {
|
||||||
|
// 超级管理员租户查询所有通知,忽略租户隔离
|
||||||
|
if (SYSTEM_TENANT_ID.equals(tenantId)) {
|
||||||
|
return TenantUtils.executeIgnore(() -> communityNoticeMapper.selectPage(pageReqVO));
|
||||||
|
}
|
||||||
|
// 普通租户:租户ID即小区ID
|
||||||
|
pageReqVO.setCommunityId(tenantId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用 EXISTS 子查询
|
||||||
|
return communityNoticeMapper.selectPage(pageReqVO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void publishNotice(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
CommunityNoticeDO notice = validateNoticeExists(id);
|
||||||
|
|
||||||
|
// 校验状态
|
||||||
|
if (notice.getStatus() != 0) {
|
||||||
|
throw exception(new ErrorCode(2_004_000_001, "只有草稿状态的通知才能发布"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新状态为已发布
|
||||||
|
CommunityNoticeDO updateObj = new CommunityNoticeDO();
|
||||||
|
updateObj.setId(id);
|
||||||
|
updateObj.setStatus(1);
|
||||||
|
updateObj.setPublishTime(LocalDateTime.now());
|
||||||
|
communityNoticeMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void revokeNotice(Long id) {
|
||||||
|
// 校验存在
|
||||||
|
CommunityNoticeDO notice = validateNoticeExists(id);
|
||||||
|
|
||||||
|
// 校验状态
|
||||||
|
if (notice.getStatus() != 1) {
|
||||||
|
throw exception(new ErrorCode(2_004_000_002, "只有已发布状态的通知才能撤回"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新状态为已撤回
|
||||||
|
CommunityNoticeDO updateObj = new CommunityNoticeDO();
|
||||||
|
updateObj.setId(id);
|
||||||
|
updateObj.setStatus(3);
|
||||||
|
communityNoticeMapper.updateById(updateObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public int autoPublishNotices() {
|
||||||
|
// 查询需要发布的通知:草稿状态 + 发布时间已到
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
List<CommunityNoticeDO> notices = communityNoticeMapper.selectList(new LambdaQueryWrapperX<CommunityNoticeDO>()
|
||||||
|
.eq(CommunityNoticeDO::getStatus, 0) // 草稿状态
|
||||||
|
.eq(CommunityNoticeDO::getPublishType, 2) // 定时发布
|
||||||
|
.le(CommunityNoticeDO::getPublishTime, now) // 发布时间已到
|
||||||
|
);
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(notices)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量更新状态为已发布
|
||||||
|
int count = 0;
|
||||||
|
for (CommunityNoticeDO notice : notices) {
|
||||||
|
CommunityNoticeDO updateObj = new CommunityNoticeDO();
|
||||||
|
updateObj.setId(notice.getId());
|
||||||
|
updateObj.setStatus(1); // 已发布
|
||||||
|
communityNoticeMapper.updateById(updateObj);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public int autoExpireNotices() {
|
||||||
|
// 查询需要过期的通知:已发布状态 + 结束类型是定时结束 + 结束时间已到
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
List<CommunityNoticeDO> notices = communityNoticeMapper.selectList(new LambdaQueryWrapperX<CommunityNoticeDO>()
|
||||||
|
.eq(CommunityNoticeDO::getStatus, 1) // 已发布状态
|
||||||
|
.eq(CommunityNoticeDO::getEndType, 2) // 定时结束
|
||||||
|
.le(CommunityNoticeDO::getEndTime, now) // 结束时间已到
|
||||||
|
);
|
||||||
|
|
||||||
|
if (CollUtil.isEmpty(notices)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量更新状态为已过期
|
||||||
|
int count = 0;
|
||||||
|
for (CommunityNoticeDO notice : notices) {
|
||||||
|
CommunityNoticeDO updateObj = new CommunityNoticeDO();
|
||||||
|
updateObj.setId(notice.getId());
|
||||||
|
updateObj.setStatus(2); // 已过期
|
||||||
|
communityNoticeMapper.updateById(updateObj);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验通知是否存在
|
||||||
|
*
|
||||||
|
* @param id 通知ID
|
||||||
|
* @return 通知对象
|
||||||
|
*/
|
||||||
|
private CommunityNoticeDO validateNoticeExists(Long id) {
|
||||||
|
CommunityNoticeDO notice = communityNoticeMapper.selectById(id);
|
||||||
|
if (notice == null) {
|
||||||
|
throw exception(NOTICE_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
return notice;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据小区ID列表批量查询小区名称
|
||||||
|
*
|
||||||
|
* @param communityIds 小区ID列表
|
||||||
|
* @return 小区名称列表(与输入顺序一致,不存在的小区返回null)
|
||||||
|
*/
|
||||||
|
private List<String> getCommunityNamesByIds(List<Long> communityIds) {
|
||||||
|
if (CollUtil.isEmpty(communityIds)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 批量查询小区信息
|
||||||
|
List<CommunityDO> communities = communityMapper.selectByIds(communityIds);
|
||||||
|
|
||||||
|
// 构建ID到名称的映射
|
||||||
|
Map<Long, String> communityNameMap = communities.stream()
|
||||||
|
.filter(community -> community.getCommunityName() != null)
|
||||||
|
.collect(Collectors.toMap(CommunityDO::getId, CommunityDO::getCommunityName));
|
||||||
|
|
||||||
|
// 按照原始ID顺序返回名称列表,不存在的小区返回null
|
||||||
|
return communityIds.stream()
|
||||||
|
.map(communityNameMap::get)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,231 +0,0 @@
|
||||||
package com.fjrcloud.community.module.community.service.notice;
|
|
||||||
|
|
||||||
import com.fjrcloud.community.framework.common.pojo.PageResult;
|
|
||||||
import com.fjrcloud.community.framework.common.util.object.BeanUtils;
|
|
||||||
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticePageReqVO;
|
|
||||||
import com.fjrcloud.community.module.community.controller.admin.notice.vo.NoticeSaveReqVO;
|
|
||||||
import com.fjrcloud.community.module.community.dal.dataobject.notice.NoticeDO;
|
|
||||||
import com.fjrcloud.community.module.community.dal.mysql.notice.NoticeMapper;
|
|
||||||
import com.fjrcloud.community.module.community.dal.mysql.notice.NoticeScopeMapper;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import static com.fjrcloud.community.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
||||||
import static com.fjrcloud.community.module.community.enums.ErrorCodeConstants.NOTICE_NOT_DRAFT;
|
|
||||||
import static com.fjrcloud.community.module.community.enums.ErrorCodeConstants.NOTICE_NOT_EXISTS;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 通知管理 Service 实现类
|
|
||||||
*
|
|
||||||
* @author fjrcloud
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
@Validated
|
|
||||||
public class NoticeServiceImpl implements NoticeService {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private NoticeMapper noticeMapper;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private NoticeScopeMapper noticeScopeMapper;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public Long createNotice(NoticeSaveReqVO createReqVO) {
|
|
||||||
// 插入通知
|
|
||||||
NoticeDO notice = BeanUtils.toBean(createReqVO, NoticeDO.class);
|
|
||||||
|
|
||||||
// 根据发布类型设置状态:1-立即发布直接设为已发布,2-定时发布设为草稿
|
|
||||||
if (createReqVO.getPublishType() == 1) {
|
|
||||||
notice.setStatus(1); // 已发布
|
|
||||||
notice.setPublishTime(LocalDateTime.now());
|
|
||||||
} else {
|
|
||||||
notice.setStatus(0); // 草稿
|
|
||||||
}
|
|
||||||
notice.setViewCount(0);
|
|
||||||
noticeMapper.insert(notice);
|
|
||||||
|
|
||||||
// 插入通知小区关联
|
|
||||||
if (createReqVO.getCommunityIds() != null && !createReqVO.getCommunityIds().isEmpty()) {
|
|
||||||
noticeScopeMapper.insertBatch(notice.getId(), createReqVO.getCommunityIds());
|
|
||||||
}
|
|
||||||
|
|
||||||
return notice.getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void updateNotice(NoticeSaveReqVO updateReqVO) {
|
|
||||||
// 校验存在
|
|
||||||
NoticeDO oldNotice = validateNoticeExists(updateReqVO.getId());
|
|
||||||
|
|
||||||
// 如果原状态是已发布、已过期或已撤回,不允许修改
|
|
||||||
if (oldNotice.getStatus() != 0) {
|
|
||||||
throw exception(NOTICE_NOT_DRAFT);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新通知
|
|
||||||
NoticeDO updateObj = BeanUtils.toBean(updateReqVO, NoticeDO.class);
|
|
||||||
|
|
||||||
// 根据发布类型设置状态:1-立即发布直接设为已发布,2-定时发布设为草稿
|
|
||||||
if (updateReqVO.getPublishType() == 1) {
|
|
||||||
updateObj.setStatus(1); // 已发布
|
|
||||||
updateObj.setPublishTime(LocalDateTime.now());
|
|
||||||
} else {
|
|
||||||
updateObj.setStatus(0); // 草稿
|
|
||||||
}
|
|
||||||
|
|
||||||
noticeMapper.updateById(updateObj);
|
|
||||||
|
|
||||||
// 更新通知小区关联:先删除旧的,再插入新的
|
|
||||||
noticeScopeMapper.deleteByNoticeId(updateReqVO.getId());
|
|
||||||
if (updateReqVO.getCommunityIds() != null && !updateReqVO.getCommunityIds().isEmpty()) {
|
|
||||||
noticeScopeMapper.insertBatch(updateReqVO.getId(), updateReqVO.getCommunityIds());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void deleteNotice(Long id) {
|
|
||||||
// 校验存在
|
|
||||||
validateNoticeExists(id);
|
|
||||||
// 删除通知
|
|
||||||
noticeMapper.deleteById(id);
|
|
||||||
// 删除通知小区关联
|
|
||||||
noticeScopeMapper.deleteByNoticeId(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void deleteNoticeListByIds(List<Long> ids) {
|
|
||||||
// 删除通知
|
|
||||||
noticeMapper.deleteByIds(ids);
|
|
||||||
// 删除通知小区关联
|
|
||||||
for (Long id : ids) {
|
|
||||||
noticeScopeMapper.deleteByNoticeId(id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public NoticeDO getNotice(Long id) {
|
|
||||||
return noticeMapper.selectById(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public PageResult<NoticeDO> getNoticePage(NoticePageReqVO pageReqVO) {
|
|
||||||
return noticeMapper.selectPage(pageReqVO);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void publishNotice(Long id) {
|
|
||||||
// 校验存在
|
|
||||||
NoticeDO notice = validateNoticeExists(id);
|
|
||||||
|
|
||||||
// 校验状态
|
|
||||||
if (notice.getStatus() != 0) {
|
|
||||||
throw exception(new com.fjrcloud.community.framework.common.exception.ErrorCode(2_004_000_001, "只有草稿状态的通知才能发布"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新状态为已发布
|
|
||||||
NoticeDO updateObj = new NoticeDO();
|
|
||||||
updateObj.setId(id);
|
|
||||||
updateObj.setStatus(1);
|
|
||||||
updateObj.setPublishTime(LocalDateTime.now());
|
|
||||||
noticeMapper.updateById(updateObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void revokeNotice(Long id) {
|
|
||||||
// 校验存在
|
|
||||||
NoticeDO notice = validateNoticeExists(id);
|
|
||||||
|
|
||||||
// 校验状态
|
|
||||||
if (notice.getStatus() != 1) {
|
|
||||||
throw exception(new com.fjrcloud.community.framework.common.exception.ErrorCode(2_004_000_002, "只有已发布状态的通知才能撤回"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新状态为已撤回
|
|
||||||
NoticeDO updateObj = new NoticeDO();
|
|
||||||
updateObj.setId(id);
|
|
||||||
updateObj.setStatus(3);
|
|
||||||
noticeMapper.updateById(updateObj);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public int autoPublishNotices() {
|
|
||||||
// 查询需要发布的通知:草稿状态 + 发布时间已到
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
|
||||||
List<NoticeDO> notices = noticeMapper.selectList(new com.fjrcloud.community.framework.mybatis.core.query.LambdaQueryWrapperX<NoticeDO>()
|
|
||||||
.eq(NoticeDO::getStatus, 0) // 草稿状态
|
|
||||||
.eq(NoticeDO::getPublishType, 2) // 定时发布
|
|
||||||
.le(NoticeDO::getPublishTime, now) // 发布时间已到
|
|
||||||
);
|
|
||||||
|
|
||||||
if (notices == null || notices.isEmpty()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 批量更新状态为已发布
|
|
||||||
int count = 0;
|
|
||||||
for (NoticeDO notice : notices) {
|
|
||||||
NoticeDO updateObj = new NoticeDO();
|
|
||||||
updateObj.setId(notice.getId());
|
|
||||||
updateObj.setStatus(1); // 已发布
|
|
||||||
noticeMapper.updateById(updateObj);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public int autoExpireNotices() {
|
|
||||||
// 查询需要过期的通知:已发布状态 + 结束类型是定时结束 + 结束时间已到
|
|
||||||
LocalDateTime now = LocalDateTime.now();
|
|
||||||
List<NoticeDO> notices = noticeMapper.selectList(new com.fjrcloud.community.framework.mybatis.core.query.LambdaQueryWrapperX<NoticeDO>()
|
|
||||||
.eq(NoticeDO::getStatus, 1) // 已发布状态
|
|
||||||
.eq(NoticeDO::getEndType, 2) // 定时结束
|
|
||||||
.le(NoticeDO::getEndTime, now) // 结束时间已到
|
|
||||||
);
|
|
||||||
|
|
||||||
if (notices == null || notices.isEmpty()) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 批量更新状态为已过期
|
|
||||||
int count = 0;
|
|
||||||
for (NoticeDO notice : notices) {
|
|
||||||
NoticeDO updateObj = new NoticeDO();
|
|
||||||
updateObj.setId(notice.getId());
|
|
||||||
updateObj.setStatus(2); // 已过期
|
|
||||||
noticeMapper.updateById(updateObj);
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验通知是否存在
|
|
||||||
*
|
|
||||||
* @param id 通知ID
|
|
||||||
* @return 通知对象
|
|
||||||
*/
|
|
||||||
private NoticeDO validateNoticeExists(Long id) {
|
|
||||||
NoticeDO notice = noticeMapper.selectById(id);
|
|
||||||
if (notice == null) {
|
|
||||||
throw exception(NOTICE_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
return notice;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?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">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.fjrcloud.community.module.community.dal.mysql.notice.NoticeMapper">
|
<mapper namespace="com.fjrcloud.community.module.community.dal.mysql.notice.CommunityNoticeMapper">
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
|
||||||
|
|
@ -155,15 +155,7 @@ logging:
|
||||||
com.fjrcloud.community.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info
|
com.fjrcloud.community.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info
|
||||||
com.fjrcloud.community.module.tool.dal.mysql: debug
|
com.fjrcloud.community.module.tool.dal.mysql: debug
|
||||||
com.fjrcloud.community.module.member.dal.mysql: debug
|
com.fjrcloud.community.module.member.dal.mysql: debug
|
||||||
com.fjrcloud.community.module.trade.dal.mysql: debug
|
com.fjrcloud.community.module.community.dal.mysql: debug
|
||||||
com.fjrcloud.community.module.promotion.dal.mysql: debug
|
|
||||||
com.fjrcloud.community.module.statistics.dal.mysql: debug
|
|
||||||
com.fjrcloud.community.module.crm.dal.mysql: debug
|
|
||||||
com.fjrcloud.community.module.erp.dal.mysql: debug
|
|
||||||
com.fjrcloud.community.module.iot.dal.mysql: debug
|
|
||||||
com.fjrcloud.community.module.iot.dal.tdengine: DEBUG
|
|
||||||
com.fjrcloud.community.module.iot.service.rule: debug
|
|
||||||
com.fjrcloud.community.module.ai.dal.mysql: debug
|
|
||||||
org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿:先禁用,Spring Boot 3.X 存在部分错误的 WARN 提示
|
org.springframework.context.support.PostProcessorRegistrationDelegate: ERROR # TODO 芋艿:先禁用,Spring Boot 3.X 存在部分错误的 WARN 提示
|
||||||
|
|
||||||
debug: false
|
debug: false
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue