增加活动底图功能

This commit is contained in:
1350250847@qq.com
2026-04-28 09:43:58 +08:00
parent 70b299eda6
commit 359c080023
9 changed files with 469 additions and 2 deletions

View File

@@ -0,0 +1,127 @@
package com.gxwebsoft.shop.controller;
import com.gxwebsoft.common.core.web.BaseController;
import com.gxwebsoft.shop.service.ShopActiveImageService;
import com.gxwebsoft.shop.entity.ShopActiveImage;
import com.gxwebsoft.shop.param.ShopActiveImageParam;
import com.gxwebsoft.common.core.web.ApiResult;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.common.core.web.BatchParam;
import com.gxwebsoft.common.core.annotation.OperationLog;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;
/**
* 推广码底图控制器
*
* @author xm
* @since 2026-04-27 18:02:18
*/
@Tag(name = "推广码底图管理")
@RestController
@RequestMapping("/api/shop/shop-active-image")
public class ShopActiveImageController extends BaseController {
@Resource
private ShopActiveImageService shopActiveImageService;
// @PreAuthorize("hasAuthority('shop:shopActiveImage:list')")
@Operation(summary = "分页查询推广码底图")
@GetMapping("/page")
public ApiResult<PageResult<ShopActiveImage>> page(ShopActiveImageParam param) {
// 使用关联查询
return success(shopActiveImageService.pageRel(param));
}
// @PreAuthorize("hasAuthority('shop:shopActiveImage:list')")
@Operation(summary = "查询全部推广码底图")
@GetMapping()
public ApiResult<List<ShopActiveImage>> list(ShopActiveImageParam param) {
// 使用关联查询
return success(shopActiveImageService.listRel(param));
}
// @PreAuthorize("hasAuthority('shop:shopActiveImage:list')")
@Operation(summary = "根据id查询推广码底图")
@GetMapping("/{id}")
public ApiResult<ShopActiveImage> get(@PathVariable("id") Integer id) {
// 使用关联查询
return success(shopActiveImageService.getByIdRel(id));
}
// @PreAuthorize("hasAuthority('shop:shopActiveImage:save')")
@OperationLog
@Operation(summary = "添加推广码底图")
@PostMapping()
public ApiResult<?> save(@RequestBody ShopActiveImage shopActiveImage) {
shopActiveImage.setCreator(String.valueOf(getLoginUserId()));
shopActiveImage.setCreateTime(LocalDateTime.now());
if (shopActiveImageService.save(shopActiveImage)) {
return success("添加成功");
}
return fail("添加失败");
}
// @PreAuthorize("hasAuthority('shop:shopActiveImage:update')")
@OperationLog
@Operation(summary = "修改推广码底图")
@PutMapping()
public ApiResult<?> update(@RequestBody ShopActiveImage shopActiveImage) {
shopActiveImage.setUpdater(String.valueOf(getLoginUserId()));
shopActiveImage.setUpdateTime(LocalDateTime.now());
if (shopActiveImageService.updateById(shopActiveImage)) {
return success("修改成功");
}
return fail("修改失败");
}
// @PreAuthorize("hasAuthority('shop:shopActiveImage:remove')")
@OperationLog
@Operation(summary = "删除推广码底图")
@DeleteMapping("/{id}")
public ApiResult<?> remove(@PathVariable("id") Integer id) {
if (shopActiveImageService.removeById(id)) {
return success("删除成功");
}
return fail("删除失败");
}
@PreAuthorize("hasAuthority('shop:shopActiveImage:save')")
@OperationLog
@Operation(summary = "批量添加推广码底图")
@PostMapping("/batch")
public ApiResult<?> saveBatch(@RequestBody List<ShopActiveImage> list) {
if (shopActiveImageService.saveBatch(list)) {
return success("添加成功");
}
return fail("添加失败");
}
@PreAuthorize("hasAuthority('shop:shopActiveImage:update')")
@OperationLog
@Operation(summary = "批量修改推广码底图")
@PutMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody BatchParam<ShopActiveImage> batchParam) {
if (batchParam.update(shopActiveImageService, "id")) {
return success("修改成功");
}
return fail("修改失败");
}
// @PreAuthorize("hasAuthority('shop:shopActiveImage:remove')")
@OperationLog
@Operation(summary = "批量删除推广码底图")
@DeleteMapping("/batch")
public ApiResult<?> removeBatch(@RequestBody List<Integer> ids) {
if (shopActiveImageService.removeByIds(ids)) {
return success("删除成功");
}
return fail("删除失败");
}
}

