| | |
| | | package com.vincent.rsf.server.manager.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.server.common.utils.ExcelUtil; |
| | | import com.vincent.rsf.server.common.annotation.OperationLog; |
| | | import com.vincent.rsf.server.common.domain.BaseParam; |
| | | import com.vincent.rsf.server.common.domain.CursorPageParam; |
| | | import com.vincent.rsf.server.common.domain.KeyValVo; |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.manager.entity.AsnOrderLog; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderLogService; |
| | | import com.vincent.rsf.server.manager.utils.buildPageRowsUtils; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import jakarta.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | public class AsnOrderLogController extends BaseController { |
| | | |
| | | private static final int DEFAULT_CURSOR_PAGE_SIZE = 20; |
| | | |
| | | @Autowired |
| | | private AsnOrderLogService asnOrderLogService; |
| | |
| | | @PreAuthorize("hasAuthority('manager:asnOrderLog:list')") |
| | | @PostMapping("/asnOrderLog/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<AsnOrderLog, BaseParam> pageParam = new PageParam<>(baseParam, AsnOrderLog.class); |
| | | return R.ok().add(asnOrderLogService.page(pageParam, pageParam.buildWrapper(true))); |
| | | // 这里已经不再手写游标分页细节,而是直接复用 BaseController 的通用实现。 |
| | | // |
| | | // 当前这几个参数分别表达: |
| | | // 1. map:前端原始请求参数 |
| | | // 2. CursorPageParam.class:通用游标参数解析器 |
| | | // 3. AsnOrderLog.class:用于通用筛选和 condition 模糊搜索 |
| | | // 4. asnOrderLogService:实际执行查询的 service |
| | | // 5. "id":本接口的游标字段,固定按 id desc 做分页 |
| | | // 6. DEFAULT_CURSOR_PAGE_SIZE:默认每页大小 |
| | | // 7. null:当前没有额外的 where 条件扩展 |
| | | // 8. buildPageRowsUtils::userNameMap:结果后处理,批量补 createBy$/updateBy$ |
| | | return R.ok().add(cursorPage( |
| | | map, |
| | | CursorPageParam.class, |
| | | AsnOrderLog.class, |
| | | asnOrderLogService, |
| | | "id", |
| | | DEFAULT_CURSOR_PAGE_SIZE, |
| | | null, |
| | | buildPageRowsUtils::userNameMap |
| | | )); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('manager:asnOrderLog:list')") |
| | |
| | | @PreAuthorize("hasAuthority('manager:asnOrderLog:list')") |
| | | @PostMapping("/asnOrderLog/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(asnOrderLogService.list(), AsnOrderLog.class), response); |
| | | List<AsnOrderLog> orders = new ArrayList<>(); |
| | | if (!Objects.isNull(map.get("ids"))) { |
| | | List<Long> ids = JSONArray.parseArray(JSONObject.toJSONString(map.get("ids")), Long.class); |
| | | if (!ids.isEmpty()) { |
| | | orders = asnOrderLogService.list(new LambdaQueryWrapper<AsnOrderLog>().in(AsnOrderLog::getId, ids)); |
| | | } else { |
| | | orders = asnOrderLogService.list(new LambdaQueryWrapper<>()); |
| | | } |
| | | } else { |
| | | orders = asnOrderLogService.list(new LambdaQueryWrapper<>()); |
| | | } |
| | | ExcelUtil.build(ExcelUtil.create(orders, AsnOrderLog.class), response); |
| | | } |
| | | |
| | | @ApiOperation("继续收货") |
| | | @PreAuthorize("hasAuthority('manager:asnOrderLog:update')") |
| | | @PostMapping("/asnOrderLog/continue/{id}") |
| | | public R continuRcpt(@PathVariable Long id) { |
| | | if (Objects.isNull(id)) { |
| | | return R.error("参数不能为空!!"); |
| | | } |
| | | return asnOrderLogService.continueRecipt(id); |
| | | } |
| | | |
| | | } |