package com.tofly.base.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import com.tofly.base.entity.UserRoles;
import com.tofly.base.service.UserService;
import com.tofly.common.core.entity.ResultRespone;

import com.tofly.base.entity.UserMiddle;
import com.tofly.base.service.UserMiddleService;

import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.ModelAttribute;

@RestController
@AllArgsConstructor
@RequestMapping("/usermiddle")
@Api(tags = "用户中间表接口")
@Slf4j
public class UserMiddleController {
    private final UserMiddleService userMiddleService;
    private final UserService userService;

    @GetMapping("/page")
    @ApiOperation(value = "分页查询")
    public ResultRespone getUserMiddlePage(Page page, @ModelAttribute UserMiddle userMiddle) {
        return ResultRespone.success(userMiddleService.page(page, Wrappers.query(userMiddle)));
    }

    @PostMapping("/sendUserNewUpdate")
    public ResultRespone sendUserNewUpdate(@RequestBody UserRoles user){
        log.info("营销用户同步:{}",user.getRealName());
        return ResultRespone.success(userMiddleService.sendUserNewUpdate(user));
    }

}
