package com.ym.mec.web.controller;

import com.ym.mec.auth.api.client.SysUserFeignService;
import com.ym.mec.auth.api.entity.SysUser;
import com.ym.mec.biz.dal.page.FinancialExpenditureQueryInfo;
import com.ym.mec.biz.service.FinancialExpenditureService;
import com.ym.mec.biz.service.OrganizationService;
import com.ym.mec.common.controller.BaseController;
import io.swagger.annotations.Api;
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.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("financialExpenditure")
@Api(tags = "财务支出服务")
@RestController
public class FinancialExpenditureController extends BaseController {

    @Autowired
    private FinancialExpenditureService financialExpenditureService;
    @Autowired
    private SysUserFeignService sysUserFeignService;
    @Autowired
    private OrganizationService organizationService;

    @ApiOperation(value = "删除财务支出")
    @PostMapping("/batchDel")
    @PreAuthorize("@pcs.hasPermissions('financialExpenditure/batchDel')")
    public Object batchDel(String ids) {
        financialExpenditureService.batchDel(ids);
        return succeed();
    }

    @ApiOperation(value = "分页查询财务支出列表")
    @GetMapping("/queryPage")
    @PreAuthorize("@pcs.hasPermissions('financialExpenditure/queryPage')")
    public Object queryPage(FinancialExpenditureQueryInfo queryInfo) {
        queryInfo.setOrganId(organizationService.getEmployeeOrgan(queryInfo.getOrganId()));
        return succeed(financialExpenditureService.queryFinancialExpenditurePage(queryInfo));
    }

}
