From 6c3c5f3fb28cc65684e065b60a09768cf8a77429 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期一, 29 九月 2025 23:45:13 +0800
Subject: [PATCH] 添加抽奖次数加锁

---
 framework/src/main/java/cn/lili/modules/lmk/service/impl/AddNumCheekServiceImpl.java |  119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 119 insertions(+), 0 deletions(-)

diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/AddNumCheekServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/AddNumCheekServiceImpl.java
new file mode 100644
index 0000000..a701e5a
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/AddNumCheekServiceImpl.java
@@ -0,0 +1,119 @@
+package cn.lili.modules.lmk.service.impl;
+
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import cn.lili.modules.lmk.domain.entity.AddNumCheek;
+import cn.lili.modules.lmk.mapper.AddNumCheekMapper;
+import cn.lili.modules.lmk.service.AddNumCheekService;
+import cn.lili.base.Result;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import cn.lili.modules.lmk.domain.form.AddNumCheekForm;
+import cn.lili.modules.lmk.domain.vo.AddNumCheekVO;
+import cn.lili.modules.lmk.domain.query.AddNumCheekQuery;
+import org.springframework.stereotype.Service;
+import lombok.RequiredArgsConstructor;
+import cn.lili.utils.PageUtil;
+import org.springframework.beans.BeanUtils;
+import org.springframework.util.Assert;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * 鐢ㄦ埛澧炲姞娆℃暟鏍¢獙 鏈嶅姟瀹炵幇绫�
+ *
+ * @author peng
+ * @since 2025-09-29
+ */
+@Service
+@RequiredArgsConstructor
+public class AddNumCheekServiceImpl extends ServiceImpl<AddNumCheekMapper, AddNumCheek> implements AddNumCheekService {
+
+    private final AddNumCheekMapper addNumCheekMapper;
+
+    /**
+     * 娣诲姞
+     * @param form
+     * @return
+     */
+    @Override
+    public Result add(AddNumCheekForm form) {
+        AddNumCheek entity = AddNumCheekForm.getEntityByForm(form, null);
+        baseMapper.insert(entity);
+        return Result.ok("娣诲姞鎴愬姛");
+    }
+
+    /**
+     * 淇敼
+     * @param form
+     * @return
+     */
+    @Override
+    public Result update(AddNumCheekForm form) {
+        AddNumCheek entity = baseMapper.selectById(form.getId());
+
+        // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
+        Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
+        BeanUtils.copyProperties(form, entity);
+        baseMapper.updateById(entity);
+        return Result.ok("淇敼鎴愬姛");
+    }
+
+    /**
+     * 鎵归噺鍒犻櫎
+     * @param ids
+     * @return
+     */
+    @Override
+    public Result remove(List<String> ids) {
+        baseMapper.deleteBatchIds(ids);
+        return Result.ok("鍒犻櫎鎴愬姛");
+    }
+
+    /**
+     * id鍒犻櫎
+     * @param id
+     * @return
+     */
+    @Override
+    public Result removeById(String id) {
+        baseMapper.deleteById(id);
+        return Result.ok("鍒犻櫎鎴愬姛");
+    }
+
+    /**
+     * 鍒嗛〉鏌ヨ
+     * @param query
+     * @return
+     */
+    @Override
+    public Result page(AddNumCheekQuery query) {
+        IPage<AddNumCheekVO> page = PageUtil.getPage(query, AddNumCheekVO.class);
+        baseMapper.getPage(page, query);
+        return Result.ok().data(page.getRecords()).total(page.getTotal());
+    }
+
+    /**
+     * 鏍规嵁id鏌ユ壘
+     * @param id
+     * @return
+     */
+    @Override
+    public Result detail(String id) {
+        AddNumCheekVO vo = baseMapper.getById(id);
+        Assert.notNull(vo, "璁板綍涓嶅瓨鍦�");
+        return Result.ok().data(vo);
+    }
+
+    /**
+     * 鍒楄〃
+     * @return
+     */
+    @Override
+    public Result all() {
+        List<AddNumCheek> entities = baseMapper.selectList(null);
+        List<AddNumCheekVO> vos = entities.stream()
+                .map(entity -> AddNumCheekVO.getVoByEntity(entity, null))
+                .collect(Collectors.toList());
+        return Result.ok().data(vos);
+    }
+}

--
Gitblit v1.8.0