package com.dk.mdm.controller.mac;

import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultVO;
import com.dk.mdm.model.pojo.mac.OtherReceivable;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.query.mac.OtherReceivableQuery;
import com.dk.mdm.model.response.mac.OtherReceivableResponse;
import com.dk.mdm.model.vo.mac.OtherReceivableVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import com.dk.mdm.service.mac.OtherReceivableService;

import java.util.Map;

@Api(tags = "其他收入单API接口")
@RestController
@RequestMapping("/mac/otherReceivable")
public class OtherReceivableController{

    public BaseService<OtherReceivable> getService() {
        return otherReceivableService;
    }

    @Autowired
    private OtherReceivableService otherReceivableService;

    /**
     * @desc : 条件查询
     * @author : 付斌
     * @date : 2023/1/9 10:36
     */
    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<OtherReceivableResponse>> selectByCond(@RequestBody OtherReceivableQuery otherReceivableQuery) {
        return otherReceivableService.selectByCond(otherReceivableQuery);
    }

    /**
     * @desc :查询其它收入明细（明细附件）
     * @author : 付斌
     * @date : 2024-02-28 13:24
     */
    @PostMapping({"select_other_receivable_info_by_id/{id}"})
    public ResponseResultVO<Map<String, Object>> selectOtherReceivableInfoById(@PathVariable String id) {
        return otherReceivableService.selectOtherReceivableInfoById(id);
    }

    /**
     * @desc : 新建方法
     * @author : 付斌
     * @date : 2023/1/9 10:48
     */
    @ApiOperation(value = "新建", notes = "新建")
    @PostMapping({"insert"})
    public ResponseResultVO<?> insert(@RequestBody OtherReceivableVO otherReceivableVO) {
        return otherReceivableService.insert(otherReceivableVO);
    }

    /**
     * @desc : 编辑方法
     * @author : 付斌
     * @date : 2023/1/9 10:49
     */
    @ApiOperation(value = "编辑", notes = "编辑")
    @PostMapping({"update"})
    public ResponseResultVO<?> update(@RequestBody OtherReceivableVO otherReceivableVO) {
        return otherReceivableService.update(otherReceivableVO);
    }

    /**
     * @desc :查询其它收入明细（明细附件）
     * @author : 付斌
     * @date : 2024-02-28 13:24
     */
    @PostMapping({"get_other_receivable_for_update/{id}"})
    public ResponseResultVO<?> getOtherReceivableForUpdate(@PathVariable String id) {
        return otherReceivableService.getOtherReceivableForUpdate(id);
    }
    /**
     * @desc : 通过ID查询
     * @author : 王英杰
     * @date : 2023/1/9 10:41
     */
    @PostMapping({"/{id}"})
    public ResponseResultVO selectById(@PathVariable String id) {
        return otherReceivableService.getOtherReceivableForUpdate(id);
    }

    /**
     * @desc : 作废
     * @author : 付斌
     * @date : 2024-03-08 16:36
     */
    @ApiOperation(value = "作废", notes = "作废")
    @PostMapping({"invalid/{id}"})
    public ResponseResultVO<?> invalid(@PathVariable String id) {
        return otherReceivableService.invalid(id);
    }

}
