From fb46af7bc32fcc7a0f4b59aa66a42bf4a5b7677e Mon Sep 17 00:00:00 2001 From: xm <1350250847@qq.com> Date: Wed, 29 Apr 2026 09:46:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=AD=A5=E6=A2=AF=E8=B4=B9?= =?UTF-8?q?=E7=94=A8=E8=AE=BE=E7=BD=AE=E4=B8=9A=E5=8A=A1=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ShopSurchargeConfigController.java | 88 ++++++++++++++ .../shop/entity/ShopSurchargeConfig.java | 66 ++++++++++ .../mapper/ShopSurchargeConfigMapper.java | 37 ++++++ .../mapper/xml/ShopSurchargeConfigMapper.xml | 60 +++++++++ .../shop/param/ShopSurchargeConfigParam.java | 57 +++++++++ .../service/ShopSurchargeConfigService.java | 70 +++++++++++ .../impl/ShopSurchargeConfigServiceImpl.java | 114 ++++++++++++++++++ 7 files changed, 492 insertions(+) create mode 100644 src/main/java/com/gxwebsoft/shop/controller/ShopSurchargeConfigController.java create mode 100644 src/main/java/com/gxwebsoft/shop/entity/ShopSurchargeConfig.java create mode 100644 src/main/java/com/gxwebsoft/shop/mapper/ShopSurchargeConfigMapper.java create mode 100644 src/main/java/com/gxwebsoft/shop/mapper/xml/ShopSurchargeConfigMapper.xml create mode 100644 src/main/java/com/gxwebsoft/shop/param/ShopSurchargeConfigParam.java create mode 100644 src/main/java/com/gxwebsoft/shop/service/ShopSurchargeConfigService.java create mode 100644 src/main/java/com/gxwebsoft/shop/service/impl/ShopSurchargeConfigServiceImpl.java diff --git a/src/main/java/com/gxwebsoft/shop/controller/ShopSurchargeConfigController.java b/src/main/java/com/gxwebsoft/shop/controller/ShopSurchargeConfigController.java new file mode 100644 index 0000000..b5cf848 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/controller/ShopSurchargeConfigController.java @@ -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> page(ShopSurchargeConfigParam param) { + // 使用关联查询 + return success(shopSurchargeConfigService.pageRel(param)); + } + +// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:list')") + @Operation(summary = "根据id查询步梯费用设置") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(shopSurchargeConfigService.getByIdRel(id)); + } + +// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:list')") + @Operation(summary = "根据类型查询步梯费用设置") + @GetMapping("/getInfoByType") + public ApiResult getInfoByType(@RequestParam Integer type) { + // 使用关联查询 + return success(shopSurchargeConfigService.getInfoByType(type)); + } + +// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:save')") + @OperationLog + @Operation(summary = "添加步梯费用设置") + @PostMapping() + public ApiResult save(@RequestBody ShopSurchargeConfig shopSurchargeConfig) { + return success(shopSurchargeConfigService.saveInfo(shopSurchargeConfig)); + } + +// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:update')") + @OperationLog + @Operation(summary = "修改步梯费用设置") + @PutMapping() + public ApiResult update(@RequestBody ShopSurchargeConfig shopSurchargeConfig) { + return success(shopSurchargeConfigService.updateInfo(shopSurchargeConfig)); + } + +// @PreAuthorize("hasAuthority('shop:shopSurchargeConfig:update')") + @OperationLog + @Operation(summary = "修改步梯费用设置") + @PutMapping("/updateStatus") + public ApiResult 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("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/ShopSurchargeConfig.java b/src/main/java/com/gxwebsoft/shop/entity/ShopSurchargeConfig.java new file mode 100644 index 0000000..79ff296 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/entity/ShopSurchargeConfig.java @@ -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; + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/ShopSurchargeConfigMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/ShopSurchargeConfigMapper.java new file mode 100644 index 0000000..7674ee8 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/ShopSurchargeConfigMapper.java @@ -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 { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") ShopSurchargeConfigParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") ShopSurchargeConfigParam param); + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopSurchargeConfigMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopSurchargeConfigMapper.xml new file mode 100644 index 0000000..6827f44 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopSurchargeConfigMapper.xml @@ -0,0 +1,60 @@ + + + + + + + SELECT a.* + FROM shop_surcharge_config a + + + AND a.id = #{param.id} + + + AND a.name LIKE CONCAT('%', #{param.name}, '%') + + + AND a.type = #{param.type} + + + AND a.status = #{param.status} + + + AND a.sort_number = #{param.sortNumber} + + + AND a.creator LIKE CONCAT('%', #{param.creator}, '%') + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND a.updater LIKE CONCAT('%', #{param.updater}, '%') + + + AND a.deleted = #{param.deleted} + + + AND a.deleted = 0 + + + AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/shop/param/ShopSurchargeConfigParam.java b/src/main/java/com/gxwebsoft/shop/param/ShopSurchargeConfigParam.java new file mode 100644 index 0000000..ac1ea6e --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/param/ShopSurchargeConfigParam.java @@ -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; + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/ShopSurchargeConfigService.java b/src/main/java/com/gxwebsoft/shop/service/ShopSurchargeConfigService.java new file mode 100644 index 0000000..f11178b --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/ShopSurchargeConfigService.java @@ -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 { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(ShopSurchargeConfigParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List 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); + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/ShopSurchargeConfigServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/ShopSurchargeConfigServiceImpl.java new file mode 100644 index 0000000..78c74d0 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/impl/ShopSurchargeConfigServiceImpl.java @@ -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 implements ShopSurchargeConfigService { + + @Override + public PageResult pageRel(ShopSurchargeConfigParam param) { + PageParam page = new PageParam<>(param); + page.setDefaultOrder("sort_number asc, create_time desc"); + List list = baseMapper.selectPageRel(page, param); + return new PageResult<>(list, page.getTotal()); + } + + @Override + public List listRel(ShopSurchargeConfigParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam 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 list = lambdaQuery().eq(ShopSurchargeConfig::getType, type).list(); + if(CollectionUtils.isNotEmpty(list)){ + return list.get(0); + } + return null; + } + + @Override + public Integer saveInfo(ShopSurchargeConfig entity) { + List 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 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; + } + +}