package org.linlinjava.jz.admin.web;


import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.linlinjava.jz.admin.util.SecurityHelper;
import org.linlinjava.jz.core.util.ResponseUtil;
import org.linlinjava.jz.db.domain.SysUserRest;
import org.linlinjava.jz.db.service.JzSysUserRestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
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;

@Api(value = "Admin-UserRest-Controller",description = "坐席休息状态")
@RestController
@RequestMapping("/admin/rest")
public class AdminSysUserRestController {

    @Autowired
    private JzSysUserRestService restService;

    @RequiresPermissions("admin:rest:create")
    @PostMapping("/create")
    public Object create(@RequestBody SysUserRest rest) {
        rest.setUserId(SecurityHelper.getAdminId());
        restService.add(rest);
        return ResponseUtil.ok(rest);
    }

    @RequiresPermissions("admin:rest:update")
    @PostMapping("/update")
    public Object update(@RequestBody SysUserRest rest) {
        restService.updateById(rest);
        return ResponseUtil.ok();
    }

}
