package com.kcim.web;

import com.kcim.common.util.PageUtils;
import com.kcim.common.util.Result;
import com.kcim.dao.model.dto.AccountProductSaveDTO;
import com.kcim.vo.AccountProductVO;
import com.kcim.service.AccountingProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


/**
 * 会计科目成本对照表
 *
 * @author huangrui
 * @date 2021-07-28 20:20:53
 */
@Api(tags="会计科目成本对照表")
@RestController
@RequestMapping("accountProduct")
public class AccountingProductController {

    private final AccountingProductService accountingProductService;

    public AccountingProductController(AccountingProductService accountingProductService) {
        this.accountingProductService = accountingProductService;
    }

    /**
     * 分页查询列表
     */
    @ApiOperation("会计科目成本对照列表")
    @GetMapping("/list")
    public Result list(Integer accountType) {
        List<AccountProductVO> list = accountingProductService.selectList(accountType);
        PageUtils pageUtils = new PageUtils(list, 0, 0, 0);
        return Result.ok(pageUtils);
    }

    @ApiOperation("会计科目成本新增或修改")
    @PostMapping("/save")
    public Result save(@RequestBody @Valid AccountProductSaveDTO accountProductSaveDTO) {
        accountingProductService.saveAccountProduct(accountProductSaveDTO);
        return Result.ok();
    }

}
