package com.tzld.piaoquan.api.controller.wecom;

import com.tzld.piaoquan.api.model.param.WeComUserNameAvatarParam;
import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
import com.tzld.piaoquan.growth.common.model.bo.GroupSendWeComUserParam;
import com.tzld.piaoquan.growth.common.model.vo.UserTagParam;
import com.tzld.piaoquan.growth.common.model.vo.WeComUserVo;
import com.tzld.piaoquan.growth.common.service.WeComUserService;
import com.tzld.piaoquan.growth.common.utils.page.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/wecom/user")
public class WeComUserController {


    @Autowired
    private WeComUserService service;


    @PostMapping("/getByNameAvatar")
    public CommonResponse<List<WeComUserVo>> getByNameAvatar(@RequestBody WeComUserNameAvatarParam param) {
        log.info("param={}", param);
        return CommonResponse.success(service.getWeComUserByNameAvatar(param.getName(), param.getAvatar()));
    }


    @PostMapping("/getGroupSendUsers")
    public CommonResponse<Page<WeComUserVo>> getGroupSendUsers(@RequestBody GroupSendWeComUserParam param) {
        log.info("param={}", param);
        return CommonResponse.success(service.getGroupSendWeComUser(param));
    }

    @PostMapping("/add/tag")
    public CommonResponse<Void> addUserTag(@RequestBody UserTagParam userTagParam) {
        log.info("addUserTag param={}", userTagParam);
        return service.addUserTag(userTagParam);
    }
}
