package org.springblade.modules.app.web.admin;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wn.common.controller.BaseController;
import com.wn.common.datamodel.ResultDTO;
import org.springblade.modules.app.common.dto.UserDTO;
import org.springblade.modules.app.common.query.AdminUserQuery;
import org.springblade.modules.app.common.vo.ChangeUserStateVO;
import org.springblade.modules.app.manager.UserManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName: AdminUserController
 * @Description:
 * @author: fxs
 * @createTime: 2021-11-22-16:11
 */
@RestController
@RequestMapping("app/admin/user")
@Api(value = "用户管理-管理端", tags = "用户管理-管理端")
public class AdminUserController extends BaseController {

    @Autowired
    private UserManager userManager;

    //@ApiOperation(value = "分页查询用户注册信息列表")
    @GetMapping("/page")
    public ResponseEntity<ResultDTO<Page<UserDTO>>> pageUser(AdminUserQuery userQuery) {
        return success(userManager.pageUser(userQuery));
    }

    //@ApiOperation(value = "查询用户详情")
    @GetMapping("/{id}")
    public ResponseEntity<ResultDTO<UserDTO>> getUserDetail(@PathVariable Long id) {
        return success(userManager.getUserByID(id));
    }

    //@ApiOperation(value = "修改用户状态")
    @PutMapping("/state")
    public ResponseEntity<ResultDTO<Boolean>> changeUserState(@RequestBody ChangeUserStateVO stateVO) {
        return success(userManager.changeUserState(stateVO));
    }
}
