package com.hc.gpweb.controller.back;

import com.hc.gpbusiness.model.login.AuthEntity;
import com.hc.gpbusiness.service.WebUserAdminService;
import com.hc.gpcore.utils.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 管理员表(UserAdmin)表控制层
 *
 * @author java
 * @since 2020-05-29 16:06:50
 */
 
@RestController
@RequestMapping("/api/back/userAdmin")
public class BackUserAdminController {

    /**
     * 服务对象
     */
    private final WebUserAdminService userAdminService;

    public BackUserAdminController(WebUserAdminService userAdminService) {
        this.userAdminService = userAdminService;
    }

    
    @GetMapping("/{id}")
    @ApiOperation(value = "依据主键获取 UserAdmin", response = Result.class)
    public Result selectBackUserAdmin(@PathVariable("id") Integer id) {
        return Result.success(userAdminService.queryById(id));
    }

    @PostMapping("/login")
    @ApiOperation(value = "后台管理员登录", response = Result.class)
    public Result userAdminLogin(@Valid @RequestBody AuthEntity authEntity) {
        return Result.success(userAdminService.userAdminLogin(authEntity));
    }

}