package com.liangjian.dataplatform.member.controller;


import com.liangjian.dataplatform.member.entity.response.ResultObject;
import com.liangjian.dataplatform.member.service.IMemberextsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/memberexts")
@Api(value = "会员信息详情控制器", tags = "会员信息详情", description = "会员信息详情控制器")
public class MemberextsController {

    @Autowired
    private IMemberextsService memberextsService;

    @PostMapping("/memberextsByPhone")
    @ApiOperation(value = "查询会员信息")
    public Map<String, Object> memberextsByPhone(@ApiParam(value = "参数", required = true) @RequestBody String data) {

        return memberextsService.memberextsByPhone(data);
    }

    @PostMapping("/index")
    @ApiOperation(value = "查询会员信息")
    public Map<String, Object> index(@ApiParam(value = "参数", required = true) @RequestBody String data) {

        return memberextsService.index(data);
    }

    @PostMapping("/TagByMemberPhone")
    @ApiOperation(value = "查询用户标签")
    public Map<String, Object> tagByMemberPhone(String data) {

        return memberextsService.tagByMemberPhone(data);
    }

    /**
     *  根据用户的手机号返回用户的所有标签
     * @param phone
     * @return 用户的所有标签
     * @throws IOException
     */
    @GetMapping("/findTagsByMemberPhone")
    @ApiOperation(value = "根据手机号查询用户标签(es)")
    public ResultObject<List<Map<String, Object>>> findTagsByMemberPhone(String phone) throws IOException {
        if(phone == null || "".equals(phone)){
            return ResultObject.error("手机号不能为空");
        }
        ResultObject<List<Map<String, Object>>> result = memberextsService.findTagsByMemberPhone(phone);
        result.setMsg("响应成功");
        result.setCode(200);
        return result;

    }

    /**
     * 根据用户的加密手机号返回用户的所有标签
     * @param secretPhone
     * @return 用户的所有标签
     * @throws IOException
     */
    @GetMapping("/findTagsByMemberecretPhone")
    @ApiOperation(value = "根据加密手机号查询用户标签(es)")
    public ResultObject<List<Map<String, Object>>> findTagsByMemberecretPhone(String secretPhone) throws IOException {
        if(secretPhone == null || "".equals(secretPhone)){
            return ResultObject.error("手机号不能为空");
        }
        ResultObject<List<Map<String, Object>>> result = memberextsService.findTagsByMemberSecretPhone(secretPhone);
        result.setMsg("响应成功");
        result.setCode(200);
        return result;

    }

    /**
     * 根据用户手机号查询基本信息
     * @param phone
     * @return 用户基本信息
     * @throws IOException
     */
    @GetMapping("/findBaseInfoByMemberPhone")
    @ApiOperation(value = "根据手机号查询用户基本信息(es)")
    public ResultObject<Map<String, Object>> findBaseInfoByMemberPhone(String phone) throws IOException {
        if(phone == null || "".equals(phone)){
            return ResultObject.error("手机号不能为空");
        }

        ResultObject<Map<String, Object>> result = memberextsService.findBaseInfoByMemberPhone(phone);
        result.setCode(200);
        return result;

    }


    /**
     * 根据用户加密手机号查询基本信息
     * @param phone
     * @return 用户基本信息
     * @throws IOException
     */
    @GetMapping("/findBaseInfoByMemberSecretPhone")
    @ApiOperation(value = "根据加密手机号查询用户基本信息(es)")
    public ResultObject<Map<String, Object>> findBaseInfoByMemberSecretPhone(String phone) throws IOException {
        if(phone == null || "".equals(phone)){
            return ResultObject.error("手机号不能为空");
        }
        ResultObject<Map<String, Object>> result = memberextsService.findBaseInfoByMemberSecretPhone(phone);
        result.setCode(200);
        return result;

    }

}
