package com.iformall.controller;

import com.iformall.common.ResultData;
import com.iformall.domain.po.WxTags;
import com.iformall.enums.EnumTagType;
import com.iformall.service.WxTagsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

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

@RestController
@RequestMapping("/api/tag")
@Api(description = "积分相关接口")
@Slf4j
public class WxTagController extends BaseController {

    @Autowired
    private WxTagsService wxTagsService;

    @ApiOperation("获取标签")
    @GetMapping("/getData")
    public ResultData getData() {
        log.debug("[" + getIpAddr() + "] WxTagController::getData");
        WxTags wxTags = new WxTags();
        wxTags.setTypeId(EnumTagType.ID_27.getCode());
        List<WxTags> listA = wxTagsService.findList(wxTags);
        wxTags.setTypeId(EnumTagType.ID_28.getCode());
        List<WxTags> listB = wxTagsService.findList(wxTags);
        Map<Long, List<WxTags>> dataMap = new HashMap<>();
        dataMap.put(EnumTagType.ID_27.getCode(), listA);
        dataMap.put(EnumTagType.ID_28.getCode(), listB);

        Map<Long, String> type = new HashMap<>();
        type.put(EnumTagType.ID_27.getCode(), EnumTagType.ID_27.getMessage());
        type.put(EnumTagType.ID_28.getCode(), EnumTagType.ID_28.getMessage());

        Map<String, Object> data = new HashMap<>();
        data.put("type", type);
        data.put("data", dataMap);
        return new ResultData(data);
    }


}
