ReceiptContainerDetailController.java 3.95 KB
package com.huaheng.pc.receipt.receiptContainerDetail.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.huaheng.common.utils.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.aspectj.lang.annotation.Log;
import com.huaheng.framework.aspectj.lang.constant.BusinessType;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.framework.web.page.PageDomain;
import com.huaheng.framework.web.page.TableDataInfo;
import com.huaheng.framework.web.page.TableSupport;
import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail;
import com.huaheng.pc.receipt.receiptContainerDetail.service.ReceiptContainerDetailService;
import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

@Controller
@RequestMapping("/receipt/receiptContainerDetail")
public class ReceiptContainerDetailController extends BaseController {

    @Resource
    private ReceiptContainerDetailService receiptContainerDetailService;

    private String prefix = "receipt/receiptContainerDetail";

    @RequiresPermissions("receipt:receiptContainerDetail:view")
    @Log(title = "入库-入库详情列表", operating = "入库详情列表", action = BusinessType.GRANT)
    @GetMapping("/list/{id}")
    public String list(@PathVariable("id")Integer id, ModelMap mmap) {
        mmap.put("receiptId", id);
        return prefix+"/receiptDetail";
    }

    /**
     * 查询入库详情
     */
    @ApiOperation(value="查看入库详情", notes="根据头表id获取入库单明细信息", httpMethod = "POST")
    @RequiresPermissions("receipt:receiptDetail:list")
    @Log(title = "入库-入库单明细管理", operating = "查看入库单明细", action = BusinessType.GRANT)
    @PostMapping("/list/{id}")
    @ResponseBody
    public TableDataInfo list(@ApiParam(name="receiptDetail",value="入库详情") @PathVariable("id")Integer receiptDetailId) {
        LambdaQueryWrapper<ReceiptContainerDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        lambdaQueryWrapper.eq(ReceiptContainerDetail::getReceiptContainerId, receiptDetailId);

        if (StringUtils.isNotNull(pageNum) && StringUtils.isNotNull(pageSize)){
            /*使用分页查询*/
            Page<ReceiptContainerDetail> page = new Page<>(pageNum, pageSize);
            IPage<ReceiptContainerDetail> iPage = receiptContainerDetailService.page(page, lambdaQueryWrapper);
            return getMpDataTable(iPage.getRecords(), iPage.getTotal());
        } else {
            List<ReceiptContainerDetail> list = receiptContainerDetailService.list(lambdaQueryWrapper);
            return getDataTable(list);
        }
    }

    @RequiresPermissions("receipt:receiptContainerDetail:remove")
    @Log(title = "入库-入库详情列表", operating = "入库详情列表", action = BusinessType.GRANT)
    @PostMapping("remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        if (StringUtils.isEmpty(ids)){
            return AjaxResult.error("id不能为空");
        }

        List<Integer> idList = Arrays.asList(Convert.toIntArray(ids));
        return toAjax(receiptContainerDetailService.detailRemove(idList));
    }
}