商品模块代码提交
This commit is contained in:
parent
15db6821df
commit
2d841d3fc6
|
|
@ -28,7 +28,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/prod/product")
|
@RequestMapping("/admin/prod/product")
|
||||||
public class ProductController {
|
public class ProductController {
|
||||||
private final ProductService productService;
|
private final ProductService productService;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/prod/category")
|
@RequestMapping("/admin/prod/category")
|
||||||
public class ShopProdCategoryController {
|
public class ShopProdCategoryController {
|
||||||
private final ShopProdCategoryService shopProdCategoryService;
|
private final ShopProdCategoryService shopProdCategoryService;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,14 +25,14 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/prod/unit")
|
@RequestMapping("/admin/prod/unit")
|
||||||
public class ShopProdUnitController {
|
public class ShopProdUnitController {
|
||||||
private final ShopProdUnitService shopProdUnitService;
|
private final ShopProdUnitService shopProdUnitService;
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@LogOperation("分页")
|
@LogOperation("分页")
|
||||||
@SaAdminCheckPermission("prod:unit:all")
|
//@SaAdminCheckPermission("prod:unit:all")
|
||||||
public CzgResult<Page<ShopProdUnitDTO>> page(@RequestParam ShopProdUnitDTO param) {
|
public CzgResult<Page<ShopProdUnitDTO>> page(ShopProdUnitDTO param) {
|
||||||
Page<ShopProdUnitDTO> data = shopProdUnitService.page(param);
|
Page<ShopProdUnitDTO> data = shopProdUnitService.page(param);
|
||||||
return CzgResult.success(data);
|
return CzgResult.success(data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.czg.core.page;
|
package com.czg.core.page;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
|
import com.czg.utils.ServletUtil;
|
||||||
import com.mybatisflex.core.paginate.Page;
|
import com.mybatisflex.core.paginate.Page;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
|
@ -22,42 +23,42 @@ public class PageQuery implements Serializable {
|
||||||
/**
|
/**
|
||||||
* 当前记录起始索引
|
* 当前记录起始索引
|
||||||
*/
|
*/
|
||||||
public static final String PAGE_NUM = "pageNum";
|
public static final String PAGE = "page";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 每页显示记录数
|
* 每页显示记录数
|
||||||
*/
|
*/
|
||||||
public static final String PAGE_SIZE = "pageSize";
|
public static final String SIZE = "size";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页大小
|
* 分页大小
|
||||||
*/
|
*/
|
||||||
private Integer pageSize;
|
private Integer size;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前页数
|
* 当前页数
|
||||||
*/
|
*/
|
||||||
private Integer pageNum;
|
private Integer page;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序列
|
* 排序列
|
||||||
*/
|
*/
|
||||||
private String orderByColumn;
|
private String orderField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排序的方向desc或者asc
|
* 排序的方向desc或者asc
|
||||||
*/
|
*/
|
||||||
private String isAsc;
|
private String order;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前记录起始索引 默认值
|
* 当前记录起始索引 默认值
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_PAGE_NUM = 1;
|
public static final int DEFAULT_PAGE = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 每页显示记录数 默认值 默认查全部
|
* 每页显示记录数 默认值 默认查全部
|
||||||
*/
|
*/
|
||||||
public static final int DEFAULT_PAGE_SIZE = Integer.MAX_VALUE;
|
public static final int DEFAULT_SIZE = 10;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 构造分页查询参数
|
* 构造分页查询参数
|
||||||
|
|
@ -66,10 +67,10 @@ public class PageQuery implements Serializable {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static <T> Page<T> build() {
|
public static <T> Page<T> build() {
|
||||||
Integer pageNum = Convert.toInt(TableSupport.getHttpServletRequest().getParameter(PAGE_NUM), DEFAULT_PAGE_NUM);
|
Integer pageNum = Convert.toInt(ServletUtil.getParameter(PAGE), DEFAULT_PAGE);
|
||||||
Integer pageSize = Convert.toInt(TableSupport.getHttpServletRequest().getParameter(PAGE_SIZE), DEFAULT_PAGE_SIZE);
|
Integer pageSize = Convert.toInt(ServletUtil.getParameter(SIZE), DEFAULT_SIZE);
|
||||||
if (pageNum <= 0) {
|
if (pageNum <= 0) {
|
||||||
pageNum = DEFAULT_PAGE_NUM;
|
pageNum = DEFAULT_PAGE;
|
||||||
}
|
}
|
||||||
Page<T> page = new Page<>(pageNum, pageSize);
|
Page<T> page = new Page<>(pageNum, pageSize);
|
||||||
return page;
|
return page;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,7 @@
|
||||||
package com.czg.core.page;
|
package com.czg.core.page;
|
||||||
|
|
||||||
import cn.hutool.core.convert.Convert;
|
import cn.hutool.core.convert.Convert;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import com.czg.utils.ServletUtil;
|
||||||
import org.springframework.web.context.request.RequestAttributes;
|
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表格数据处理
|
* 表格数据处理
|
||||||
|
|
@ -38,10 +35,10 @@ public class TableSupport {
|
||||||
*/
|
*/
|
||||||
public static PageDomain getPageDomain() {
|
public static PageDomain getPageDomain() {
|
||||||
PageDomain pageDomain = new PageDomain();
|
PageDomain pageDomain = new PageDomain();
|
||||||
pageDomain.setPage(Convert.toInt(getHttpServletRequest().getParameter(PAGE), 1));
|
pageDomain.setPage(Convert.toInt(ServletUtil.getParameter(PAGE), 1));
|
||||||
pageDomain.setSize(Convert.toInt(getHttpServletRequest().getParameter(SIZE), 10));
|
pageDomain.setSize(Convert.toInt(ServletUtil.getParameter(SIZE), 10));
|
||||||
pageDomain.setOrderField(getHttpServletRequest().getParameter(ORDER_FIELD));
|
pageDomain.setOrderField(ServletUtil.getParameter(ORDER_FIELD));
|
||||||
pageDomain.setOrder(getHttpServletRequest().getParameter(ORDER));
|
pageDomain.setOrder(ServletUtil.getParameter(ORDER));
|
||||||
return pageDomain;
|
return pageDomain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -49,12 +46,4 @@ public class TableSupport {
|
||||||
return getPageDomain();
|
return getPageDomain();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpServletRequest getHttpServletRequest() {
|
|
||||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
|
||||||
if (requestAttributes == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return ((ServletRequestAttributes) requestAttributes).getRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class ShopProdUnitServiceImpl extends ServiceImpl<ShopProdUnitMapper, Sho
|
||||||
|
|
||||||
private QueryWrapper buildQueryWrapper(ShopProdUnitDTO param) {
|
private QueryWrapper buildQueryWrapper(ShopProdUnitDTO param) {
|
||||||
QueryWrapper queryWrapper = PageUtil.buildPageQueryWrapper();
|
QueryWrapper queryWrapper = PageUtil.buildPageQueryWrapper();
|
||||||
if (StrUtil.isEmpty(param.getName())) {
|
if (StrUtil.isNotEmpty(param.getName())) {
|
||||||
queryWrapper.like(ShopProdUnit::getName, param.getName());
|
queryWrapper.like(ShopProdUnit::getName, param.getName());
|
||||||
}
|
}
|
||||||
Long shopId = StpKit.ADMIN.getLoginIdAsLong();
|
Long shopId = StpKit.ADMIN.getLoginIdAsLong();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue