package com.cpp.web.controller.tool;

import com.cpp.common.core.domain.R;
import com.cpp.web.domain.datafactory.enums.FileTypeEnum;
import com.cpp.web.domain.datafactory.enums.UseStatusEnum;
import com.cpp.web.domain.enums.AlarmEnum;
import com.cpp.web.domain.enums.DataSourcesEnum;
import com.cpp.web.domain.station.enums.ElectricFieldTypeEnum;
import com.cpp.web.domain.station.enums.EquipmentTypeEnum;
import com.cpp.web.domain.station.enums.ProvinceEnum;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 枚举返回select类型选择转换接口
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("enumSelect")
public class EnumSelectController {


    /**
     * 告警类型
     * @return
     */
    @GetMapping("/alarmEnum")
    public R alarmEnum() {

        List<EnumSelect> list = new ArrayList<>();
        for (AlarmEnum value : AlarmEnum.values()) {
            list.add(new EnumSelect(value.getMessage(),value.name()));
        }
        
        return R.ok(list);
    }


    @GetMapping("/dataSourcesEnum")
    public R dataSourcesEnum() {

        List<EnumSelect> list = new ArrayList<>();
        for (DataSourcesEnum value : DataSourcesEnum.values()) {
            list.add(new EnumSelect(value.getMessage(),value.name()));
        }

        return R.ok(list);
    }

    @GetMapping("/fileTypeEnum")
    public R fileTypeEnum() {

        List<EnumSelect> list = new ArrayList<>();
        for (FileTypeEnum value : FileTypeEnum.values()) {
            list.add(new EnumSelect(value.getMessage(),value.name()));
        }

        return R.ok(list);
    }


    @GetMapping("/useStatusEnum")
    public R useStatusEnum() {

        List<EnumSelect> list = new ArrayList<>();
        for (UseStatusEnum value : UseStatusEnum.values()) {
            list.add(new EnumSelect(value.getMessage(),value.name()));
        }

        return R.ok(list);
    }


    @GetMapping("/electricFieldTypeEnum")
    public R electricFieldTypeEnum() {

        List<EnumSelect> list = new ArrayList<>();
        for (ElectricFieldTypeEnum value : ElectricFieldTypeEnum.values()) {
            list.add(new EnumSelect(value.getMessage(),value.name()));
        }

        return R.ok(list);
    }


    @GetMapping("/pquipmentTypeEnum")
    public R EquipmentTypeEnum() {

        List<EnumSelect> list = new ArrayList<>();
        for (EquipmentTypeEnum value : EquipmentTypeEnum.values()) {
            list.add(new EnumSelect(value.getMessage(),value.name()));
        }

        return R.ok(list);
    }


    @GetMapping("/provinceEnum")
    public R provinceEnum() {

        List<EnumSelect> list = new ArrayList<>();
        for (ProvinceEnum value : ProvinceEnum.values()) {
            list.add(new EnumSelect(value.getMessage(),value.name()));
        }

        return R.ok(list);
    }
    
    
    @Data
    public class EnumSelect{
        private String label;
        private String value;

        public EnumSelect(String label, String value) {
            this.label = label;
            this.value = value;
        }
    }
}
