From 355c1a7e343e0d3f75befac1cf49be07ec11b4e7 Mon Sep 17 00:00:00 2001
From: peng <peng.com>
Date: 星期五, 13 六月 2025 14:52:00 +0800
Subject: [PATCH] insert 完成厨神标签后台页面接口(增删改查/上架/下架)
---
framework/src/main/java/cn/lili/modules/lmk/domain/form/KitchenTypeForm.java | 45 +++++
framework/src/main/java/cn/lili/modules/lmk/domain/query/KitchenTypeQuery.java | 24 ++
framework/src/main/resources/mapper/lmk/KitchenTypeMapper.xml | 48 +++++
framework/src/main/java/cn/lili/modules/lmk/service/impl/KitchenTypeServiceImpl.java | 135 +++++++++++++++
framework/src/main/java/cn/lili/modules/lmk/domain/entity/KitchenType.java | 33 +++
framework/src/main/java/cn/lili/modules/lmk/mapper/KitchenTypeMapper.java | 34 +++
manager-api/src/main/java/cn/lili/controller/lmk/KitchenTypeController.java | 76 ++++++++
framework/src/main/java/cn/lili/modules/lmk/service/KitchenTypeService.java | 65 +++++++
framework/src/main/java/cn/lili/modules/lmk/domain/vo/KitchenTypeVO.java | 43 ++++
9 files changed, 503 insertions(+), 0 deletions(-)
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/entity/KitchenType.java b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/KitchenType.java
new file mode 100644
index 0000000..7c22910
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/entity/KitchenType.java
@@ -0,0 +1,33 @@
+package cn.lili.modules.lmk.domain.entity;
+
+import cn.lili.mybatis.BaseEntity;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+/**
+ * 鍘ㄧ绫诲瀷
+ *
+ * @author wp
+ * @since 2025-06-13
+ */
+@Data
+@TableName("lmk_kitchen_type")
+public class KitchenType extends BaseEntity {
+
+ private static final long serialVersionUID = 1L;
+
+ @TableField("type_name")
+ /** 鍘ㄧ绫诲瀷 */
+ private String typeName;
+
+ @TableField("use_num")
+ /** 浣跨敤娆℃暟 */
+ private Long useNum;
+
+ @TableField("sort_num")
+ /** 鎺掑簭瀛楁 */
+ private Long sortNum;
+
+
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/form/KitchenTypeForm.java b/framework/src/main/java/cn/lili/modules/lmk/domain/form/KitchenTypeForm.java
new file mode 100644
index 0000000..3887943
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/form/KitchenTypeForm.java
@@ -0,0 +1,45 @@
+package cn.lili.modules.lmk.domain.form;
+
+import cn.lili.group.Update;
+import cn.lili.group.Add;
+import cn.lili.base.AbsForm;
+import cn.lili.modules.lmk.domain.entity.KitchenType;
+import org.springframework.beans.BeanUtils;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import org.springframework.lang.NonNull;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.util.Date;
+
+/**
+ * 鍘ㄧ绫诲瀷琛ㄥ崟
+ *
+ * @author wp
+ * @since 2025-06-13
+ */
+@Data
+@ApiModel(value = "KitchenType琛ㄥ崟", description = "鍘ㄧ绫诲瀷琛ㄥ崟")
+public class KitchenTypeForm extends AbsForm {
+
+ @NotBlank(message = "鍘ㄧ绫诲瀷涓嶈兘涓虹┖", groups = {Add.class, Update.class})
+ @ApiModelProperty("鍘ㄧ绫诲瀷")
+ private String typeName;
+
+ @ApiModelProperty("浣跨敤娆℃暟")
+ private Long useNum;
+
+ @NotNull(message = "鎺掑簭瀛楁涓嶈兘涓虹┖", groups = {Add.class, Update.class})
+ @ApiModelProperty("鎺掑簭瀛楁")
+ private Long sortNum;
+
+ public static KitchenType getEntityByForm(@NonNull KitchenTypeForm form, KitchenType entity) {
+ if(entity == null) {
+ entity = new KitchenType();
+ }
+ BeanUtils.copyProperties(form, entity);
+ return entity;
+ }
+
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/query/KitchenTypeQuery.java b/framework/src/main/java/cn/lili/modules/lmk/domain/query/KitchenTypeQuery.java
new file mode 100644
index 0000000..678b28c
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/query/KitchenTypeQuery.java
@@ -0,0 +1,24 @@
+package cn.lili.modules.lmk.domain.query;
+
+import cn.lili.base.AbsQuery;
+import java.util.List;
+import org.springframework.lang.NonNull;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 鍘ㄧ绫诲瀷鏌ヨ
+ *
+ * @author wp
+ * @since 2025-06-13
+ */
+@Data
+@ApiModel(value = "KitchenType鏌ヨ鍙傛暟", description = "鍘ㄧ绫诲瀷鏌ヨ鍙傛暟")
+public class KitchenTypeQuery extends AbsQuery {
+ @ApiModelProperty("鏍囩鍚嶇О")
+ private String typeName;
+}
+
diff --git a/framework/src/main/java/cn/lili/modules/lmk/domain/vo/KitchenTypeVO.java b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/KitchenTypeVO.java
new file mode 100644
index 0000000..a56c395
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/domain/vo/KitchenTypeVO.java
@@ -0,0 +1,43 @@
+package cn.lili.modules.lmk.domain.vo;
+
+import cn.lili.base.AbsVo;
+import cn.lili.modules.lmk.domain.entity.KitchenType;
+import java.util.List;
+import org.springframework.lang.NonNull;
+import org.springframework.beans.BeanUtils;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import java.util.Date;
+
+/**
+ * 鍘ㄧ绫诲瀷灞曠ず
+ *
+ * @author wp
+ * @since 2025-06-13
+ */
+@Data
+@ApiModel(value = "鍘ㄧ绫诲瀷鍝嶅簲鏁版嵁", description = "鍘ㄧ绫诲瀷鍝嶅簲鏁版嵁")
+public class KitchenTypeVO extends AbsVo {
+
+ /** 鍘ㄧ绫诲瀷 */
+ @ApiModelProperty("鍘ㄧ绫诲瀷")
+ private String typeName;
+
+ /** 浣跨敤娆℃暟 */
+ @ApiModelProperty("浣跨敤娆℃暟")
+ private Long useNum;
+
+ /** 鎺掑簭瀛楁 */
+ @ApiModelProperty("鎺掑簭瀛楁")
+ private Long sortNum;
+
+ public static KitchenTypeVO getVoByEntity(@NonNull KitchenType entity, KitchenTypeVO vo) {
+ if(vo == null) {
+ vo = new KitchenTypeVO();
+ }
+ BeanUtils.copyProperties(entity, vo);
+ return vo;
+ }
+
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/mapper/KitchenTypeMapper.java b/framework/src/main/java/cn/lili/modules/lmk/mapper/KitchenTypeMapper.java
new file mode 100644
index 0000000..199b8c8
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/mapper/KitchenTypeMapper.java
@@ -0,0 +1,34 @@
+package cn.lili.modules.lmk.mapper;
+
+import cn.lili.modules.lmk.domain.entity.KitchenType;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import cn.lili.modules.lmk.domain.vo.KitchenTypeVO;
+import cn.lili.modules.lmk.domain.form.KitchenTypeForm;
+import cn.lili.modules.lmk.domain.query.KitchenTypeQuery;
+import java.util.List;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+/**
+ * 鍘ㄧ绫诲瀷 Mapper 鎺ュ彛
+ *
+ * @author wp
+ * @since 2025-06-13
+ */
+@Mapper
+public interface KitchenTypeMapper extends BaseMapper<KitchenType> {
+
+ /**
+ * id鏌ユ壘鍘ㄧ绫诲瀷
+ * @param id
+ * @return
+ */
+ KitchenTypeVO getById(String id);
+
+ /**
+ * 鍒嗛〉
+ */
+ IPage getPage(IPage page, @Param("query") KitchenTypeQuery query);
+
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/KitchenTypeService.java b/framework/src/main/java/cn/lili/modules/lmk/service/KitchenTypeService.java
new file mode 100644
index 0000000..322ea84
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/KitchenTypeService.java
@@ -0,0 +1,65 @@
+package cn.lili.modules.lmk.service;
+
+import cn.lili.modules.lmk.domain.entity.KitchenType;
+import com.baomidou.mybatisplus.extension.service.IService;
+import cn.lili.base.Result;
+import cn.lili.modules.lmk.domain.form.KitchenTypeForm;
+import cn.lili.modules.lmk.domain.query.KitchenTypeQuery;
+import java.util.List;
+
+/**
+ * 鍘ㄧ绫诲瀷 鏈嶅姟绫�
+ *
+ * @author wp
+ * @since 2025-06-13
+ */
+public interface KitchenTypeService extends IService<KitchenType> {
+
+ /**
+ * 娣诲姞
+ * @param form
+ * @return
+ */
+ Result add(KitchenTypeForm form);
+
+ /**
+ * 淇敼
+ * @param form
+ * @return
+ */
+ Result update(KitchenTypeForm form);
+
+ /**
+ * 鎵归噺鍒犻櫎
+ * @param ids
+ * @return
+ */
+ Result remove(List<String> ids);
+
+ /**
+ * id鍒犻櫎
+ * @param id
+ * @return
+ */
+ Result removeById(String id);
+
+ /**
+ * 鍒嗛〉鏌ヨ
+ * @param query
+ * @return
+ */
+ Result page(KitchenTypeQuery query);
+
+ /**
+ * 鏍规嵁id鏌ユ壘
+ * @param id
+ * @return
+ */
+ Result detail(String id);
+
+ /**
+ * 鍒楄〃
+ * @return
+ */
+ Result all();
+}
diff --git a/framework/src/main/java/cn/lili/modules/lmk/service/impl/KitchenTypeServiceImpl.java b/framework/src/main/java/cn/lili/modules/lmk/service/impl/KitchenTypeServiceImpl.java
new file mode 100644
index 0000000..d2e0f9c
--- /dev/null
+++ b/framework/src/main/java/cn/lili/modules/lmk/service/impl/KitchenTypeServiceImpl.java
@@ -0,0 +1,135 @@
+package cn.lili.modules.lmk.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import cn.lili.modules.lmk.domain.entity.KitchenType;
+import cn.lili.modules.lmk.mapper.KitchenTypeMapper;
+import cn.lili.modules.lmk.service.KitchenTypeService;
+import cn.lili.base.Result;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import cn.lili.modules.lmk.domain.form.KitchenTypeForm;
+import cn.lili.modules.lmk.domain.vo.KitchenTypeVO;
+import cn.lili.modules.lmk.domain.query.KitchenTypeQuery;
+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 wp
+ * @since 2025-06-13
+ */
+@Service
+@RequiredArgsConstructor
+public class KitchenTypeServiceImpl extends ServiceImpl<KitchenTypeMapper, KitchenType> implements KitchenTypeService {
+
+ private final KitchenTypeMapper kitchenTypeMapper;
+
+ /**
+ * 娣诲姞
+ * @param form
+ * @return
+ */
+ @Override
+ public Result add(KitchenTypeForm form) {
+ KitchenType entity = KitchenTypeForm.getEntityByForm(form, null);
+ entity.setUseNum(0L);
+ LambdaQueryWrapper<KitchenType> wrapper = Wrappers.lambdaQuery();
+ wrapper.eq(KitchenType::getTypeName, form.getTypeName());
+ List<KitchenType> kitchenTypes = baseMapper.selectList(wrapper);
+ if (!kitchenTypes.isEmpty()) {
+ return Result.error("娣诲姞澶辫触鏍囩瀛樺湪");
+ }
+ baseMapper.insert(entity);
+ return Result.ok("娣诲姞鎴愬姛");
+ }
+
+ /**
+ * 淇敼
+ * @param form
+ * @return
+ */
+ @Override
+ public Result update(KitchenTypeForm form) {
+ KitchenType entity = baseMapper.selectById(form.getId());
+
+ // 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
+ Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
+ BeanUtils.copyProperties(form, entity);
+ //鏍¢獙鏍囩鏄惁瀛樺湪
+ LambdaQueryWrapper<KitchenType> wrapper = Wrappers.lambdaQuery();
+ wrapper.eq(KitchenType::getTypeName, form.getTypeName());
+ List<KitchenType> kitchenTypes = baseMapper.selectList(wrapper);
+ if (!kitchenTypes.isEmpty()) {
+ return Result.error("淇敼澶辫触鏍囩瀛樺湪");
+ }
+ 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(KitchenTypeQuery query) {
+ IPage<KitchenTypeVO> page = PageUtil.getPage(query, KitchenTypeVO.class);
+ baseMapper.getPage(page, query);
+ return Result.ok().data(page.getRecords()).total(page.getTotal());
+ }
+
+ /**
+ * 鏍规嵁id鏌ユ壘
+ * @param id
+ * @return
+ */
+ @Override
+ public Result detail(String id) {
+ KitchenTypeVO vo = baseMapper.getById(id);
+ Assert.notNull(vo, "璁板綍涓嶅瓨鍦�");
+ return Result.ok().data(vo);
+ }
+
+ /**
+ * 鍒楄〃
+ * @return
+ */
+ @Override
+ public Result all() {
+ List<KitchenType> entities = baseMapper.selectList(null);
+ List<KitchenTypeVO> vos = entities.stream()
+ .map(entity -> KitchenTypeVO.getVoByEntity(entity, null))
+ .collect(Collectors.toList());
+ return Result.ok().data(vos);
+ }
+}
diff --git a/framework/src/main/resources/mapper/lmk/KitchenTypeMapper.xml b/framework/src/main/resources/mapper/lmk/KitchenTypeMapper.xml
new file mode 100644
index 0000000..ce33f35
--- /dev/null
+++ b/framework/src/main/resources/mapper/lmk/KitchenTypeMapper.xml
@@ -0,0 +1,48 @@
+<?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">
+<mapper namespace="cn.lili.modules.lmk.mapper.KitchenTypeMapper">
+
+ <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
+ <resultMap id="BaseResultMap" type="cn.lili.modules.lmk.domain.vo.KitchenTypeVO">
+ <id column="id" property="id"/>
+ <result column="type_name" property="typeName" />
+ <result column="use_num" property="useNum" />
+ <result column="sort_num" property="sortNum" />
+ </resultMap>
+
+
+
+
+
+
+
+ <select id="getById" resultMap="BaseResultMap">
+ SELECT
+ LKT.type_name,
+ LKT.use_num,
+ LKT.sort_num,
+ LKT.id
+ FROM
+ lmk_kitchen_type LKT
+ WHERE
+ LKT.id = #{id} AND LKT.delete_flag = 0
+ </select>
+
+
+ <select id="getPage" resultMap="BaseResultMap">
+ SELECT
+ LKT.type_name,
+ LKT.use_num,
+ LKT.sort_num,
+ LKT.id
+ FROM
+ lmk_kitchen_type LKT
+ WHERE
+ LKT.delete_flag = 0
+ <if test="query.typeName != null and query.typeName != ''">
+ AND LKT.type_name LIKE CONCAT('%', #{query.typeName},'%')
+ </if>
+ order by LKT.sort_num asc
+ </select>
+
+</mapper>
diff --git a/manager-api/src/main/java/cn/lili/controller/lmk/KitchenTypeController.java b/manager-api/src/main/java/cn/lili/controller/lmk/KitchenTypeController.java
new file mode 100644
index 0000000..d2c3d80
--- /dev/null
+++ b/manager-api/src/main/java/cn/lili/controller/lmk/KitchenTypeController.java
@@ -0,0 +1,76 @@
+package cn.lili.controller.lmk;
+
+import cn.lili.group.Update;
+import cn.lili.group.Add;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import lombok.RequiredArgsConstructor;
+import java.util.List;
+import org.springframework.validation.annotation.Validated;
+import javax.validation.constraints.NotEmpty;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import cn.lili.modules.lmk.service.KitchenTypeService;
+import cn.lili.base.Result;
+import cn.lili.modules.lmk.domain.form.KitchenTypeForm;
+import cn.lili.modules.lmk.domain.query.KitchenTypeQuery;
+import lombok.RequiredArgsConstructor;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 鍘ㄧ绫诲瀷 鍓嶇鎺у埗鍣�
+ *
+ * @author wp
+ * @since 2025-06-13
+ */
+@Validated
+@RequiredArgsConstructor
+@Api(value = "鍘ㄧ绫诲瀷", tags = "鍘ㄧ绫诲瀷绠$悊")
+@RestController
+@RequestMapping("/manager/lmk/kitchen-type")
+public class KitchenTypeController {
+
+ private final KitchenTypeService kitchenTypeService;
+
+ @PostMapping
+ @ApiOperation(value = "娣诲姞", notes = "娣诲姞")
+ public Result add(@RequestBody @Validated(Add.class) KitchenTypeForm form) {
+ return kitchenTypeService.add(form);
+ }
+
+ @PutMapping
+ @ApiOperation(value = "淇敼", notes = "淇敼")
+ public Result update(@RequestBody @Validated(Update.class) KitchenTypeForm form) {
+ return kitchenTypeService.update(form);
+ }
+
+ @DeleteMapping("/{id}")
+ @ApiOperation(value = "ID鍒犻櫎", notes = "ID鍒犻櫎")
+ public Result removeById(@PathVariable("id") String id) {
+ return kitchenTypeService.removeById(id);
+ }
+
+ @DeleteMapping("/batch")
+ @ApiOperation(value = "鎵归噺鍒犻櫎", notes = "鎵归噺鍒犻櫎")
+ public Result remove(@RequestBody @NotEmpty(message = "璇烽�夋嫨鏁版嵁") List<String> ids) {
+ return kitchenTypeService.remove(ids);
+ }
+
+ @GetMapping("/page")
+ @ApiOperation(value = "鍒嗛〉", notes = "鍒嗛〉")
+ public Result page(KitchenTypeQuery query) {
+ return kitchenTypeService.page(query);
+ }
+
+ @GetMapping("/{id}")
+ @ApiOperation(value = "璇︽儏", notes = "璇︽儏")
+ public Result detail(@PathVariable("id") String id) {
+ return kitchenTypeService.detail(id);
+ }
+
+ @GetMapping("/list")
+ @ApiOperation(value = "鍒楄〃", notes = "鍒楄〃")
+ public Result list() {
+ return kitchenTypeService.all();
+ }
+}
--
Gitblit v1.8.0