package com.dk.mdm.controller.mst;

import com.dk.common.model.pojo.PageList;
import com.dk.common.response.ResponseResultVO;
import com.dk.mdm.model.pojo.mst.MoneyAccount;
import com.dk.common.service.BaseService;
import com.dk.mdm.model.query.mst.MoneyAccountQuery;
import com.dk.mdm.model.response.mst.MoneyAccountResponse;
import com.dk.mdm.model.vo.mst.MoneyAccountVO;
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.mst.MoneyAccountService;

import java.util.List;
import java.util.Map;

@Api(tags = "资金账户API接口")
@RestController
@RequestMapping("/mst/moneyAccount")
public class MoneyAccountController{

    public BaseService<MoneyAccount> getService() {
        return moneyAccountService;
    }

    @Autowired
    private MoneyAccountService moneyAccountService;

    /**
     * @desc : 条件查询
     * @author : 宋扬
     * @date : 2023/2/29 10:36
     */
    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
    @PostMapping({"list_by"})
    public ResponseResultVO<PageList<MoneyAccountResponse>> selectByCond(@RequestBody MoneyAccountQuery moneyAccountQuery) {
        return moneyAccountService.selectByCond(moneyAccountQuery);
    }

    /**
     * @desc   : 通过ID查询
     * @author : 宋扬
     * @date   : 2024/3/1 16:01
     */
    @PostMapping({"/{id}"})
    public ResponseResultVO selectById(@PathVariable String id) {
        return moneyAccountService.selectById(id);
    }

    /**
     * @desc : 维修小程序查询
     * @author : 王英杰
     * @date : 2023/2/29 10:36
     */
    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
    @PostMapping({"wx_list_by"})
    public ResponseResultVO<Map<String, Object>> wxSelectByCond(@RequestBody MoneyAccountQuery moneyAccountQuery) {
        return moneyAccountService.wxSelectByCond(moneyAccountQuery);
    }

    /**
     * @desc : 新建资金账户
     * @author : 宋扬
     * @date : 2023/2/29 10:48
     */
    @ApiOperation(value = "新建资金账户", notes = "新建资金账户")
    @PostMapping({"insert"})
    public ResponseResultVO<?> insert(@RequestBody MoneyAccountVO moneyAccountVO) {
        return moneyAccountService.insert(moneyAccountVO);
    }

    /**
     * @desc : 编辑员工
     * @author : 宋扬
     * @date : 2023/2/29 10:49
     */
    @ApiOperation(value = "编辑资金账户", notes = "编辑资金账户")
    @PostMapping({"update"})
    public ResponseResultVO<Boolean> update(@RequestBody MoneyAccountVO moneyAccountVO) {
        return moneyAccountService.update(moneyAccountVO);
    }

    /**
     * @desc : 批量启用
     * @author : 周兴
     * @date : 2023/3/7 10:34
     */
    @ApiOperation(value = "批量启用", notes = "批量启用")
    @PostMapping("enable_batch")
    public ResponseResultVO<Boolean> enableBatch(@RequestBody List<String> ids) {
        return this.getService().enableBatch(ids);
    }

    /**
     * @desc : 批量停用
     * @author : 周兴
     * @date : 2023/3/7 10:34
     */
    @ApiOperation(value = "批量停用", notes = "批量停用")
    @PostMapping("disable_batch")
    public ResponseResultVO<Boolean> disableBatch(@RequestBody List<String> ids) {
        return this.getService().disableBatch(ids);
    }

}
