package org.nl.system.controller.generator;


import cn.dev33.satoken.annotation.SaIgnore;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.nl.system.service.generator.ICodeGenConfigService;
import org.nl.system.service.generator.dao.CodeGenConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 代码生成配置表 前端控制器
 * </p>
 *
 * @author lyd
 * @since 2023-05-03
 */
@SaIgnore
@RestController
@Api(tags = "系统：代码生成管理")
@RequestMapping("api/genConfig")
public class CodeGenConfigController {

    @Autowired
    private ICodeGenConfigService genConfigService;

    @ApiOperation("查询表数据")
    @GetMapping(value = "/{tableName}")
    public ResponseEntity<Object> query(@PathVariable String tableName){
        return new ResponseEntity<>(genConfigService.findByTableName(tableName), HttpStatus.OK);
    }

    @ApiOperation("修改")
    @PutMapping
    public ResponseEntity<Object> update(@Validated @RequestBody CodeGenConfig genConfig){
        return new ResponseEntity<>(genConfigService.update(genConfig.getTable_name(), genConfig),HttpStatus.OK);
    }
}

