package shop.alien.store.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import shop.alien.entity.result.R;
import shop.alien.store.service.LifeFansService;

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

/**
 * <p>
 * 粉丝/会员表 前端控制器
 * </p>
 *
 * @author lhb
 * @since 2025-05-14
 */
@Api(tags = {"一期-粉丝"})
@Slf4j
@RestController
@CrossOrigin
@RequestMapping("/fans")
@RequiredArgsConstructor
public class LifeFansController {

    private final LifeFansService lifeFansService;

    @ApiOperation("查询好友列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "用户phone", dataType = "String", paramType = "query", required = true)
    })
    @GetMapping("/getFriends")
    public R<List<Map<String, Object>>> getFriends(
            @RequestParam("phone") String phone) {
        log.info("LifeFansController.getFriends?phone={}", phone);
        return R.data(lifeFansService.getFriends(phone));
    }

    @ApiOperation("查询用户是否关注了某人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", paramType = "query", required = true),
            @ApiImplicitParam(name = "followedUserId", value = "关注人id", dataType = "Integer", paramType = "query", required = true)
    })
    @GetMapping("/getFollowStatus")
    public R<Boolean> getFollowStatus(@RequestParam("userId") Integer userId, @RequestParam("followedUserId") Integer followedUserId) {
        log.info("LifeFansController.getFollowStatus?userId={}&followedUserId={}", userId, followedUserId);
        return R.data(lifeFansService.getFollowStatus(userId, followedUserId));
    }

}
