店铺区域接口

This commit is contained in:
张松
2025-02-19 10:31:11 +08:00
parent d8791107a6
commit 3520a4cc07
7 changed files with 78 additions and 36 deletions

View File

@@ -1,11 +1,19 @@
package com.czg.controller.admin; package com.czg.controller.admin;
import com.czg.account.entity.ShopTableArea;
import com.czg.account.service.ShopTableAreaService;
import com.czg.annotation.SaAdminCheckPermission; import com.czg.annotation.SaAdminCheckPermission;
import com.czg.resp.CzgResult; import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/** /**
* 区域管理 * 区域管理
* @author Administrator * @author Administrator
@@ -13,10 +21,28 @@ import org.springframework.web.bind.annotation.RestController;
@RestController @RestController
@RequestMapping("/shopArea") @RequestMapping("/shopArea")
public class ShopTableAreaController { public class ShopTableAreaController {
@Resource
private ShopTableAreaService shopTableAreaService;
// @SaAdminCheckPermission("shopArea:list") /**
// @GetMapping * 区域添加
// public CzgResult<?> list() { * @param name 区域名称
// * @return 是否成功
// } */
@SaAdminCheckPermission("shopArea:list")
@GetMapping
public CzgResult<Page<ShopTableArea>> list(String name) {
return CzgResult.success(shopTableAreaService.pageInfo(StpKit.USER.getShopId(), name));
}
/**
* 区域修改
* @param name 区域名称
* @return 是否成功
*/
@SaAdminCheckPermission("shopArea:edit")
@PutMapping
public CzgResult<Page<ShopTableArea>> edit(String name) {
return CzgResult.success(shopTableAreaService.pageInfo(StpKit.USER.getShopId(), name));
}
} }

View File

@@ -1,8 +1,10 @@
package com.czg.account.dto; package com.czg.account.dto.area;
import java.io.Serializable; import java.io.Serializable;
import java.io.Serial; import java.io.Serial;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@@ -18,14 +20,12 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class ShopAreaDTO implements Serializable { public class ShopAreaEditDTO implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
/** /**
* id * id
*/ */
@NotNull
private Integer id; private Integer id;
/** /**
@@ -43,8 +43,5 @@ public class ShopAreaDTO implements Serializable {
*/ */
private String name; private String name;
private Long createdAt;
private Long updatedAt;
} }

View File

@@ -1,11 +1,13 @@
package com.czg.account.entity; package com.czg.account.entity;
import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id; import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType; import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table; import com.mybatisflex.annotation.Table;
import java.io.Serializable; import java.io.Serializable;
import java.io.Serial; import java.io.Serial;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
@@ -49,8 +51,10 @@ public class ShopTableArea implements Serializable {
*/ */
private String name; private String name;
private Long createdAt; @Column(onInsertValue = "now()")
private LocalDateTime createdTime;
private Long updatedAt; @Column(onInsertValue = "now()", onUpdateValue = "now()")
private Long updatedTime;
} }

View File

@@ -1,5 +1,6 @@
package com.czg.account.service; package com.czg.account.service;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService; import com.mybatisflex.core.service.IService;
import com.czg.account.entity.ShopTableArea; import com.czg.account.entity.ShopTableArea;
@@ -9,6 +10,7 @@ import com.czg.account.entity.ShopTableArea;
* @author zs * @author zs
* @since 2025-02-18 * @since 2025-02-18
*/ */
public interface ShopAreaService extends IService<ShopTableArea> { public interface ShopTableAreaService extends IService<ShopTableArea> {
Page<ShopTableArea> pageInfo(Long shopId, String name);
} }

View File

@@ -1,18 +0,0 @@
package com.czg.service.account.service.impl;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.account.entity.ShopTableArea;
import com.czg.account.service.ShopAreaService;
import com.czg.service.account.mapper.ShopAreaMapper;
import org.springframework.stereotype.Service;
/**
* 店铺区域 服务层实现。
*
* @author zs
* @since 2025-02-18
*/
@Service
public class ShopAreaServiceImpl extends ServiceImpl<ShopAreaMapper, ShopTableArea> implements ShopAreaService{
}

View File

@@ -0,0 +1,31 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.util.StrUtil;
import com.czg.utils.PageUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.account.entity.ShopTableArea;
import com.czg.account.service.ShopTableAreaService;
import com.czg.service.account.mapper.ShopAreaMapper;
import org.springframework.stereotype.Service;
/**
* 店铺区域 服务层实现。
*
* @author zs
* @since 2025-02-18
*/
@Service
public class ShopTableAreaServiceImpl extends ServiceImpl<ShopAreaMapper, ShopTableArea> implements ShopTableAreaService {
@Override
public Page<ShopTableArea> pageInfo(Long shopId, String name) {
QueryWrapper queryWrapper = new QueryWrapper().eq(ShopTableArea::getShopId, shopId);
if (StrUtil.isNotBlank(name)) {
queryWrapper.like(ShopTableArea::getName, name);
}
return page(PageUtil.buildPage(), queryWrapper);
}
}

View File

@@ -9,7 +9,7 @@ import com.czg.account.dto.table.ShopTableAddDTO;
import com.czg.account.dto.table.ShopTableBindDTO; import com.czg.account.dto.table.ShopTableBindDTO;
import com.czg.account.entity.ShopTableArea; import com.czg.account.entity.ShopTableArea;
import com.czg.account.entity.ShopTableCode; import com.czg.account.entity.ShopTableCode;
import com.czg.account.service.ShopAreaService; import com.czg.account.service.ShopTableAreaService;
import com.czg.account.service.ShopTableCodeService; import com.czg.account.service.ShopTableCodeService;
import com.czg.enums.ShopTableStatusEnum; import com.czg.enums.ShopTableStatusEnum;
import com.czg.exception.ApiNotPrintException; import com.czg.exception.ApiNotPrintException;
@@ -42,7 +42,7 @@ import java.util.zip.ZipOutputStream;
@Service @Service
public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable> implements ShopTableService{ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable> implements ShopTableService{
@Resource @Resource
private ShopAreaService shopAreaService; private ShopTableAreaService shopAreaService;
@Resource @Resource
private ShopTableCodeService shopTableCodeService; private ShopTableCodeService shopTableCodeService;