skyouc
昨天 52d78628a70d6aa129f874050b7846d259819554
rsf-server/src/main/java/com/vincent/rsf/server/manager/controller/StockItemController.java
@@ -12,6 +12,7 @@
import com.vincent.rsf.server.manager.entity.StockItem;
import com.vincent.rsf.server.manager.service.StockItemService;
import com.vincent.rsf.server.system.controller.BaseController;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
@@ -19,13 +20,14 @@
import javax.servlet.http.HttpServletResponse;
import java.util.*;
@Api(tags = "库存明细")
@RestController
public class StockItemController extends BaseController {
    @Autowired
    private StockItemService stockItemService;
    @PreAuthorize("hasAuthority('manager:stockItem:list')")
    @PreAuthorize("hasAuthority('manager:stock:list')")
    @PostMapping("/stockItem/page")
    public R page(@RequestBody Map<String, Object> map) {
        BaseParam baseParam = buildParam(map, BaseParam.class);
@@ -33,25 +35,25 @@
        return R.ok().add(stockItemService.page(pageParam, pageParam.buildWrapper(true)));
    }
    @PreAuthorize("hasAuthority('manager:stockItem:list')")
    @PreAuthorize("hasAuthority('manager:stock:list')")
    @PostMapping("/stockItem/list")
    public R list(@RequestBody Map<String, Object> map) {
        return R.ok().add(stockItemService.list());
    }
    @PreAuthorize("hasAuthority('manager:stockItem:list')")
    @PreAuthorize("hasAuthority('manager:stock:list')")
    @PostMapping({"/stockItem/many/{ids}", "/stockItems/many/{ids}"})
    public R many(@PathVariable Long[] ids) {
        return R.ok().add(stockItemService.listByIds(Arrays.asList(ids)));
    }
    @PreAuthorize("hasAuthority('manager:stockItem:list')")
    @PreAuthorize("hasAuthority('manager:stock:list')")
    @GetMapping("/stockItem/{id}")
    public R get(@PathVariable("id") Long id) {
        return R.ok().add(stockItemService.getById(id));
    }
    @PreAuthorize("hasAuthority('manager:stockItem:save')")
    @PreAuthorize("hasAuthority('manager:stock:save')")
    @OperationLog("Create 库存明细表")
    @PostMapping("/stockItem/save")
    public R save(@RequestBody StockItem stockItem) {
@@ -65,7 +67,7 @@
        return R.ok("Save Success").add(stockItem);
    }
    @PreAuthorize("hasAuthority('manager:stockItem:update')")
    @PreAuthorize("hasAuthority('manager:stock:update')")
    @OperationLog("Update 库存明细表")
    @PostMapping("/stockItem/update")
    public R update(@RequestBody StockItem stockItem) {
@@ -77,7 +79,7 @@
        return R.ok("Update Success").add(stockItem);
    }
    @PreAuthorize("hasAuthority('manager:stockItem:remove')")
    @PreAuthorize("hasAuthority('manager:stock:remove')")
    @OperationLog("Delete 库存明细表")
    @PostMapping("/stockItem/remove/{ids}")
    public R remove(@PathVariable Long[] ids) {
@@ -87,21 +89,21 @@
        return R.ok("Delete Success").add(ids);
    }
    @PreAuthorize("hasAuthority('manager:stockItem:list')")
    @PreAuthorize("hasAuthority('manager:stock:list')")
    @PostMapping("/stockItem/query")
    public R query(@RequestParam(required = false) String condition) {
        List<KeyValVo> vos = new ArrayList<>();
        LambdaQueryWrapper<StockItem> wrapper = new LambdaQueryWrapper<>();
        if (!Cools.isEmpty(condition)) {
            wrapper.like(StockItem::getMatnrk, condition);
            wrapper.like(StockItem::getMaktx, condition);
        }
        stockItemService.page(new Page<>(1, 30), wrapper).getRecords().forEach(
                item -> vos.add(new KeyValVo(item.getId(), item.getMatnrk()))
                item -> vos.add(new KeyValVo(item.getId(), item.getMaktx()))
        );
        return R.ok().add(vos);
    }
    @PreAuthorize("hasAuthority('manager:stockItem:list')")
    @PreAuthorize("hasAuthority('manager:stock:list')")
    @PostMapping("/stockItem/export")
    public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception {
        ExcelUtil.build(ExcelUtil.create(stockItemService.list(), StockItem.class), response);