台桌管理接口
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.czg.account.dto.table.ShopTableAddDTO;
|
||||
import com.czg.account.dto.table.ShopTableDTO;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import com.czg.account.service.ShopTableService;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 台桌管理
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/shopTable")
|
||||
public class ShopTableController {
|
||||
@Resource
|
||||
private ShopTableService shopTableService;
|
||||
|
||||
|
||||
/**
|
||||
* 获取台桌列表
|
||||
* 权限标识: shopTable:list
|
||||
* @param areaId 区域id
|
||||
* @param tableCode 桌码
|
||||
* @return 台桌列表
|
||||
*/
|
||||
@SaAdminCheckPermission("shopTable:list")
|
||||
@GetMapping
|
||||
public CzgResult<Page<ShopTable>> list(Integer areaId, String tableCode) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper().eq(ShopTable::getShopId, StpKit.USER.getShopId());
|
||||
if (areaId != null) {
|
||||
queryWrapper.eq(ShopTable::getAreaId, areaId);
|
||||
}
|
||||
|
||||
if (StrUtil.isNotBlank(tableCode)) {
|
||||
queryWrapper.like(ShopTable::getTableCode, tableCode);
|
||||
}
|
||||
return CzgResult.success(shopTableService.page(PageUtil.buildPage(), queryWrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 台桌信息修改
|
||||
* 权限标识: shopTable:edit
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission("shopTable:edit")
|
||||
@PutMapping
|
||||
public CzgResult<Boolean> edit(@RequestBody @Validated ShopTableDTO shopTableDTO) {
|
||||
ShopTable shopTable = BeanUtil.copyProperties(shopTableDTO, ShopTable.class);
|
||||
return CzgResult.success(shopTableService.update(shopTable, new QueryWrapper().eq(ShopTable::getShopId, StpKit.USER.getShopId()).eq(ShopTable::getId, shopTableDTO.getId())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 台桌信息删除
|
||||
* 权限标识: shopTable:del
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission("shopTable:del")
|
||||
@DeleteMapping
|
||||
public CzgResult<Boolean> remove(@RequestBody @Validated ShopTableDTO shopTableDTO) {
|
||||
return CzgResult.success(shopTableService.remove(new QueryWrapper().eq(ShopTable::getShopId, StpKit.USER.getShopId()).eq(ShopTable::getId, shopTableDTO.getId())));
|
||||
}
|
||||
|
||||
/**
|
||||
* 台桌信息增加
|
||||
* 权限标识: shopTable:add
|
||||
* @return 是否成功
|
||||
*/
|
||||
@SaAdminCheckPermission("shopTable:add")
|
||||
@PostMapping
|
||||
public CzgResult<Boolean> add(@RequestBody @Validated ShopTableAddDTO shopTableAddDTO) {
|
||||
if (shopTableAddDTO.getStart() >= shopTableAddDTO.getEnd()){
|
||||
return CzgResult.failure("起始数不能大于结束数");
|
||||
}
|
||||
return CzgResult.success(shopTableService.add(StpKit.USER.getShopId(), shopTableAddDTO));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user