package com.qmth.paper.library.api;


import com.qmth.boot.api.constant.ApiConstant;
import com.qmth.paper.library.common.entity.BasicField;
import com.qmth.paper.library.common.service.BasicFieldService;
import com.qmth.paper.library.common.contant.ApiPrefixConstant;
import com.qmth.paper.library.common.util.Result;
import com.qmth.paper.library.common.util.ResultUtil;
import io.swagger.annotations.*;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 字段管理 前端控制器
 * </p>
 */
@Api(tags = "字段管理Controller")
@RestController
@RequestMapping(ApiConstant.DEFAULT_URI_PREFIX + ApiPrefixConstant.PREFIX_BASIC)
@Validated
public class BasicFieldController {

    @Resource
    private BasicFieldService basicFieldService;

    @ApiOperation(value = "查询")
    @PostMapping("/field/list")
    @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = Result.class)})
    public Result list() {
        return ResultUtil.ok(basicFieldService.listData());
    }

    @ApiOperation(value = "保存")
    @PostMapping("/field/save")
    @ApiResponses({@ApiResponse(code = 200, message = "保存成功", response = Result.class)})
    public Result pictureUpload(@RequestBody List<BasicField> list) {
        return ResultUtil.ok(basicFieldService.savaData(list));
    }

}
