Helius
2020-12-27 b43d3b638790b8fc4398a803f9e18af2b35efac6
zq-erp/src/main/java/com/matrix/system/app/action/ApiStoreAction.java
@@ -1,15 +1,65 @@
package com.matrix.system.app.action;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.WebUtil;
import com.matrix.system.app.dto.StoreListDto;
import com.matrix.system.app.mapper.SysStoreInfoMapper;
import com.matrix.system.app.vo.StoreListVo;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.common.tools.DataAuthUtil;
import com.matrix.system.hive.bean.SysStoreInfo;
import com.matrix.system.hive.dao.SysStoreInfoDao;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
 * @author wzy
 * @date 2020-12-27
 **/
@Api(value = "ApiStoreAction", tags = "库存管理接口类")
@RestController
@RequestMapping(value = "/api/store")
public class ApiStoreAction {
    @Autowired
    private SysStoreInfoDao sysStoreInfoDao;
    @ApiOperation(value = "获取库存列表", notes = "获取库存列表")
    @ApiResponses({
            @ApiResponse(code = 200, message = "ok", response = StoreListVo.class)
    })
    @PostMapping(value = "/findStoreList")
    public AjaxResult findStoreList(@RequestBody @Validated StoreListDto storeListDto) {
        SysStoreInfo sysStoreInfo = new SysStoreInfo();
        if (!DataAuthUtil.hasAllShopAuth()) {
            SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
            sysStoreInfo.setShopId(users.getShopId());
            sysStoreInfo.setCompanyId(users.getCompanyId());
        }
        sysStoreInfo.setQueryKey(storeListDto.getQueryKey());
        PaginationVO pageVo = new PaginationVO();
        pageVo.setOffset((storeListDto.getPageNum() - 1) * storeListDto.getPageSize());
        pageVo.setLimit(storeListDto.getPageSize());
        pageVo.setSort("c.goods_no");
        pageVo.setOrder("asc");
        List<SysStoreInfo> dataList = sysStoreInfoDao.selectCountInPage(sysStoreInfo, pageVo);
        List<StoreListVo> resultList = SysStoreInfoMapper.INSTANCE.entitiesToStoreVos(dataList);
        return new AjaxResult(AjaxResult.STATUS_SUCCESS,  resultList, sysStoreInfoDao.selectCountTotalRecord(sysStoreInfo));
    }
}