增加步梯费用设置业务功能
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
package com.gxwebsoft.shop.controller;
|
||||
|
||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
||||
import com.gxwebsoft.common.core.web.ApiResult;
|
||||
import com.gxwebsoft.common.core.web.BaseController;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.entity.ShopSurchargeConfig;
|
||||
import com.gxwebsoft.shop.param.ShopSurchargeConfigParam;
|
||||
import com.gxwebsoft.shop.service.ShopSurchargeConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 步梯费用设置控制器
|
||||
*
|
||||
* @author xm
|
||||
* @since 2026-04-28 16:30:00
|
||||
*/
|
||||
@Tag(name = "步梯费用设置管理")
|
||||
@RestController
|
||||
@RequestMapping("/api/shop/shop-surcharge-config")
|
||||
public class ShopSurchargeConfigController extends BaseController {
|
||||
@Resource
|
||||
private ShopSurchargeConfigService shopSurchargeConfigService;
|
||||
|
||||
// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:list')")
|
||||
@Operation(summary = "分页查询步梯费用设置")
|
||||
@GetMapping("/page")
|
||||
public ApiResult<PageResult<ShopSurchargeConfig>> page(ShopSurchargeConfigParam param) {
|
||||
// 使用关联查询
|
||||
return success(shopSurchargeConfigService.pageRel(param));
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:list')")
|
||||
@Operation(summary = "根据id查询步梯费用设置")
|
||||
@GetMapping("/{id}")
|
||||
public ApiResult<ShopSurchargeConfig> get(@PathVariable("id") Integer id) {
|
||||
// 使用关联查询
|
||||
return success(shopSurchargeConfigService.getByIdRel(id));
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:list')")
|
||||
@Operation(summary = "根据类型查询步梯费用设置")
|
||||
@GetMapping("/getInfoByType")
|
||||
public ApiResult<ShopSurchargeConfig> getInfoByType(@RequestParam Integer type) {
|
||||
// 使用关联查询
|
||||
return success(shopSurchargeConfigService.getInfoByType(type));
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:save')")
|
||||
@OperationLog
|
||||
@Operation(summary = "添加步梯费用设置")
|
||||
@PostMapping()
|
||||
public ApiResult<Integer> save(@RequestBody ShopSurchargeConfig shopSurchargeConfig) {
|
||||
return success(shopSurchargeConfigService.saveInfo(shopSurchargeConfig));
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改步梯费用设置")
|
||||
@PutMapping()
|
||||
public ApiResult<Boolean> update(@RequestBody ShopSurchargeConfig shopSurchargeConfig) {
|
||||
return success(shopSurchargeConfigService.updateInfo(shopSurchargeConfig));
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:update')")
|
||||
@OperationLog
|
||||
@Operation(summary = "修改步梯费用设置")
|
||||
@PutMapping("/updateStatus")
|
||||
public ApiResult<Boolean> updateStatus(@RequestParam("id") Integer id) {
|
||||
return success(shopSurchargeConfigService.updateStatus(id));
|
||||
}
|
||||
|
||||
// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:remove')")
|
||||
@OperationLog
|
||||
@Operation(summary = "删除步梯费用设置")
|
||||
@DeleteMapping("/{id}")
|
||||
public ApiResult<?> remove(@PathVariable("id") Integer id) {
|
||||
if (shopSurchargeConfigService.removeById(id)) {
|
||||
return success("删除成功");
|
||||
}
|
||||
return fail("删除失败");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.gxwebsoft.shop.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import java.io.Serializable;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 步梯费用设置
|
||||
*
|
||||
* @author xm
|
||||
* @since 2026-04-28 16:30:00
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(name = "ShopSurchargeConfig对象", description = "步梯费用设置")
|
||||
@TableName("shop_surcharge_config")
|
||||
public class ShopSurchargeConfig implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键ID")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "价格(元)")
|
||||
private BigDecimal price;
|
||||
|
||||
@Schema(description = "类型 0-步梯费 1-其他")
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "状态 0-开启 1-关闭")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "排序")
|
||||
private Integer sortNumber;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
private Integer tenantId;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "修改人")
|
||||
private String updater;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@Schema(description = "是否删除 0-未删 1-已删")
|
||||
@TableLogic
|
||||
private Boolean deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.gxwebsoft.shop.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.gxwebsoft.shop.entity.ShopSurchargeConfig;
|
||||
import com.gxwebsoft.shop.param.ShopSurchargeConfigParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 步梯费用设置Mapper
|
||||
*
|
||||
* @author xm
|
||||
* @since 2026-04-28 16:30:00
|
||||
*/
|
||||
public interface ShopSurchargeConfigMapper extends BaseMapper<ShopSurchargeConfig> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页对象
|
||||
* @param param 查询参数
|
||||
* @return List<ShopSurchargeConfig>
|
||||
*/
|
||||
List<ShopSurchargeConfig> selectPageRel(@Param("page") IPage<ShopSurchargeConfig> page,
|
||||
@Param("param") ShopSurchargeConfigParam param);
|
||||
|
||||
/**
|
||||
* 查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<User>
|
||||
*/
|
||||
List<ShopSurchargeConfig> selectListRel(@Param("param") ShopSurchargeConfigParam param);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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.gxwebsoft.shop.mapper.ShopSurchargeConfigMapper">
|
||||
|
||||
<!-- 关联查询sql -->
|
||||
<sql id="selectSql">
|
||||
SELECT a.*
|
||||
FROM shop_surcharge_config a
|
||||
<where>
|
||||
<if test="param.id != null">
|
||||
AND a.id = #{param.id}
|
||||
</if>
|
||||
<if test="param.name != null">
|
||||
AND a.name LIKE CONCAT('%', #{param.name}, '%')
|
||||
</if>
|
||||
<if test="param.type != null">
|
||||
AND a.type = #{param.type}
|
||||
</if>
|
||||
<if test="param.status != null">
|
||||
AND a.status = #{param.status}
|
||||
</if>
|
||||
<if test="param.sortNumber != null">
|
||||
AND a.sort_number = #{param.sortNumber}
|
||||
</if>
|
||||
<if test="param.creator != null">
|
||||
AND a.creator LIKE CONCAT('%', #{param.creator}, '%')
|
||||
</if>
|
||||
<if test="param.createTimeStart != null">
|
||||
AND a.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test="param.createTimeEnd != null">
|
||||
AND a.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test="param.updater != null">
|
||||
AND a.updater LIKE CONCAT('%', #{param.updater}, '%')
|
||||
</if>
|
||||
<if test="param.deleted != null">
|
||||
AND a.deleted = #{param.deleted}
|
||||
</if>
|
||||
<if test="param.deleted == null">
|
||||
AND a.deleted = 0
|
||||
</if>
|
||||
<if test="param.keywords != null">
|
||||
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="selectPageRel" resultType="com.gxwebsoft.shop.entity.ShopSurchargeConfig">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
<!-- 查询全部 -->
|
||||
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.ShopSurchargeConfig">
|
||||
<include refid="selectSql"></include>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.gxwebsoft.shop.param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||
import com.gxwebsoft.common.core.web.BaseParam;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 步梯费用设置查询参数
|
||||
*
|
||||
* @author xm
|
||||
* @since 2026-04-28 16:30:00
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Schema(name = "ShopSurchargeConfigParam对象", description = "步梯费用设置查询参数")
|
||||
public class ShopSurchargeConfigParam extends BaseParam {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键ID")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer id;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "价格(元)")
|
||||
private BigDecimal price;
|
||||
|
||||
@Schema(description = "类型 0-步梯费 1-其他")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer type;
|
||||
|
||||
@Schema(description = "状态 0-开启 1-关闭")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "排序")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Integer sortNumber;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
private String creator;
|
||||
|
||||
@Schema(description = "修改人")
|
||||
private String updater;
|
||||
|
||||
@Schema(description = "是否删除 0-未删 1-已删")
|
||||
@QueryField(type = QueryType.EQ)
|
||||
private Boolean deleted;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.gxwebsoft.shop.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import com.gxwebsoft.shop.entity.ShopSurchargeConfig;
|
||||
import com.gxwebsoft.shop.param.ShopSurchargeConfigParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 步梯费用设置Service
|
||||
*
|
||||
* @author xm
|
||||
* @since 2026-04-28 16:30:00
|
||||
*/
|
||||
public interface ShopSurchargeConfigService extends IService<ShopSurchargeConfig> {
|
||||
|
||||
/**
|
||||
* 分页关联查询
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return PageResult<ShopSurchargeConfig>
|
||||
*/
|
||||
PageResult<ShopSurchargeConfig> pageRel(ShopSurchargeConfigParam param);
|
||||
|
||||
/**
|
||||
* 关联查询全部
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return List<ShopSurchargeConfig>
|
||||
*/
|
||||
List<ShopSurchargeConfig> listRel(ShopSurchargeConfigParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return ShopSurchargeConfig
|
||||
*/
|
||||
ShopSurchargeConfig getByIdRel(Integer id);
|
||||
|
||||
/**
|
||||
* 通过类型获取数据
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
ShopSurchargeConfig getInfoByType(Integer type);
|
||||
|
||||
/**
|
||||
* 保存信息
|
||||
* @param shopSurchargeConfig
|
||||
* @return
|
||||
*/
|
||||
Integer saveInfo(ShopSurchargeConfig shopSurchargeConfig);
|
||||
|
||||
/**
|
||||
* 修改信息
|
||||
* @param shopSurchargeConfig
|
||||
* @return
|
||||
*/
|
||||
Boolean updateInfo(ShopSurchargeConfig shopSurchargeConfig);
|
||||
|
||||
/**
|
||||
* 更新数据状态
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
Boolean updateStatus(Integer id);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.gxwebsoft.shop.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gxwebsoft.common.core.exception.enums.GlobalErrorCodeConstants;
|
||||
import com.gxwebsoft.common.core.utils.LoginUserUtil;
|
||||
import com.gxwebsoft.common.system.entity.User;
|
||||
import com.gxwebsoft.shop.mapper.ShopSurchargeConfigMapper;
|
||||
import com.gxwebsoft.shop.service.ShopSurchargeConfigService;
|
||||
import com.gxwebsoft.shop.entity.ShopSurchargeConfig;
|
||||
import com.gxwebsoft.shop.param.ShopSurchargeConfigParam;
|
||||
import com.gxwebsoft.common.core.web.PageParam;
|
||||
import com.gxwebsoft.common.core.web.PageResult;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 步梯费用设置Service实现
|
||||
*
|
||||
* @author xm
|
||||
* @since 2026-04-28 16:30:00
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class ShopSurchargeConfigServiceImpl extends ServiceImpl<ShopSurchargeConfigMapper, ShopSurchargeConfig> implements ShopSurchargeConfigService {
|
||||
|
||||
@Override
|
||||
public PageResult<ShopSurchargeConfig> pageRel(ShopSurchargeConfigParam param) {
|
||||
PageParam<ShopSurchargeConfig, ShopSurchargeConfigParam> page = new PageParam<>(param);
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
List<ShopSurchargeConfig> list = baseMapper.selectPageRel(page, param);
|
||||
return new PageResult<>(list, page.getTotal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ShopSurchargeConfig> listRel(ShopSurchargeConfigParam param) {
|
||||
List<ShopSurchargeConfig> list = baseMapper.selectListRel(param);
|
||||
// 排序
|
||||
PageParam<ShopSurchargeConfig, ShopSurchargeConfigParam> page = new PageParam<>();
|
||||
page.setDefaultOrder("sort_number asc, create_time desc");
|
||||
return page.sortRecords(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopSurchargeConfig getByIdRel(Integer id) {
|
||||
ShopSurchargeConfigParam param = new ShopSurchargeConfigParam();
|
||||
param.setId(id);
|
||||
return param.getOne(baseMapper.selectListRel(param));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ShopSurchargeConfig getInfoByType(Integer type) {
|
||||
List<ShopSurchargeConfig> list = lambdaQuery().eq(ShopSurchargeConfig::getType, type).list();
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
return list.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer saveInfo(ShopSurchargeConfig entity) {
|
||||
List<ShopSurchargeConfig> list = lambdaQuery().eq(ShopSurchargeConfig::getType, entity.getType()).list();
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
throw new RuntimeException("该类型收费数据已存在!");
|
||||
}
|
||||
User loginUser = LoginUserUtil.getLoginUser();
|
||||
entity.setCreator(String.valueOf(loginUser.getUserId()));
|
||||
entity.setCreateTime(LocalDateTime.now());
|
||||
|
||||
baseMapper.insert(entity);
|
||||
return entity.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateInfo(ShopSurchargeConfig entity) {
|
||||
List<ShopSurchargeConfig> list = lambdaQuery().eq(ShopSurchargeConfig::getType, entity.getType()).list();
|
||||
if(CollectionUtils.isNotEmpty(list)){
|
||||
throw new RuntimeException("该类型收费数据已存在!");
|
||||
}
|
||||
|
||||
User loginUser = LoginUserUtil.getLoginUser();
|
||||
entity.setUpdater(String.valueOf(loginUser.getUserId()));
|
||||
entity.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
return baseMapper.updateById(entity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateStatus(Integer id) {
|
||||
User loginUser = LoginUserUtil.getLoginUser();
|
||||
if(loginUser == null){
|
||||
throw new RuntimeException(GlobalErrorCodeConstants.UNAUTHORIZED.getMsg());
|
||||
}
|
||||
|
||||
ShopSurchargeConfig config = baseMapper.selectById(id);
|
||||
if(config == null){
|
||||
throw new RuntimeException(GlobalErrorCodeConstants.NOT_FOUND.getMsg());
|
||||
}
|
||||
|
||||
if(config.getStatus() == 0){
|
||||
config.setStatus(1);
|
||||
}else {
|
||||
config.setStatus(0);
|
||||
}
|
||||
config.setUpdater(String.valueOf(loginUser.getUserId()));
|
||||
config.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
return baseMapper.updateById(config) > 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user