package com.joju.datamanager.controller;

import cn.hutool.core.collection.CollUtil;
import com.joju.datamanager.common.annotation.EleganceLog;
import com.joju.datamanager.common.result.Result;
import com.joju.datamanager.common.result.ResultUtil;
import com.joju.datamanager.model.user.User;
import com.joju.datamanager.service.UserService;
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.List;

/**
 * @description: 微信用户信息管理
 * @author: Mr.zs
 * @create: 2024-03-06 18:09
 **/
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {


    @Autowired
    private UserService userService;

    @GetMapping("/getUserData")
    @EleganceLog(description = "测试接口")
    public Result getData() {

        return ResultUtil.successData("ok");
    }

    @GetMapping("/getOpenidByUserCard")
    @EleganceLog(description = "获取用户卡号绑定的openid")
    public Result getOpenidByUserCard(String card) {

        List<User> userCardAndRelateList = userService.getOpenidByUserCard(card);

        if (!CollUtil.isEmpty(userCardAndRelateList)) {
            return ResultUtil.successData(userCardAndRelateList);
        }
        return ResultUtil.failureMsg("获取失败");
    }




}
