package com.ssyf.module.robot.controller.auth;

import cn.hutool.core.bean.BeanUtil;
import com.github.pagehelper.PageInfo;
import com.ssyf.common.web.aop.RequestSynchronization;
import com.ssyf.common.web.apicode.ApiCodeUser;
import com.ssyf.common.web.result.Result;
import com.ssyf.common.web.valid.ValidA;
import com.ssyf.module.robot.domain.entity.RRunningConfigGlobal;
import com.ssyf.module.robot.domain.query.RRunningConfigGlobalQuery;
import com.ssyf.module.robot.domain.vo.RRunningConfigGlobalVo;
import com.ssyf.module.robot.service.RRunningConfigGlobalService;
import com.ssyf.plugs.logger.Log;
import com.ssyf.plugs.mysql.helper.PageEnhanceHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
* com.ssyf.auth.entity.RRunningConfigGlobal模型开放接口
*
* @author: auth
* @date: 2022-12-12
*/
@Api(tags="基础-运行配置")
@RestController
@RequestMapping("/auth/RRunningConfigGlobal")
public class RRunningConfigGlobalAuthController {

    @Autowired
    private RRunningConfigGlobalService baseService;

    /**
     * 根据uuid更新记录
     */
    @ApiOperation("更新运行配置")
    @PostMapping("/updateBy")
    @RequestSynchronization
    public Result updateBy(@Validated({ValidA.class}) @RequestBody RRunningConfigGlobalQuery query) {
        if(BeanUtil.isEmpty(query)){
            return Result.fail(ApiCodeUser.PARAMETER_ERROR.getCode() ,"更新数据不能为空");
        }
        this.baseService.updateBy(query);
        return Result.success();
    }

    /**
     * 根据uuid查询记录
     */
    @ApiOperation("查询运行配置详情")
    @GetMapping("/getOneBy")
    public Result<RRunningConfigGlobalVo> getOneByUid() {
        return Result.success(this.baseService.getOneBy());
    }

}