package pwc.taxtech.atms.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.dpo.StatisticAttributeDisplayDto;
import pwc.taxtech.atms.dto.OperationResultDto;
import pwc.taxtech.atms.dto.StatisticAttributeDto;
import pwc.taxtech.atms.service.impl.StatisticAttributeServiceImpl;

import java.util.List;

@RestController
@RequestMapping("/api/v1/statisticAttribute/")
public class StatisticAttributeController {

    @Autowired
    private StatisticAttributeServiceImpl statisticAttributeService;

//    @ApiOperation(value = "显示自定义显示字段")
    @RequestMapping(value = "getByParentDimensionID", method = RequestMethod.GET)
    public @ResponseBody
    List<StatisticAttributeDisplayDto> getDimensionStatics(
            @RequestParam("parentDimensionID") String parentDimensionId) {
        return statisticAttributeService.getStatisticAttributeListByDimensionId(parentDimensionId, null);
    }

//    @ApiOperation(value = "自定义显示字段下拉框")
    @RequestMapping(value = "get", method = RequestMethod.GET)
    public @ResponseBody
    List<StatisticAttributeDto> getStatisticAttributeList(
            @RequestParam("dictionaryCode") String dictionaryCode) {
        return statisticAttributeService.getStatisticAttributeList(dictionaryCode);
    }

//    @ApiOperation(value = "更新显示自定义显示字段")
    @RequestMapping(value = "update", method = RequestMethod.POST)
    @SuppressWarnings("rawtypes")
    public OperationResultDto updateDimension(
            @RequestBody(required = false) List<StatisticAttributeDisplayDto> modelList) {
        return statisticAttributeService.updateStatisticAttribute(modelList);
    }

//    @ApiOperation(value = "机构管理/卡片/机构/点击自定义显示内容按钮")
    @RequestMapping(value = "getOrgSubChildrenStatAttributeList", method = RequestMethod.GET)
    public @ResponseBody
    List<StatisticAttributeDisplayDto> getOrgSubChildrenStatAttributeList(
            @RequestParam("parentDimensionId") String parentDimensionId) {
        return statisticAttributeService.getOrgSubChildrenStatAttributeList(parentDimensionId);
    }

}