package com.ywt.controllers.mg;

import com.ywt.core.BaseResponse;
import com.ywt.core.DataResponse;


import com.ywt.core.MGRight;
import com.ywt.core.MGRightTypeDef;
import com.ywt.models.enums.PaymentChannelEnum;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author daiyihua
 * @create 2018-11-02 4:51 PM
 * @desc 得到枚举列表控制类
 **/

@RestController
@RequestMapping({"/mg/enum"})
@MGRight(type = MGRightTypeDef.Logined)
public class EnumController {


    /**
     * 得到支付方式（渠道）枚举list
     *
     * @return {@link BaseResponse}
     */
    @RequestMapping("/getPaymentChannelEnumList")
    public BaseResponse getPaymentChannelEnumList() {
        DataResponse<Object> response = new DataResponse<>();
        List<Object> lst = new ArrayList<>();
        for (PaymentChannelEnum e : PaymentChannelEnum.values()) {
            if (e.getValue() != 0) {
                Map<String, Object> item = new HashMap<>();
                item.put("value", e.getValue());
                item.put("name", e.getDisplayName());
                lst.add(item);
            }
        }
        response.setData(lst);
        return response.succeed("处理成功");
    }


}
