From 88bd75d93f86d3cf4f12e652d459da8bae71e545 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期二, 24 六月 2025 15:22:04 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev
---
framework/src/main/java/cn/lili/modules/lmk/service/impl/NewsServiceImpl.java | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 108 insertions(+), 0 deletions(-)
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/NewsServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/NewsServiceImpl.java
new file mode 100644
index 0000000..92011fc
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/NewsServiceImpl.java
@@ -0,0 +1,108 @@
+package cn.lili.modules.lmk.service.impl;
+
+
+import cn.lili.base.Result;
+import cn.lili.common.enums.ActivityCoverTypeEnum;
+import cn.lili.modules.lmk.domain.entity.Activity;
+import cn.lili.modules.lmk.domain.entity.MySubscribe;
+import cn.lili.modules.lmk.domain.entity.News;
+import cn.lili.modules.lmk.domain.form.ActivityForm;
+import cn.lili.modules.lmk.domain.form.NewsForm;
+import cn.lili.modules.lmk.domain.query.NewsQuery;
+import cn.lili.modules.lmk.domain.vo.ActivityVO;
+import cn.lili.modules.lmk.domain.vo.NewsVO;
+import cn.lili.modules.lmk.mapper.NewsMapper;
+import cn.lili.modules.lmk.service.NewsService;
+import cn.lili.utils.PageUtil;
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
+
+import java.util.*;
+import java.util.function.Function;
+
+/**
+ * lmk-shop-java
+ * 鏂伴椈鏈嶅姟瀹炵幇绫�
+ *
+ * @author : zxl
+ * @date : 2025-06-20 14:55
+ **/
+@Service
+@RequiredArgsConstructor
+public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> implements NewsService {
+
+ private final NewsMapper newsMapper;
+ @Override
+ public Result add(NewsForm form) {
+ News entity = NewsForm.getEntityByForm(form, null);
+ baseMapper.insert(entity);
+ return Result.ok("娣诲姞鎴愬姛");
+ }
+
+ @Override
+ public Result update(NewsForm form) {
+ News entity = baseMapper.selectById(form.getId());
+
+ Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
+ BeanUtils.copyProperties(form, entity);
+
+ baseMapper.updateById(entity);
+
+
+ return Result.ok("淇敼鎴愬姛");
+ }
+
+ @Override
+ public Result remove(List<String> ids) {
+ baseMapper.deleteBatchIds(ids);
+ return Result.ok("鍒犻櫎鎴愬姛");
+ }
+
+ @Override
+ public Result removeById(String id) {
+ //鍒ゆ柇鏄惁鍙戝竷鍙戝竷鍒欐彁绀哄厛涓嬫灦锛屽啀鍒犻櫎
+ News entity = baseMapper.selectById(id);
+ if(entity.getPublish()){
+ throw new RuntimeException("璇ユ柊闂诲凡鍙戝竷");
+ }
+
+ baseMapper.deleteById(id);
+ return Result.ok("鍒犻櫎鎴愬姛");
+ }
+
+ @Override
+ public Result page(NewsQuery query) {
+ IPage<NewsVO> page = PageUtil.getPage(query, NewsVO.class);
+
+ baseMapper.getPage(page, query);
+
+ return Result.ok().data(page.getRecords()).total(page.getTotal());
+ }
+
+ @Override
+ public Result detail(String id) {
+ NewsVO vo = baseMapper.getById(id);
+ Assert.notNull(vo, "璁板綍涓嶅瓨鍦�");
+ return Result.ok().data(vo);
+ }
+
+ @Override
+ public Result publish(String id) {
+ News entity = baseMapper.selectById(id);
+ if (!entity.getPublish()) {
+ entity.setPublishDate(new Date());
+ }else {
+ entity.setPublishDate(null);
+ }
+ entity.setPublish(!entity.getPublish());
+ baseMapper.updateById(entity);
+ return Result.ok("鎴愬姛");
+ }
+
+
+}
--
Gitblit v1.8.0