diff --git a/src/main/java/com/gxwebsoft/shop/controller/ShopCommunityController.java b/src/main/java/com/gxwebsoft/shop/controller/ShopCommunityController.java new file mode 100644 index 0000000..cdd3dbe --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/controller/ShopCommunityController.java @@ -0,0 +1,120 @@ +package com.gxwebsoft.shop.controller; + +import com.gxwebsoft.common.core.web.BaseController; +import com.gxwebsoft.shop.service.ShopCommunityService; +import com.gxwebsoft.shop.entity.ShopCommunity; +import com.gxwebsoft.shop.param.ShopCommunityParam; +import com.gxwebsoft.common.core.web.ApiResult; +import com.gxwebsoft.common.core.web.PageResult; +import com.gxwebsoft.common.core.web.PageParam; +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.util.List; + +/** + * 小区控制器 + * + * @author 科技小王子 + * @since 2026-01-29 20:48:32 + */ +@Tag(name = "小区管理") +@RestController +@RequestMapping("/api/shop/shop-community") +public class ShopCommunityController extends BaseController { + @Resource + private ShopCommunityService shopCommunityService; + + @Operation(summary = "分页查询小区") + @GetMapping("/page") + public ApiResult> page(ShopCommunityParam param) { + // 使用关联查询 + return success(shopCommunityService.pageRel(param)); + } + + @Operation(summary = "查询全部小区") + @GetMapping() + public ApiResult> list(ShopCommunityParam param) { + // 使用关联查询 + return success(shopCommunityService.listRel(param)); + } + + @Operation(summary = "根据id查询小区") + @GetMapping("/{id}") + public ApiResult get(@PathVariable("id") Integer id) { + // 使用关联查询 + return success(shopCommunityService.getByIdRel(id)); + } + + @PreAuthorize("hasAuthority('shop:shopCommunity:save')") + @OperationLog + @Operation(summary = "添加小区") + @PostMapping() + public ApiResult save(@RequestBody ShopCommunity shopCommunity) { + if (shopCommunityService.save(shopCommunity)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @PreAuthorize("hasAuthority('shop:shopCommunity:update')") + @OperationLog + @Operation(summary = "修改小区") + @PutMapping() + public ApiResult update(@RequestBody ShopCommunity shopCommunity) { + if (shopCommunityService.updateById(shopCommunity)) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @PreAuthorize("hasAuthority('shop:shopCommunity:remove')") + @OperationLog + @Operation(summary = "删除小区") + @DeleteMapping("/{id}") + public ApiResult remove(@PathVariable("id") Integer id) { + if (shopCommunityService.removeById(id)) { + return success("删除成功"); + } + return fail("删除失败"); + } + + @PreAuthorize("hasAuthority('shop:shopCommunity:save')") + @OperationLog + @Operation(summary = "批量添加小区") + @PostMapping("/batch") + public ApiResult saveBatch(@RequestBody List list) { + if (shopCommunityService.saveBatch(list)) { + return success("添加成功"); + } + return fail("添加失败"); + } + + @PreAuthorize("hasAuthority('shop:shopCommunity:update')") + @OperationLog + @Operation(summary = "批量修改小区") + @PutMapping("/batch") + public ApiResult removeBatch(@RequestBody BatchParam batchParam) { + if (batchParam.update(shopCommunityService, "id")) { + return success("修改成功"); + } + return fail("修改失败"); + } + + @PreAuthorize("hasAuthority('shop:shopCommunity:remove')") + @OperationLog + @Operation(summary = "批量删除小区") + @DeleteMapping("/batch") + public ApiResult removeBatch(@RequestBody List ids) { + if (shopCommunityService.removeByIds(ids)) { + return success("删除成功"); + } + return fail("删除失败"); + } + +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/ShopCommunity.java b/src/main/java/com/gxwebsoft/shop/entity/ShopCommunity.java new file mode 100644 index 0000000..03994c1 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/entity/ShopCommunity.java @@ -0,0 +1,53 @@ +package com.gxwebsoft.shop.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import java.time.LocalDateTime; +import java.io.Serializable; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import com.fasterxml.jackson.annotation.JsonFormat; + +/** + * 小区 + * + * @author 科技小王子 + * @since 2026-01-29 20:48:32 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Schema(name = "ShopCommunity对象", description = "小区") +public class ShopCommunity 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 String code; + + @Schema(description = "详细地址") + private String address; + + @Schema(description = "排序(数字越小越靠前)") + private Integer sortNumber; + + @Schema(description = "备注") + private String comments; + + @Schema(description = "状态, 0正常, 1冻结") + private Integer status; + + @Schema(description = "租户id") + private Integer tenantId; + + @Schema(description = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; + +} diff --git a/src/main/java/com/gxwebsoft/shop/entity/ShopDealerUser.java b/src/main/java/com/gxwebsoft/shop/entity/ShopDealerUser.java index 2184e28..a3530cc 100644 --- a/src/main/java/com/gxwebsoft/shop/entity/ShopDealerUser.java +++ b/src/main/java/com/gxwebsoft/shop/entity/ShopDealerUser.java @@ -83,6 +83,16 @@ public class ShopDealerUser implements Serializable { @Schema(description = "成员数量(三级)") private Integer thirdNum; + @Schema(description = "小区ID") + private Integer communityId; + + @Schema(description = "店铺ID") + private Integer dealerUserId; + + @Schema(description = "店铺名称") + @TableField(exist = false) + private String shopName; + @Schema(description = "专属二维码") private String qrcode; diff --git a/src/main/java/com/gxwebsoft/shop/mapper/ShopCommunityMapper.java b/src/main/java/com/gxwebsoft/shop/mapper/ShopCommunityMapper.java new file mode 100644 index 0000000..c46985e --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/ShopCommunityMapper.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.ShopCommunity; +import com.gxwebsoft.shop.param.ShopCommunityParam; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 小区Mapper + * + * @author 科技小王子 + * @since 2026-01-29 20:48:32 + */ +public interface ShopCommunityMapper extends BaseMapper { + + /** + * 分页查询 + * + * @param page 分页对象 + * @param param 查询参数 + * @return List + */ + List selectPageRel(@Param("page") IPage page, + @Param("param") ShopCommunityParam param); + + /** + * 查询全部 + * + * @param param 查询参数 + * @return List + */ + List selectListRel(@Param("param") ShopCommunityParam param); + +} diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopCommunityMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopCommunityMapper.xml new file mode 100644 index 0000000..ad46b31 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopCommunityMapper.xml @@ -0,0 +1,54 @@ + + + + + + + SELECT a.* + FROM shop_community a + + + AND a.id = #{param.id} + + + AND a.name LIKE CONCAT('%', #{param.name}, '%') + + + AND a.code LIKE CONCAT('%', #{param.code}, '%') + + + AND a.address LIKE CONCAT('%', #{param.address}, '%') + + + AND a.sort_number = #{param.sortNumber} + + + AND a.comments LIKE CONCAT('%', #{param.comments}, '%') + + + AND a.status = #{param.status} + + + AND a.create_time >= #{param.createTimeStart} + + + AND a.create_time <= #{param.createTimeEnd} + + + AND (a.name LIKE CONCAT('%', #{param.keywords}, '%') + ) + + + + + + + + + + + diff --git a/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerUserMapper.xml b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerUserMapper.xml index de01801..f103c11 100644 --- a/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerUserMapper.xml +++ b/src/main/java/com/gxwebsoft/shop/mapper/xml/ShopDealerUserMapper.xml @@ -4,9 +4,10 @@ - SELECT a.*, b.openid, b.avatar + SELECT a.*, b.openid, b.avatar, c.dealer_name AS shopName FROM shop_dealer_user a LEFT JOIN gxwebsoft_core.sys_user b ON a.user_id = b.user_id + LEFT JOIN shop_dealer_user c ON a.dealer_user_id = c.id AND a.id = #{param.id} diff --git a/src/main/java/com/gxwebsoft/shop/param/ShopCommunityParam.java b/src/main/java/com/gxwebsoft/shop/param/ShopCommunityParam.java new file mode 100644 index 0000000..ecf76af --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/param/ShopCommunityParam.java @@ -0,0 +1,49 @@ +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 科技小王子 + * @since 2026-01-29 20:48:31 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@JsonInclude(JsonInclude.Include.NON_NULL) +@Schema(name = "ShopCommunityParam对象", description = "小区查询参数") +public class ShopCommunityParam 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 String code; + + @Schema(description = "详细地址") + private String address; + + @Schema(description = "排序(数字越小越靠前)") + @QueryField(type = QueryType.EQ) + private Integer sortNumber; + + @Schema(description = "备注") + private String comments; + + @Schema(description = "状态, 0正常, 1冻结") + @QueryField(type = QueryType.EQ) + private Integer status; + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/ShopCommunityService.java b/src/main/java/com/gxwebsoft/shop/service/ShopCommunityService.java new file mode 100644 index 0000000..695b037 --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/ShopCommunityService.java @@ -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.ShopCommunity; +import com.gxwebsoft.shop.param.ShopCommunityParam; + +import java.util.List; + +/** + * 小区Service + * + * @author 科技小王子 + * @since 2026-01-29 20:48:32 + */ +public interface ShopCommunityService extends IService { + + /** + * 分页关联查询 + * + * @param param 查询参数 + * @return PageResult + */ + PageResult pageRel(ShopCommunityParam param); + + /** + * 关联查询全部 + * + * @param param 查询参数 + * @return List + */ + List listRel(ShopCommunityParam param); + + /** + * 根据id查询 + * + * @param id ID + * @return ShopCommunity + */ + ShopCommunity getByIdRel(Integer id); + +} diff --git a/src/main/java/com/gxwebsoft/shop/service/impl/ShopCommunityServiceImpl.java b/src/main/java/com/gxwebsoft/shop/service/impl/ShopCommunityServiceImpl.java new file mode 100644 index 0000000..1dac6cd --- /dev/null +++ b/src/main/java/com/gxwebsoft/shop/service/impl/ShopCommunityServiceImpl.java @@ -0,0 +1,47 @@ +package com.gxwebsoft.shop.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.gxwebsoft.shop.mapper.ShopCommunityMapper; +import com.gxwebsoft.shop.service.ShopCommunityService; +import com.gxwebsoft.shop.entity.ShopCommunity; +import com.gxwebsoft.shop.param.ShopCommunityParam; +import com.gxwebsoft.common.core.web.PageParam; +import com.gxwebsoft.common.core.web.PageResult; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** + * 小区Service实现 + * + * @author 科技小王子 + * @since 2026-01-29 20:48:32 + */ +@Service +public class ShopCommunityServiceImpl extends ServiceImpl implements ShopCommunityService { + + @Override + public PageResult pageRel(ShopCommunityParam 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(ShopCommunityParam param) { + List list = baseMapper.selectListRel(param); + // 排序 + PageParam page = new PageParam<>(); + page.setDefaultOrder("sort_number asc, create_time desc"); + return page.sortRecords(list); + } + + @Override + public ShopCommunity getByIdRel(Integer id) { + ShopCommunityParam param = new ShopCommunityParam(); + param.setId(id); + return param.getOne(baseMapper.selectListRel(param)); + } + +}