存酒接口

This commit is contained in:
张松
2025-02-27 13:58:04 +08:00
parent 250ce131d2
commit 2bce1acb69
27 changed files with 807 additions and 63 deletions

View File

@@ -29,8 +29,8 @@ public class UShopUserController {
* @return 店铺会员信息
*/
@GetMapping
public CzgResult<ShopUser> get() {
return CzgResult.success(shopUserService.getShopUserInfo(StpKit.USER.getShopId(), StpKit.USER.getLoginIdAsLong()));
public CzgResult<ShopUser> get(Long shopId) {
return CzgResult.success(shopUserService.getShopUserInfo(shopId == null ? StpKit.USER.getShopId() : shopId, StpKit.USER.getLoginIdAsLong()));
}
/**
@@ -49,8 +49,8 @@ public class UShopUserController {
* @return 店铺会员信息列表
*/
@GetMapping("/code")
public CzgResult<String> code() {
return shopUserService.getCode(StpKit.USER.getLoginIdAsLong(), StpKit.USER.getShopId());
public CzgResult<String> code(Long shopId) {
return shopUserService.getCode(StpKit.USER.getLoginIdAsLong(), shopId == null ? StpKit.USER.getShopId() : shopId);
}
}

View File

@@ -38,7 +38,7 @@ public class UserAuthorizationController {
*/
@PostMapping("/test")
public CzgResult<String> login() {
// StpKit.USER.login(1L, null, MyStpLogic.LoginType.USER, false);
StpKit.USER.login(1L, "2342", null, MyStpLogic.LoginType.USER, false);
return CzgResult.success(StpKit.USER.getTokenValue());
}
}

View File

@@ -0,0 +1,85 @@
package com.czg.controller.admin;
import com.czg.product.dto.storage.CountStorageDTO;
import com.czg.product.dto.storage.ShopStorageAddDTO;
import com.czg.product.dto.storage.ShopStorageEditDTO;
import com.czg.product.entity.ShopStorage;
import com.czg.product.entity.ShopStorageRecord;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.product.service.ShopStorageService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.mybatisflex.core.paginate.Page;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 存酒记录管理
* @author Administrator
*/
@RestController
@RequestMapping("/admin/shopStorage")
public class ShopStorageController {
@Resource
private ShopStorageService shopStorageService;
/**
* 存酒记录
* @param key 酒名/用户昵称
* @param phone 手机号
* @param status 0已取完1未取完2已过期
* @return 分页数据
*/
@SaAdminCheckPermission(value = "shopStorage:list", name = "获取存酒记录列表")
@GetMapping
public CzgResult<Page<ShopStorage>> list(String key, String phone, Integer status) {
return CzgResult.success(shopStorageService.pageInfo(StpKit.USER.getShopId(), key, phone, status));
}
/**
* 存酒记录添加
* @return 分页数据
*/
@SaAdminCheckPermission(value = "shopStorage:add", name = "添加存酒")
@PostMapping
public CzgResult<Boolean> add(@RequestBody @Validated ShopStorageAddDTO shopStorageAddDTO) {
return CzgResult.success(shopStorageService.add(StpKit.USER.getShopId(), shopStorageAddDTO));
}
/**
* 存酒取酒
* @return 分页数据
*/
@SaAdminCheckPermission(value = "shopStorage:edit", name = "修改存酒数量")
@PutMapping
public CzgResult<Boolean> edit(@RequestBody @Validated ShopStorageEditDTO shopStorageEditDTO) {
if (shopStorageEditDTO.getNum() == 0) {
return CzgResult.failure("数量不为0");
}
return CzgResult.success(shopStorageService.edit(StpKit.USER.getShopId(), shopStorageEditDTO));
}
/**
* 查询存取酒记录
* @param id 存酒id
* @return 分页数据
*/
@SaAdminCheckPermission(value = "shopStorage:record", name = "查询存取酒记录")
@GetMapping("/record")
public CzgResult<List<ShopStorageRecord>> recordList(@RequestParam Integer id) {
return CzgResult.success(shopStorageService.getRecord(StpKit.USER.getShopId(), id));
}
/**
* 存酒统计
* @return 统计信息
*/
@SaAdminCheckPermission(value = "shopStorage:count", name = "存酒统计")
@GetMapping("/count")
public CzgResult<List<CountStorageDTO>> countRecord() {
return CzgResult.success(shopStorageService.countRecord(StpKit.USER.getShopId()));
}
}

View File

@@ -1,14 +1,14 @@
package com.czg.controller.admin;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.storage.ShopStorageGoodDTO;
import com.czg.account.entity.ShopStorageGood;
import com.czg.account.service.ShopStorageGoodService;
import com.czg.product.dto.storage.ShopStorageGoodDTO;
import com.czg.product.entity.ShopStorage;
import com.czg.product.entity.ShopStorageGood;
import com.czg.product.service.ShopStorageGoodService;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.utils.PageUtil;
import com.czg.validator.group.DefaultGroup;
import com.czg.validator.group.InsertGroup;
import com.czg.validator.group.UpdateGroup;
import com.mybatisflex.core.paginate.Page;
@@ -39,6 +39,7 @@ public class ShopStorageGoodController {
if (StrUtil.isNotBlank(name)) {
queryWrapper.eq(ShopStorageGood::getName, name);
}
queryWrapper.orderBy(ShopStorageGood::getId, false);
return CzgResult.success(shopStorageGoodService.page(PageUtil.buildPage(), queryWrapper));
}
@@ -64,15 +65,23 @@ public class ShopStorageGoodController {
}
/**
* 编辑存酒商品
* 添加存酒商品
* @return 列表
*/
@SaAdminCheckPermission(value = "storageGood:add", name = "存酒商品新增")
@PutMapping("/add")
@PostMapping
public CzgResult<Boolean> add(@RequestBody @Validated({InsertGroup.class}) ShopStorageGoodDTO shopStorageGoodDTO) {
return CzgResult.success(shopStorageGoodService.saveInfo(StpKit.USER.getShopId(), shopStorageGoodDTO));
}
/**
* 删除存酒商品
* @return 列表
*/
@SaAdminCheckPermission(value = "storageGood:del", name = "存酒商品删除")
@DeleteMapping
public CzgResult<Boolean> del(@RequestBody @Validated({UpdateGroup.class}) ShopStorageGoodDTO shopStorageGoodDTO) {
return CzgResult.success(shopStorageGoodService.remove(new QueryWrapper().eq(ShopStorageGood::getShopId, StpKit.USER.getShopId()).eq(ShopStorageGood::getId, shopStorageGoodDTO.getId())));
}
}