package com.hc.web.controller.browser.back;

import com.hc.business.model.ZccmUserAdmin;
import com.hc.business.model.login.AuthEntity;
import com.hc.business.service.ZccmUserAdminService;
import com.hc.core.utils.result.Result;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author JIA
 */
@RestController
@RequestMapping("/new/api/back/userAdmin")
public class BackUserAdminController {

    private final ZccmUserAdminService userAdminService;

    @Autowired
    public BackUserAdminController(ZccmUserAdminService userAdminService) {
        this.userAdminService = userAdminService;
    }

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

    @PostMapping("/insert")
    @ApiOperation(value = "新增管理员", response = Result.class)
    public Result insertZccmUserAdmin(@Valid @RequestBody ZccmUserAdmin userAdmin) {
        return Result.success(userAdminService.insert(userAdmin));
    }

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

}
