商品模块代码提交
This commit is contained in:
parent
15db6821df
commit
2d841d3fc6
|
|
@ -28,7 +28,7 @@ import java.util.Map;
|
|||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/prod/product")
|
||||
@RequestMapping("/admin/prod/product")
|
||||
public class ProductController {
|
||||
private final ProductService productService;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ import java.util.Map;
|
|||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/prod/category")
|
||||
@RequestMapping("/admin/prod/category")
|
||||
public class ShopProdCategoryController {
|
||||
private final ShopProdCategoryService shopProdCategoryService;
|
||||
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@ import java.util.List;
|
|||
*/
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/prod/unit")
|
||||
@RequestMapping("/admin/prod/unit")
|
||||
public class ShopProdUnitController {
|
||||
private final ShopProdUnitService shopProdUnitService;
|
||||
|
||||
@GetMapping("page")
|
||||
@LogOperation("分页")
|
||||
@SaAdminCheckPermission("prod:unit:all")
|
||||
public CzgResult<Page<ShopProdUnitDTO>> page(@RequestParam ShopProdUnitDTO param) {
|
||||
//@SaAdminCheckPermission("prod:unit:all")
|
||||
public CzgResult<Page<ShopProdUnitDTO>> page(ShopProdUnitDTO param) {
|
||||
Page<ShopProdUnitDTO> data = shopProdUnitService.page(param);
|
||||
return CzgResult.success(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.czg.core.page;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.czg.utils.ServletUtil;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
public static <T> Page<T> build() {
|
||||
Integer pageNum = Convert.toInt(TableSupport.getHttpServletRequest().getParameter(PAGE_NUM), DEFAULT_PAGE_NUM);
|
||||
Integer pageSize = Convert.toInt(TableSupport.getHttpServletRequest().getParameter(PAGE_SIZE), DEFAULT_PAGE_SIZE);
|
||||
Integer pageNum = Convert.toInt(ServletUtil.getParameter(PAGE), DEFAULT_PAGE);
|
||||
Integer pageSize = Convert.toInt(ServletUtil.getParameter(SIZE), DEFAULT_SIZE);
|
||||
if (pageNum <= 0) {
|
||||
pageNum = DEFAULT_PAGE_NUM;
|
||||
pageNum = DEFAULT_PAGE;
|
||||
}
|
||||
Page<T> page = new Page<>(pageNum, pageSize);
|
||||
return page;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,7 @@
|
|||
package com.czg.core.page;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
import com.czg.utils.ServletUtil;
|
||||
|
||||
/**
|
||||
* 表格数据处理
|
||||
|
|
@ -38,10 +35,10 @@ public class TableSupport {
|
|||
*/
|
||||
public static PageDomain getPageDomain() {
|
||||
PageDomain pageDomain = new PageDomain();
|
||||
pageDomain.setPage(Convert.toInt(getHttpServletRequest().getParameter(PAGE), 1));
|
||||
pageDomain.setSize(Convert.toInt(getHttpServletRequest().getParameter(SIZE), 10));
|
||||
pageDomain.setOrderField(getHttpServletRequest().getParameter(ORDER_FIELD));
|
||||
pageDomain.setOrder(getHttpServletRequest().getParameter(ORDER));
|
||||
pageDomain.setPage(Convert.toInt(ServletUtil.getParameter(PAGE), 1));
|
||||
pageDomain.setSize(Convert.toInt(ServletUtil.getParameter(SIZE), 10));
|
||||
pageDomain.setOrderField(ServletUtil.getParameter(ORDER_FIELD));
|
||||
pageDomain.setOrder(ServletUtil.getParameter(ORDER));
|
||||
return pageDomain;
|
||||
}
|
||||
|
||||
|
|
@ -49,12 +46,4 @@ public class TableSupport {
|
|||
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) {
|
||||
QueryWrapper queryWrapper = PageUtil.buildPageQueryWrapper();
|
||||
if (StrUtil.isEmpty(param.getName())) {
|
||||
if (StrUtil.isNotEmpty(param.getName())) {
|
||||
queryWrapper.like(ShopProdUnit::getName, param.getName());
|
||||
}
|
||||
Long shopId = StpKit.ADMIN.getLoginIdAsLong();
|
||||
|
|
|
|||
Loading…
Reference in New Issue