From bbc4add99e1d925e97277ed5f2d90d9293cdab8c Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期四, 25 九月 2025 18:49:31 +0800
Subject: [PATCH] 初始化店铺扫码领取优惠卷

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

diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/StoreCouponClaimRecordServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/StoreCouponClaimRecordServiceImpl.java
new file mode 100644
index 0000000..375b685
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/StoreCouponClaimRecordServiceImpl.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.StoreCouponClaimRecord;
+import cn.lili.modules.lmk.mapper.StoreCouponClaimRecordMapper;
+import cn.lili.modules.lmk.service.StoreCouponClaimRecordService;
+import cn.lili.base.Result;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import cn.lili.modules.lmk.domain.form.StoreCouponClaimRecordForm;
+import cn.lili.modules.lmk.domain.vo.StoreCouponClaimRecordVO;
+import cn.lili.modules.lmk.domain.query.StoreCouponClaimRecordQuery;
+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-25
+ */
+@Service
+@RequiredArgsConstructor
+public class StoreCouponClaimRecordServiceImpl extends ServiceImpl<StoreCouponClaimRecordMapper, StoreCouponClaimRecord> implements StoreCouponClaimRecordService {
+
+    private final StoreCouponClaimRecordMapper storeCouponClaimRecordMapper;
+
+    /**
+     * 娣诲姞
+     * @param form
+     * @return
+     */
+    @Override
+    public Result add(StoreCouponClaimRecordForm form) {
+        StoreCouponClaimRecord entity = StoreCouponClaimRecordForm.getEntityByForm(form, null);
+        baseMapper.insert(entity);
+        return Result.ok("娣诲姞鎴愬姛");
+    }
+
+    /**
+     * 淇敼
+     * @param form
+     * @return
+     */
+    @Override
+    public Result update(StoreCouponClaimRecordForm form) {
+        StoreCouponClaimRecord 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(StoreCouponClaimRecordQuery query) {
+        IPage<StoreCouponClaimRecordVO> page = PageUtil.getPage(query, StoreCouponClaimRecordVO.class);
+        baseMapper.getPage(page, query);
+        return Result.ok().data(page.getRecords()).total(page.getTotal());
+    }
+
+    /**
+     * 鏍规嵁id鏌ユ壘
+     * @param id
+     * @return
+     */
+    @Override
+    public Result detail(String id) {
+        StoreCouponClaimRecordVO vo = baseMapper.getById(id);
+        Assert.notNull(vo, "璁板綍涓嶅瓨鍦�");
+        return Result.ok().data(vo);
+    }
+
+    /**
+     * 鍒楄〃
+     * @return
+     */
+    @Override
+    public Result all() {
+        List<StoreCouponClaimRecord> entities = baseMapper.selectList(null);
+        List<StoreCouponClaimRecordVO> vos = entities.stream()
+                .map(entity -> StoreCouponClaimRecordVO.getVoByEntity(entity, null))
+                .collect(Collectors.toList());
+        return Result.ok().data(vos);
+    }
+}

--
Gitblit v1.8.0