package com.nantian.cloud.query.controller.jljc;

import cn.hutool.db.Page;
import com.nantian.cloud.query.entity.jljc.MultiDimensionTableRelationship;
import com.nantian.cloud.query.service.jljc.MultiDimensionTableRelationshipService;
import com.nantian.sc.cloud.common.core.util.R;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * 多维度数据查询表关系服务控制器
 *
 * @author kancy
 * @since 2022-02-17 10:46:27
 * @description 由 Mybatisplus Code Generator 创建
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/multiDimensionTableRelationship")
public class MultiDimensionTableRelationshipController{
    private final MultiDimensionTableRelationshipService multiDimensionTableRelationshipService;

    @GetMapping("/page")
    @ApiOperation(value = "分页获取元数据", notes = "分页获取元数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page", value = "分页对象", required = false, dataType = "json", paramType = "path"),
    })
    public R getAdvancedMaterialPage(Page page, MultiDimensionTableRelationship multiDimensionTableRelationship) {
        multiDimensionTableRelationship.setDelFlag("1"); //筛选未删除项
        return R.ok(multiDimensionTableRelationshipService.getPageScope(page, multiDimensionTableRelationship));
    }

    @PostMapping("/save")
    @ApiOperation(value = "新增元数据", notes = "新增元数据")
    @ApiImplicitParam(name = "multiDimensionDict", value = "元数据对象", required = true, dataType = "json", paramType = "path")
    public R save(@RequestBody MultiDimensionTableRelationship multiDimensionTableRelationship){
        return R.ok(multiDimensionTableRelationshipService.save(multiDimensionTableRelationship));
    }

    @PutMapping("/update")
    @ApiOperation(value = "修改元数据", notes = "修改元数据")
    @ApiImplicitParam(name = "multiDimensionDict", value = "元数据对象", required = true, dataType = "json", paramType = "path")
    public R updateById(@RequestBody MultiDimensionTableRelationship multiDimensionTableRelationship) {
        return R.ok(multiDimensionTableRelationshipService.updateById(multiDimensionTableRelationship));
    }

    @DeleteMapping("/deleted")
    @ApiOperation(value = "删除万家企业节能目标设定", notes = "删除万家企业节能目标设定")
    @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int", paramType = "path")
    public R removeById(@RequestBody MultiDimensionTableRelationship multiDimensionTableRelationship) {
        return R.ok(multiDimensionTableRelationshipService.removeById(multiDimensionTableRelationship.getId()));
    }

}
