package com.kcim.web;

import com.kcim.common.util.PageUtils;
import com.kcim.common.util.Result;
import com.kcim.dao.model.dto.DepartDTO;
import com.kcim.vo.CenterDepartmentVO;
import com.kcim.service.ResponsibilityDepartmentService;
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-27 14:53:53
 */
@Api(tags="对照中心")
@RestController
@RequestMapping("centerDepartment")
public class ResponsibilityDepartmentController {
    private ResponsibilityDepartmentService responsibilityDepartmentService;

    public ResponsibilityDepartmentController(ResponsibilityDepartmentService responsibilityDepartmentService) {
        this.responsibilityDepartmentService = responsibilityDepartmentService;
    }


    @ApiOperation("列表")
    @GetMapping("/list")
    public Result list(){
        List<CenterDepartmentVO> list = responsibilityDepartmentService.getCenterDepart();
        PageUtils pageUtils = new PageUtils(list, 0, 0, 0);
        return Result.ok(pageUtils);
    }

    @ApiOperation("保存或修改责任中心对照")
    @PostMapping("/save")
    public Result saveOrUpdate(@RequestBody @Valid DepartDTO departDTO) {
        responsibilityDepartmentService.saveCenterDepart(departDTO);
        return Result.ok();
    }


}