View File

@@ -0,0 +1,71 @@
package com.gxwebsoft.shop.entity;
import com.baomidou.mybatisplus.annotation.*;
import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.List;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotNull;
/**
* 推广码底图
*
* @author xm
* @since 2026-04-27 18:02:17
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Schema(name = "ShopActiveImage对象", description = "推广码底图")
@TableName("shop_active_image")
public class ShopActiveImage 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 = "类型 0-推广底图 1-其他")
private Integer type;
@Schema(description = "图片地址,多个以‘,’隔开")
private String imgUrl;
@Schema(description = "图片地址集合")
@TableField(exist = false)
private List<String> imgUrlList;
@Schema(description = "启用状态 0-启用 1-禁用")
private Integer status;
@Schema(description = "排序")
private Integer sortNumber;
@Schema(description = "租户ID")
@NotNull(message = "租户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 Integer deleted;
}

View File

@@ -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.ShopActiveImage;
import com.gxwebsoft.shop.param.ShopActiveImageParam;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 推广码底图Mapper
*
* @author xm
* @since 2026-04-27 18:02:17
*/
public interface ShopActiveImageMapper extends BaseMapper<ShopActiveImage> {
/**
* 分页查询
*
* @param page 分页对象
* @param param 查询参数
* @return List<ShopActiveImage>
*/
List<ShopActiveImage> selectPageRel(@Param("page") IPage<ShopActiveImage> page,
@Param("param") ShopActiveImageParam param);
/**
* 查询全部
*
* @param param 查询参数
* @return List<User>
*/
List<ShopActiveImage> selectListRel(@Param("param") ShopActiveImageParam param);
}

View File

@@ -0,0 +1,63 @@
<?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.ShopActiveImageMapper">
<!-- 关联查询sql -->
<sql id="selectSql">
SELECT a.*
FROM shop_active_image 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.imgUrl != null">
AND a.img_url LIKE CONCAT('%', #{param.imgUrl}, '%')
</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 &gt;= #{param.createTimeStart}
</if>
<if test="param.createTimeEnd != null">
AND a.create_time &lt;= #{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.ShopActiveImage">
<include refid="selectSql"></include>
</select>
<!-- 查询全部 -->
<select id="selectListRel" resultType="com.gxwebsoft.shop.entity.ShopActiveImage">
<include refid="selectSql"></include>
</select>
</mapper>

View File

@@ -0,0 +1,56 @@
package com.gxwebsoft.shop.param;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.gxwebsoft.common.core.annotation.QueryField;
import com.gxwebsoft.common.core.annotation.QueryType;
import com.gxwebsoft.common.core.web.BaseParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 推广码底图查询参数
*
* @author xm
* @since 2026-04-27 18:02:17
*/
@Data
@EqualsAndHashCode(callSuper = false)
@JsonInclude(JsonInclude.Include.NON_NULL)
@Schema(name = "ShopActiveImageParam对象", description = "推广码底图查询参数")
public class ShopActiveImageParam 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 = "类型 0-推广底图 1-其他")
@QueryField(type = QueryType.EQ)
private Integer type;
@Schema(description = "图片地址")
private String imgUrl;
@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 Integer deleted;
}

View File

@@ -0,0 +1,42 @@
package com.gxwebsoft.shop.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.ShopActiveImage;
import com.gxwebsoft.shop.param.ShopActiveImageParam;
import java.util.List;
/**
* 推广码底图Service
*
* @author xm
* @since 2026-04-27 18:02:17
*/
public interface ShopActiveImageService extends IService<ShopActiveImage> {
/**
* 分页关联查询
*
* @param param 查询参数
* @return PageResult<ShopActiveImage>
*/
PageResult<ShopActiveImage> pageRel(ShopActiveImageParam param);
/**
* 关联查询全部
*
* @param param 查询参数
* @return List<ShopActiveImage>
*/
List<ShopActiveImage> listRel(ShopActiveImageParam param);
/**
* 根据id查询
*
* @param id 主键ID
* @return ShopActiveImage
*/
ShopActiveImage getByIdRel(Integer id);
}

View File

