package com.miaxis.app.controller.Spread;

import com.miaxis.common.constant.Constants;
import com.miaxis.common.core.domain.Response;
import com.miaxis.common.core.domain.entity.UserInfo;
import com.miaxis.common.utils.SecurityUtils;
import com.miaxis.spread.service.IWxSpreadRelationService;
import com.miaxis.spread.vo.WxSpreadRelationVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
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;

/**
 * @author wwl
 * @version 1.0
 * @date 2021/11/25 10:42
 */
@RestController
@RequestMapping(Constants.STUDENT_PREFIX + "/spread/relation")
@Api(tags={"【H5-wx推广关系】"})
@AllArgsConstructor
public class WxSpreadRelationController {

    private final IWxSpreadRelationService wxSpreadRelationService;

    /**
     * 根据openid查询一二级绑定用户
     */
    @GetMapping(value = "/spreadRelationList")
    @ApiOperation("根据openid查询一二级绑定用户")
    public Response<ArrayList<WxSpreadRelationVo>> spreadRelationList() {
        UserInfo userInfo = SecurityUtils.getLoginUser().getStudent();
        ArrayList<WxSpreadRelationVo> wxSpreadRelationVos = wxSpreadRelationService.spreadRelationList(userInfo.getOpenid());
        return Response.success(wxSpreadRelationVos);
    }

}
