新建商品缺陷逻辑
This commit is contained in:
parent
655fbe5eb3
commit
07c182b9fe
@ -0,0 +1,94 @@
|
||||
package com.tmerclub.cloud.cuerecycle.controller.admin;
|
||||
|
||||
import com.tmerclub.cloud.common.database.dto.PageDTO;
|
||||
import com.tmerclub.cloud.common.database.vo.PageVO;
|
||||
import com.tmerclub.cloud.common.response.ServerResponseEntity;
|
||||
import com.tmerclub.cloud.cuerecycle.model.dto.CueFlawDTO;
|
||||
import com.tmerclub.cloud.cuerecycle.model.vo.CueFlawVO;
|
||||
import com.tmerclub.cloud.cuerecycle.service.CueFlawService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 球杆缺陷
|
||||
*
|
||||
* @author : frank
|
||||
* @create : 2025-04-13
|
||||
*/
|
||||
@Tag(name = "后管-球杆缺陷")
|
||||
@RestController("adminCueFlawController")
|
||||
@RequestMapping("/admin/cueFlaw")
|
||||
public class CueFlawController {
|
||||
@Resource
|
||||
CueFlawService cueFlawService;
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param pageDTO 分页参数
|
||||
* @param cueFlawDTO 查询参数
|
||||
* @return 分页数据
|
||||
*/
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "查询球杆缺陷分页列表", description = "查询球杆缺陷分页列表")
|
||||
public ServerResponseEntity<PageVO<CueFlawVO>> page(@Valid PageDTO pageDTO, CueFlawDTO cueFlawDTO) {
|
||||
PageVO<CueFlawVO> cueFlawPage = cueFlawService.page(pageDTO, cueFlawDTO);
|
||||
return ServerResponseEntity.success(cueFlawPage);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据主键id获取球杆缺陷
|
||||
*
|
||||
* @param flawId 主键id
|
||||
* @return CueFlawVO
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(summary = "根据id获取球杆缺陷", description = "根据id获取球杆缺陷")
|
||||
public ServerResponseEntity<CueFlawVO> getById(@RequestParam Long flawId) {
|
||||
CueFlawVO cueFlaw = cueFlawService.getById(flawId);
|
||||
return ServerResponseEntity.success(cueFlaw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增球杆缺陷
|
||||
*
|
||||
* @param cueFlawDTO CueFlawDTO
|
||||
* @return ServerResponseEntity
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "新增球杆缺陷", description = "新增球杆缺陷")
|
||||
public ServerResponseEntity<Void> save(@Valid @RequestBody CueFlawDTO cueFlawDTO) {
|
||||
int insert = cueFlawService.save(cueFlawDTO);
|
||||
return insert > 0 ? ServerResponseEntity.success() : ServerResponseEntity.showFailMsg("保存失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改球杆缺陷
|
||||
*
|
||||
* @param cueFlawDTO CueFlawDTO
|
||||
* @return ServerResponseEntity
|
||||
*/
|
||||
@PutMapping
|
||||
@Operation(summary = "修改球杆缺陷", description = "修改球杆缺陷")
|
||||
public ServerResponseEntity<Void> update(@Valid @RequestBody CueFlawDTO cueFlawDTO) {
|
||||
int update = cueFlawService.update(cueFlawDTO);
|
||||
return update > 0 ? ServerResponseEntity.success() : ServerResponseEntity.showFailMsg("修改失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除球杆缺陷
|
||||
*
|
||||
* @param flawId 主键id
|
||||
* @return ServerResponseEntity
|
||||
*/
|
||||
@DeleteMapping
|
||||
@Operation(summary = "删除球杆缺陷", description = "删除球杆缺陷")
|
||||
public ServerResponseEntity<Void> delete(@RequestParam Long flawId) {
|
||||
int delete = cueFlawService.delete(flawId);
|
||||
return delete > 0 ? ServerResponseEntity.success() : ServerResponseEntity.showFailMsg("删除失败");
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.tmerclub.cloud.cuerecycle.controller.app;
|
||||
|
||||
import com.tmerclub.cloud.common.database.dto.PageDTO;
|
||||
import com.tmerclub.cloud.common.database.vo.PageVO;
|
||||
import com.tmerclub.cloud.common.response.ServerResponseEntity;
|
||||
import com.tmerclub.cloud.cuerecycle.model.dto.CueFlawDTO;
|
||||
import com.tmerclub.cloud.cuerecycle.model.vo.CueFlawVO;
|
||||
import com.tmerclub.cloud.cuerecycle.service.CueFlawService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 球杆缺陷
|
||||
*
|
||||
* @author : frank
|
||||
* @create : 2025-04-13
|
||||
*/
|
||||
@Tag(name = "App-球杆缺陷")
|
||||
@RestController("appCueFlawController")
|
||||
@RequestMapping("/app/cueFlaw")
|
||||
public class CueFlawController {
|
||||
@Resource
|
||||
CueFlawService cueFlawService;
|
||||
|
||||
/**
|
||||
* 分页查询启用球杆缺陷列表
|
||||
*
|
||||
* @param pageDTO 分页参数
|
||||
* @return 分页数据
|
||||
*/
|
||||
@GetMapping("/listEnabled")
|
||||
@Operation(summary = "分页查询启用球杆缺陷列表", description = "分页查询启用球杆缺陷列表")
|
||||
public ServerResponseEntity<PageVO<CueFlawVO>> listEnabled(@Valid PageDTO pageDTO) {
|
||||
PageVO<CueFlawVO> cueFlawPage = cueFlawService.listEnabled(pageDTO);
|
||||
return ServerResponseEntity.success(cueFlawPage);
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package com.tmerclub.cloud.cuerecycle.mapper;
|
||||
|
||||
import com.tmerclub.cloud.cuerecycle.model.dto.CueFlawDTO;
|
||||
import com.tmerclub.cloud.cuerecycle.model.vo.CueFlawVO;
|
||||
import com.tmerclub.cloud.cuerecycle.model.CueFlaw;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 球杆缺陷Mapper接口
|
||||
*
|
||||
* @author : frank
|
||||
* @create : 2025-04-13
|
||||
*/
|
||||
public interface CueFlawMapper{
|
||||
|
||||
/**
|
||||
* 查询球杆缺陷列表
|
||||
*
|
||||
* @param cueFlawDTO 查询参数
|
||||
* @return 球杆缺陷列表数据
|
||||
*/
|
||||
List<CueFlawVO> list(@Param("dto") CueFlawDTO cueFlawDTO);
|
||||
|
||||
/**
|
||||
* 获取球杆缺陷详情
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 球杆缺陷详情
|
||||
*/
|
||||
CueFlawVO getById(Long id);
|
||||
|
||||
/**
|
||||
* 新增球杆缺陷
|
||||
*
|
||||
* @param cueFlaw 新增参数
|
||||
* @return 新增结果
|
||||
*/
|
||||
int save(CueFlaw cueFlaw);
|
||||
|
||||
/**
|
||||
* 修改球杆缺陷
|
||||
*
|
||||
* @param cueFlaw 修改参数
|
||||
* @return 修改结果
|
||||
*/
|
||||
int update(CueFlaw cueFlaw);
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.tmerclub.cloud.cuerecycle.model;
|
||||
|
||||
import com.tmerclub.cloud.common.model.BaseModel;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 球杆缺陷对象
|
||||
*
|
||||
* @author : frank
|
||||
* @create : 2025-04-13
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CueFlaw extends BaseModel implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Long flawId;
|
||||
/**
|
||||
* 缺陷名称
|
||||
*/
|
||||
private String flawName;
|
||||
/**
|
||||
* 缺陷影响价格
|
||||
*/
|
||||
private Long flawPrice;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer flawSeq;
|
||||
/**
|
||||
* 状态:0-禁用,1-启用
|
||||
*/
|
||||
private Integer flawStatus;
|
||||
/**
|
||||
* 删除状态 0-未删除 1-已删除
|
||||
*/
|
||||
private Integer deleted;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package com.tmerclub.cloud.cuerecycle.model.dto;
|
||||
|
||||
import com.tmerclub.cloud.common.validate.AddGroup;
|
||||
import com.tmerclub.cloud.common.validate.EditGroup;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 球杆缺陷对象
|
||||
*
|
||||
* @author : frank
|
||||
* @create : 2025-04-13
|
||||
*/
|
||||
@Data
|
||||
public class CueFlawDTO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@NotNull(message = "主键ID不能为空", groups = {EditGroup.class})
|
||||
private Long flawId;
|
||||
/**
|
||||
* 缺陷名称
|
||||
*/
|
||||
@NotBlank(message = "缺陷名称不能为空", groups = {AddGroup.class})
|
||||
private String flawName;
|
||||
/**
|
||||
* 缺陷影响价格
|
||||
*/
|
||||
@NotBlank(message = "缺陷名称不能为空", groups = {AddGroup.class})
|
||||
private Long flawPrice;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer flawSeq;
|
||||
/**
|
||||
* 状态:0-禁用,1-启用
|
||||
*/
|
||||
private Integer flawStatus;
|
||||
/**
|
||||
* 删除状态 0-未删除 1-已删除
|
||||
*/
|
||||
private Integer deleted;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.tmerclub.cloud.cuerecycle.model.vo;
|
||||
|
||||
import com.tmerclub.cloud.common.vo.BaseVO;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 球杆缺陷视图对象
|
||||
*
|
||||
* @author : frank
|
||||
* @create : 2025-04-13
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CueFlawVO extends BaseVO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Schema(description = "主键id")
|
||||
private Long flawId;
|
||||
/**
|
||||
* 缺陷名称
|
||||
*/
|
||||
@Schema(description = "缺陷名称")
|
||||
private String flawName;
|
||||
/**
|
||||
* 缺陷影响价格
|
||||
*/
|
||||
@Schema(description = "缺陷影响价格")
|
||||
private Long flawPrice;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Schema(description = "排序")
|
||||
private Integer flawSeq;
|
||||
/**
|
||||
* 状态:0-禁用,1-启用
|
||||
*/
|
||||
@Schema(description = "状态:0-禁用,1-启用")
|
||||
private Integer flawStatus;
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.tmerclub.cloud.cuerecycle.service;
|
||||
|
||||
import com.tmerclub.cloud.common.database.dto.PageDTO;
|
||||
import com.tmerclub.cloud.common.database.vo.PageVO;
|
||||
import com.tmerclub.cloud.cuerecycle.model.dto.CueFlawDTO;
|
||||
import com.tmerclub.cloud.cuerecycle.model.vo.CueFlawVO;
|
||||
|
||||
/**
|
||||
* 球杆缺陷Service接口
|
||||
*
|
||||
* @author : frank
|
||||
* @create : 2025-04-13
|
||||
*/
|
||||
public interface CueFlawService {
|
||||
|
||||
/**
|
||||
* 获取球杆缺陷分页列表
|
||||
*
|
||||
* @param pageDTO 分页参数
|
||||
* @param cueFlawDTO 查询参数
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageVO<CueFlawVO> page(PageDTO pageDTO, CueFlawDTO cueFlawDTO);
|
||||
|
||||
/**
|
||||
* 获取启用的球杆缺陷分页列表
|
||||
*
|
||||
* @param pageDTO 分页参数
|
||||
* @return 分页数据
|
||||
*/
|
||||
PageVO<CueFlawVO> listEnabled(PageDTO pageDTO);
|
||||
|
||||
/**
|
||||
* 获取球杆缺陷详情
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 球杆缺陷详情
|
||||
*/
|
||||
CueFlawVO getById(Long id);
|
||||
|
||||
/**
|
||||
* 新增球杆缺陷
|
||||
*
|
||||
* @param cueFlawDTO 新增参数
|
||||
* @return 新增结果
|
||||
*/
|
||||
int save(CueFlawDTO cueFlawDTO);
|
||||
|
||||
/**
|
||||
* 修改球杆缺陷
|
||||
*
|
||||
* @param cueFlawDTO 修改参数
|
||||
* @return 修改结果
|
||||
*/
|
||||
int update(CueFlawDTO cueFlawDTO);
|
||||
|
||||
/**
|
||||
* 删除球杆缺陷
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 删除结果
|
||||
*/
|
||||
int delete(Long id);
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.tmerclub.cloud.cuerecycle.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.tmerclub.cloud.common.database.util.PageUtil;
|
||||
import com.tmerclub.cloud.common.database.dto.PageDTO;
|
||||
import com.tmerclub.cloud.common.database.vo.PageVO;
|
||||
import com.tmerclub.cloud.cuerecycle.model.dto.CueFlawDTO;
|
||||
import com.tmerclub.cloud.cuerecycle.model.vo.CueFlawVO;
|
||||
import com.tmerclub.cloud.cuerecycle.model.CueFlaw;
|
||||
import com.tmerclub.cloud.cuerecycle.mapper.CueFlawMapper;
|
||||
import com.tmerclub.cloud.cuerecycle.service.CueFlawService;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 球杆缺陷Service实现类
|
||||
*
|
||||
* @author : frank
|
||||
* @create : 2025-04-13
|
||||
*/
|
||||
@Service
|
||||
public class CueFlawServiceImpl implements CueFlawService {
|
||||
|
||||
@Resource
|
||||
CueFlawMapper cueFlawMapper;
|
||||
|
||||
@Override
|
||||
public PageVO<CueFlawVO> page(PageDTO pageDTO, CueFlawDTO cueFlawDTO) {
|
||||
return PageUtil.doPage(pageDTO, () -> cueFlawMapper.list(cueFlawDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageVO<CueFlawVO> listEnabled(PageDTO pageDTO) {
|
||||
CueFlawDTO cueFlawDTO = new CueFlawDTO();
|
||||
cueFlawDTO.setFlawStatus(1);
|
||||
return PageUtil.doPage(pageDTO, () -> cueFlawMapper.list(cueFlawDTO));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CueFlawVO getById(Long id) {
|
||||
return cueFlawMapper.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int save(CueFlawDTO cueFlawDTO) {
|
||||
CueFlaw cueFlaw = BeanUtil.toBean(cueFlawDTO, CueFlaw.class);
|
||||
cueFlaw.setCreateTime(DateUtil.date());
|
||||
return cueFlawMapper.save(cueFlaw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(CueFlawDTO cueFlawDTO) {
|
||||
CueFlaw cueFlaw = BeanUtil.toBean(cueFlawDTO, CueFlaw.class);
|
||||
cueFlaw.setUpdateTime(DateUtil.date());
|
||||
return cueFlawMapper.update(cueFlaw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Long id) {
|
||||
CueFlawVO cueFlawVO = cueFlawMapper.getById(id);
|
||||
CueFlaw cueFlaw = BeanUtil.toBean(cueFlawVO, CueFlaw.class);
|
||||
cueFlaw.setUpdateTime(DateUtil.date());
|
||||
cueFlaw.setDeleted(1);
|
||||
return cueFlawMapper.update(cueFlaw);
|
||||
}
|
||||
}
|
89
tmerclub-local/src/main/resources/mapper/CueFlawMapper.xml
Normal file
89
tmerclub-local/src/main/resources/mapper/CueFlawMapper.xml
Normal file
@ -0,0 +1,89 @@
|
||||
<?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="com.tmerclub.cloud.cuerecycle.mapper.CueFlawMapper">
|
||||
|
||||
<!-- 可根据自己的需求,是否要使用 -->
|
||||
<resultMap id="cueFlawVOMap" type="com.tmerclub.cloud.cuerecycle.model.vo.CueFlawVO">
|
||||
<result property="flawId" column="flaw_id"/>
|
||||
<result property="flawName" column="flaw_name"/>
|
||||
<result property="flawPrice" column="flaw_price"/>
|
||||
<result property="flawSeq" column="flaw_seq"/>
|
||||
<result property="flawStatus" column="flaw_status"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Vo_Column_List">
|
||||
flaw_id,flaw_name,flaw_price,flaw_seq,flaw_status,deleted,create_time,update_time
|
||||
</sql>
|
||||
|
||||
<select id="list" resultMap="cueFlawVOMap">
|
||||
SELECT
|
||||
<include refid="Vo_Column_List" />
|
||||
FROM cue_flaw
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="dto.flawName != null and dto.flawName != ''">
|
||||
AND flaw_name LIKE CONCAT('%', #{dto.flawName}, '%')
|
||||
</if>
|
||||
<if test="dto.flawStatus != null">
|
||||
AND flaw_status = #{dto.flawStatus}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY
|
||||
flaw_seq ASC,
|
||||
flaw_id DESC
|
||||
</select>
|
||||
|
||||
<select id="getById" resultMap="cueFlawVOMap">
|
||||
SELECT
|
||||
<include refid="Vo_Column_List" />
|
||||
FROM
|
||||
cue_flaw
|
||||
WHERE flaw_id = #{flawId}
|
||||
</select>
|
||||
|
||||
<insert id="save" useGeneratedKeys="true" keyProperty="flawId">
|
||||
INSERT INTO cue_flaw
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="flawName != null">flaw_name,</if>
|
||||
<if test="flawPrice != null">flaw_price,</if>
|
||||
<if test="flawSeq != null">flaw_seq,</if>
|
||||
<if test="flawStatus != null">flaw_status,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="flawName != null">#{flawName},</if>
|
||||
<if test="flawPrice != null">#{flawPrice},</if>
|
||||
<if test="flawSeq != null">#{flawSeq},</if>
|
||||
<if test="flawStatus != null">#{flawStatus},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="update">
|
||||
UPDATE cue_flaw
|
||||
<set>
|
||||
<if test="flawName != null">
|
||||
flaw_name = #{flawName},
|
||||
</if>
|
||||
<if test="flawPrice != null">
|
||||
flaw_price = #{flawPrice},
|
||||
</if>
|
||||
<if test="flawSeq != null">
|
||||
flaw_seq = #{flawSeq},
|
||||
</if>
|
||||
<if test="flawStatus != null">
|
||||
flaw_status = #{flawStatus},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
where flaw_id = #{flawId}
|
||||
</update>
|
||||
</mapper>
|
Loading…
x
Reference in New Issue
Block a user