@@ -0,0 +1,70 @@
package com.gxwebsoft.shop.service.impl;
import com.aliyuncs.utils.StringUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxwebsoft.common.core.web.PageParam;
import com.gxwebsoft.common.core.web.PageResult;
import com.gxwebsoft.shop.entity.ShopActiveImage;
import com.gxwebsoft.shop.mapper.ShopActiveImageMapper;
import com.gxwebsoft.shop.param.ShopActiveImageParam;
import com.gxwebsoft.shop.service.ShopActiveImageService;
import lombok.AllArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
/**
* 推广码底图Service实现
*
* @author xm
* @since 2026-04-27 17:53:00
*/
@Service
@AllArgsConstructor
public class ShopActiveImageServiceImpl extends ServiceImpl<ShopActiveImageMapper, ShopActiveImage> implements ShopActiveImageService {
@Override
public PageResult<ShopActiveImage> pageRel(ShopActiveImageParam param) {
PageParam<ShopActiveImage, ShopActiveImageParam> page = new PageParam<>(param);
page.setDefaultOrder("sort_number asc, create_time desc");
List<ShopActiveImage> list = baseMapper.selectPageRel(page, param);
if(CollectionUtils.isNotEmpty(list)){
list.forEach(shopActiveImage -> {
if(!StringUtils.isEmpty(shopActiveImage.getImgUrl())){
shopActiveImage.setImgUrlList(Arrays.asList(shopActiveImage.getImgUrl().split(",")));
}
});
}
return new PageResult<>(list, page.getTotal());
}
@Override
public List<ShopActiveImage> listRel(ShopActiveImageParam param) {
List<ShopActiveImage> list = baseMapper.selectListRel(param);
if(CollectionUtils.isNotEmpty(list)){
list.forEach(shopActiveImage -> {
if(!StringUtils.isEmpty(shopActiveImage.getImgUrl())){
shopActiveImage.setImgUrlList(Arrays.asList(shopActiveImage.getImgUrl().split(",")));
}
});
}
// 排序
PageParam<ShopActiveImage, ShopActiveImageParam> page = new PageParam<>();
page.setDefaultOrder("sort_number asc, create_time desc");
return page.sortRecords(list);
}
@Override
public ShopActiveImage getByIdRel(Integer id) {
ShopActiveImageParam param = new ShopActiveImageParam();
param.setId(id);
ShopActiveImage activeImage = param.getOne(baseMapper.selectListRel(param));
if(activeImage != null && !StringUtils.isEmpty(activeImage.getImgUrl())){
activeImage.setImgUrlList(Arrays.asList(activeImage.getImgUrl().split(",")));
}
return activeImage;
}
}

View File

@@ -45,7 +45,7 @@ public class ShopGenerator {
private static final String DB_URL = "jdbc:mysql://47.107.249.41:13306/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8"; private static final String DB_URL = "jdbc:mysql://47.107.249.41:13306/modules?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8";
private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver"; private static final String DB_DRIVER = "com.mysql.cj.jdbc.Driver";
private static final String DB_USERNAME = "modules"; private static final String DB_USERNAME = "modules";
private static final String DB_PASSWORD = "tYmmMGh5wpwXR3ae2"; private static final String DB_PASSWORD = "tYmmMGh5wpwXR3ae";
// 包名 // 包名
private static final String PACKAGE_NAME = "com.gxwebsoft"; private static final String PACKAGE_NAME = "com.gxwebsoft";
// 模块名 // 模块名
@@ -106,7 +106,7 @@ public class ShopGenerator {
// "shop_express_template_detail", // "shop_express_template_detail",
// "shop_gift" // "shop_gift"
// "shop_flash_sale_activity" // "shop_flash_sale_activity"
// "shop_flash_sale_product" // "shop_active_image"
}; };
// 需要去除的表前缀 // 需要去除的表前缀
private static final String[] TABLE_PREFIX = new String[]{ private static final String[] TABLE_PREFIX = new String[]{

View File

@@ -16,6 +16,7 @@ import ${package.Entity}.${entity};
import ${cfg.packageName!}.${package.ModuleName}.param.${entity}Param; import ${cfg.packageName!}.${package.ModuleName}.param.${entity}Param;
import ${cfg.packageName!}.common.core.web.PageParam; import ${cfg.packageName!}.common.core.web.PageParam;
import ${cfg.packageName!}.common.core.web.PageResult; import ${cfg.packageName!}.common.core.web.PageResult;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;