From 86adcac79055c748738a36ce631af1d0badf25f2 Mon Sep 17 00:00:00 2001
From: xiangpei <xiangpei@timesnew.cn>
Date: 星期二, 13 五月 2025 15:41:33 +0800
Subject: [PATCH] 视频标签代码生成

---
 framework/src/main/java/cn/lili/modules/lmk/service/VideoTagService.java          |   65 ++++++++++++++++
 framework/src/main/java/cn/lili/modules/lmk/mapper/VideoTagMapper.java            |   34 ++++++++
 framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java |  119 +++++++++++++++++++++++++++++
 3 files changed, 218 insertions(+), 0 deletions(-)

diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoTagMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoTagMapper.java
new file mode 100644
index 0000000..8727463
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/VideoTagMapper.java
@@ -0,0 +1,34 @@
+package cn.lili.modules.lmk.mapper;
+
+import cn.lili.modules.lmk.domain.entity.VideoTag;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import cn.lili.modules.lmk.domain.vo.VideoTagVO;
+import cn.lili.modules.lmk.domain.form.VideoTagForm;
+import cn.lili.modules.lmk.domain.query.VideoTagQuery;
+import java.util.List;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 瑙嗛鏍囩 Mapper 鎺ュ彛
+ *
+ * @author xp
+ * @since 2025-05-13
+ */
+@Mapper
+public interface VideoTagMapper extends BaseMapper<VideoTag> {
+
+    /**
+     * id鏌ユ壘瑙嗛鏍囩
+     * @param id
+     * @return
+     */
+    VideoTagVO getById(Integer id);
+
+    /**
+    *  鍒嗛〉
+    */
+    IPage getPage(IPage page, @Param("query") VideoTagQuery query);
+
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/VideoTagService.java b/framework/src/main/java/cn/lili/modules/lmk/service/VideoTagService.java
new file mode 100644
index 0000000..08cf306
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/VideoTagService.java
@@ -0,0 +1,65 @@
+package cn.lili.modules.lmk.service;
+
+import cn.lili.modules.lmk.domain.entity.VideoTag;
+import com.baomidou.mybatisplus.extension.service.IService;
+import cn.lili.base.Result;
+import cn.lili.modules.lmk.domain.form.VideoTagForm;
+import cn.lili.modules.lmk.domain.query.VideoTagQuery;
+import java.util.List;
+
+/**
+ * 瑙嗛鏍囩 鏈嶅姟绫�
+ *
+ * @author xp
+ * @since 2025-05-13
+ */
+public interface VideoTagService extends IService<VideoTag> {
+
+    /**
+     * 娣诲姞
+     * @param form
+     * @return
+     */
+    Result add(VideoTagForm form);
+
+    /**
+     * 淇敼
+     * @param form
+     * @return
+     */
+    Result update(VideoTagForm form);
+
+    /**
+     * 鎵归噺鍒犻櫎
+     * @param ids
+     * @return
+     */
+    Result remove(List<String> ids);
+
+    /**
+     * id鍒犻櫎
+     * @param id
+     * @return
+     */
+    Result removeById(String id);
+
+    /**
+     * 鍒嗛〉鏌ヨ
+     * @param query
+     * @return
+     */
+    Result page(VideoTagQuery query);
+
+    /**
+     * 鏍规嵁id鏌ユ壘
+     * @param id
+     * @return
+     */
+    Result detail(Integer id);
+
+    /**
+     * 鍒楄〃
+     * @return
+     */
+    Result all();
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.java
new file mode 100644
index 0000000..ec86ed3
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/VideoTagServiceImpl.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.VideoTag;
+import cn.lili.modules.lmk.mapper.VideoTagMapper;
+import cn.lili.modules.lmk.service.VideoTagService;
+import cn.lili.base.Result;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import cn.lili.modules.lmk.domain.form.VideoTagForm;
+import cn.lili.modules.lmk.domain.vo.VideoTagVO;
+import cn.lili.modules.lmk.domain.query.VideoTagQuery;
+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 xp
+ * @since 2025-05-13
+ */
+@Service
+@RequiredArgsConstructor
+public class VideoTagServiceImpl extends ServiceImpl<VideoTagMapper, VideoTag> implements VideoTagService {
+
+    private final VideoTagMapper videoTagMapper;
+
+    /**
+     * 娣诲姞
+     * @param form
+     * @return
+     */
+    @Override
+    public Result add(VideoTagForm form) {
+        VideoTag entity = VideoTagForm.getEntityByForm(form, null);
+        baseMapper.insert(entity);
+        return Result.ok("娣诲姞鎴愬姛");
+    }
+
+    /**
+     * 淇敼
+     * @param form
+     * @return
+     */
+    @Override
+    public Result update(VideoTagForm form) {
+        VideoTag 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(VideoTagQuery query) {
+        IPage<VideoTagVO> page = PageUtil.getPage(query, VideoTagVO.class);
+        baseMapper.getPage(page, query);
+        return Result.ok().data(page.getRecords()).total(page.getTotal());
+    }
+
+    /**
+     * 鏍规嵁id鏌ユ壘
+     * @param id
+     * @return
+     */
+    @Override
+    public Result detail(Integer id) {
+        VideoTagVO vo = baseMapper.getById(id);
+        Assert.notNull(vo, "璁板綍涓嶅瓨鍦�");
+        return Result.ok().data(vo);
+    }
+
+    /**
+     * 鍒楄〃
+     * @return
+     */
+    @Override
+    public Result all() {
+        List<VideoTag> entities = baseMapper.selectList(null);
+        List<VideoTagVO> vos = entities.stream()
+                .map(entity -> VideoTagVO.getVoByEntity(entity, null))
+                .collect(Collectors.toList());
+        return Result.ok().data(vos);
+    }
+}

--
Gitblit v1.8.0