Your Name
2023-09-25 fe623ab80e5148b33403fffee8e70043af945e00
优化代码
1个文件已修改
31 ■■■■ 已修改文件
service-store/src/main/java/com/java110/store/cmd/resourceStore/ListAllocationStorehouseApplysCmd.java 31 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service-store/src/main/java/com/java110/store/cmd/resourceStore/ListAllocationStorehouseApplysCmd.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSONObject;
import com.java110.core.annotation.Java110Cmd;
import com.java110.core.context.CmdContextUtils;
import com.java110.core.context.ICmdDataFlowContext;
import com.java110.core.event.cmd.Cmd;
import com.java110.core.event.cmd.CmdEvent;
@@ -11,6 +12,7 @@
import com.java110.intf.store.IAllocationStorehouseApplyInnerServiceSMO;
import com.java110.utils.exception.CmdException;
import com.java110.utils.util.BeanConvertUtil;
import com.java110.utils.util.StringUtil;
import com.java110.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
@@ -43,14 +45,7 @@
    public void doCmd(CmdEvent event, ICmdDataFlowContext context, JSONObject reqJson) throws CmdException, ParseException {
        AllocationStorehouseApplyDto allocationStorehouseApplyDto = BeanConvertUtil.covertBean(reqJson, AllocationStorehouseApplyDto.class);
        //调拨记录(调拨记录所有权限查看所有数据)
        String userId = reqJson.getString("userId");
        BasePrivilegeDto basePrivilegeDto = new BasePrivilegeDto();
        basePrivilegeDto.setResource("/viewlistAllocationStorehouses");
        basePrivilegeDto.setUserId(userId);
        List<Map> privileges = menuInnerServiceSMOImpl.checkUserHasResource(basePrivilegeDto);
        if (privileges.size() == 0) {
            allocationStorehouseApplyDto.setStartUserId(userId);
        }
        privilegeControl(context, allocationStorehouseApplyDto);
        int count = allocationStorehouseApplyInnerServiceSMOImpl.queryAllocationStorehouseApplysCount(allocationStorehouseApplyDto);
        List<AllocationStorehouseApplyDto> allocationStorehouseApplyDtos = null;
@@ -67,4 +62,24 @@
        context.setResponseEntity(responseEntity);
    }
    /**
     * 权限控制
     *
     * @param context
     * @param allocationStorehouseApplyDto
     */
    private void privilegeControl(ICmdDataFlowContext context, AllocationStorehouseApplyDto allocationStorehouseApplyDto) {
        if (!StringUtil.isEmpty(allocationStorehouseApplyDto.getApplyId())) { //单个信息查询时不做控制
            return;
        }
        String userId = CmdContextUtils.getUserId(context);
        BasePrivilegeDto basePrivilegeDto = new BasePrivilegeDto();
        basePrivilegeDto.setResource("/viewlistAllocationStorehouses");
        basePrivilegeDto.setUserId(userId);
        List<Map> privileges = menuInnerServiceSMOImpl.checkUserHasResource(basePrivilegeDto);
        if (privileges.size() == 0) {
            allocationStorehouseApplyDto.setStartUserId(userId);
        }
    }
}