商品模块代码提交
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
package com.czg.controller;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.hutool.core.lang.Validator;
|
||||
import com.czg.annotation.SaAdminCheckPermission;
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.product.dto.ShopProdCategoryDTO;
|
||||
import com.czg.product.service.ShopProdCategoryService;
|
||||
@@ -17,7 +14,6 @@ import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -33,67 +29,82 @@ public class ShopProdCategoryController {
|
||||
private final ShopProdCategoryService shopProdCategoryService;
|
||||
|
||||
@GetMapping("page")
|
||||
@OperationLog("分页")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
public CzgResult<Page<ShopProdCategoryDTO>> page(@RequestParam Map<String, Object> params) {
|
||||
Page<ShopProdCategoryDTO> data = shopProdCategoryService.pageAs(null, null, ShopProdCategoryDTO.class);
|
||||
@OperationLog("商品分类-分页")
|
||||
//@SaAdminCheckPermission("prod:category:page")
|
||||
public CzgResult<Page<ShopProdCategoryDTO>> page(ShopProdCategoryDTO param) {
|
||||
Page<ShopProdCategoryDTO> data = shopProdCategoryService.page(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@OperationLog("列表")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
public CzgResult<List<ShopProdCategoryDTO>> list(@RequestParam Map<String, Object> params) {
|
||||
List<ShopProdCategoryDTO> data = null;
|
||||
|
||||
@OperationLog("商品分类-列表")
|
||||
//@SaAdminCheckPermission("prod:category:list")
|
||||
public CzgResult<List<ShopProdCategoryDTO>> list(ShopProdCategoryDTO param) {
|
||||
List<ShopProdCategoryDTO> data = shopProdCategoryService.list(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@OperationLog("信息")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
@OperationLog("商品分类-详情")
|
||||
//@SaAdminCheckPermission("prod:category:info")
|
||||
public CzgResult<ShopProdCategoryDTO> get(@PathVariable("id") Long id) {
|
||||
ShopProdCategoryDTO data = null;
|
||||
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
ShopProdCategoryDTO data = shopProdCategoryService.get(id);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@OperationLog("保存")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
@OperationLog("商品分类-新增")
|
||||
//@SaAdminCheckPermission("prod:category:save")
|
||||
public CzgResult<Void> save(@RequestBody ShopProdCategoryDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtil.validateEntity(dto, InsertGroup.class, DefaultGroup.class);
|
||||
|
||||
//shopProdCategoryService.save(dto);
|
||||
shopProdCategoryService.save(dto);
|
||||
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@OperationLog("修改")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
@OperationLog("商品分类-修改")
|
||||
//@SaAdminCheckPermission("prod:category:update")
|
||||
public CzgResult<Void> update(@RequestBody ShopProdCategoryDTO dto) {
|
||||
//效验数据
|
||||
ValidatorUtil.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
//shopProdCategoryService.update(dto);
|
||||
shopProdCategoryService.update(dto);
|
||||
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@DeleteMapping
|
||||
@OperationLog("删除")
|
||||
@SaAdminCheckPermission("prod:category:all")
|
||||
public CzgResult<Void> delete(@RequestBody Long[] ids) {
|
||||
@DeleteMapping("{id}")
|
||||
@OperationLog("商品分类-删除")
|
||||
//@SaAdminCheckPermission("prod:unit:delete")
|
||||
public CzgResult<Void> delete(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
Assert.notNull(ids, "{}不能为空", "id");
|
||||
AssertUtil.isArrayEmpty(ids, "请求id数组不能为空");
|
||||
AssertUtil.isArrayEmpty(ids, "请求{}{}数组不能为空", "id", "的");
|
||||
Validator.validateBirthday("2022-12-12", "生日格式不正确");
|
||||
|
||||
//shopProdCategoryService.delete(ids);
|
||||
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
shopProdCategoryService.delete(id);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("disable/{id}")
|
||||
@OperationLog("商品分类-禁用")
|
||||
//@SaAdminCheckPermission("prod:unit:able")
|
||||
public CzgResult<Void> disable(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
shopProdCategoryService.disable(id);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("enable/{id}")
|
||||
@OperationLog("商品分类-启用")
|
||||
//@SaAdminCheckPermission("prod:unit:able")
|
||||
public CzgResult<Void> enable(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
shopProdCategoryService.enable(id);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,7 +46,7 @@ public class ShopProdUnitController {
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@OperationLog("商品单位-信息")
|
||||
@OperationLog("商品单位-详情")
|
||||
//@SaAdminCheckPermission("prod:unit:info")
|
||||
public CzgResult<ShopProdUnitDTO> get(@PathVariable("id") Long id) {
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
@@ -55,7 +55,7 @@ public class ShopProdUnitController {
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@OperationLog("商品单位-保存")
|
||||
@OperationLog("商品单位-新增")
|
||||
//@SaAdminCheckPermission("prod:unit:save")
|
||||
public CzgResult<Void> save(@RequestBody ShopProdUnitDTO dto) {
|
||||
//效验数据
|
||||
@@ -79,7 +79,7 @@ public class ShopProdUnitController {
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
@OperationLog("商品单位-启用")
|
||||
@OperationLog("商品单位-删除")
|
||||
//@SaAdminCheckPermission("prod:unit:delete")
|
||||
public CzgResult<Void> delete(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
package com.czg.controller;
|
||||
|
||||
import com.czg.log.annotation.OperationLog;
|
||||
import com.czg.product.dto.ShopProductSpecDTO;
|
||||
import com.czg.product.service.ShopProductSpecService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.utils.AssertUtil;
|
||||
import com.czg.validator.ValidatorUtil;
|
||||
import com.czg.validator.group.DefaultGroup;
|
||||
import com.czg.validator.group.InsertGroup;
|
||||
import com.czg.validator.group.UpdateGroup;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 商品规格
|
||||
*
|
||||
* @author Tankaikai tankaikai@aliyun.com
|
||||
* @since 1.0 2025-02-13
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/admin/prod/spec")
|
||||
public class ShopProductSpecController {
|
||||
private final ShopProductSpecService shopProductSpecService;
|
||||
|
||||
@GetMapping("list")
|
||||
@OperationLog("商品规格-列表")
|
||||
//@SaAdminCheckPermission("product:spec:list")
|
||||
public CzgResult<List<ShopProductSpecDTO>> list(ShopProductSpecDTO param){
|
||||
List<ShopProductSpecDTO> data = shopProductSpecService.list(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@OperationLog("商品规格-详情")
|
||||
//@SaAdminCheckPermission("product:spec:info")
|
||||
public CzgResult<ShopProductSpecDTO> get(@PathVariable("id") Long id){
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
ShopProductSpecDTO data = shopProductSpecService.get(id);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@OperationLog("商品规格-新增")
|
||||
//@SaAdminCheckPermission("product:spec:save")
|
||||
public CzgResult<Void> save(@RequestBody ShopProductSpecDTO dto){
|
||||
//效验数据
|
||||
ValidatorUtil.validateEntity(dto, InsertGroup.class, DefaultGroup.class);
|
||||
|
||||
shopProductSpecService.save(dto);
|
||||
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@OperationLog("商品规格-修改")
|
||||
//@SaAdminCheckPermission("product:spec:update")
|
||||
public CzgResult<Void> update(@RequestBody ShopProductSpecDTO dto){
|
||||
//效验数据
|
||||
ValidatorUtil.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
shopProductSpecService.update(dto);
|
||||
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
@OperationLog("商品规格-删除")
|
||||
//@SaAdminCheckPermission("product:spec:delete")
|
||||
public CzgResult<Void> delete(@PathVariable("id") Long id){
|
||||
//效验数据
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
shopProductSpecService.delete(id);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("disable/{id}")
|
||||
@OperationLog("商品规格-禁用")
|
||||
//@SaAdminCheckPermission("product:spec:able")
|
||||
public CzgResult<Void> disable(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
shopProductSpecService.disable(id);
|
||||
return CzgResult.success();
|
||||
}
|
||||
|
||||
@PostMapping("enable/{id}")
|
||||
@OperationLog("商品规格-启用")
|
||||
//@SaAdminCheckPermission("product:spec:able")
|
||||
public CzgResult<Void> enable(@PathVariable("id") Long id) {
|
||||
//效验数据
|
||||
AssertUtil.isNull(id, "{}不能为空", "id");
|
||||
shopProductSpecService.enable(id);
|
||||
return CzgResult.success();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user