package com.kcim.web;

import com.kcim.common.util.Result;
import com.kcim.dao.model.ReportRelation;
import com.kcim.service.ReportRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;


/**
 * 报表对应项目设置关系
 *
 * @author huangrui
 * @date 2021-08-03 13:53:52
 */
@RestController
@RequestMapping("/reportrelation")
public class ReportRelationController {
    @Autowired
    private ReportRelationService reportRelationService;

    /**
     * 分页查询列表
     */
//    @RequestMapping("/list")
//    public Result list(@RequestParam(defaultValue = "1", value = "page") Integer page,
//                       @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){
//        User user = (User) SecurityUtils.getSubject().getPrincipal();
//        return Result.ok();
//    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public Result info(@PathVariable("id") Long id){
		ReportRelation reportRelation = reportRelationService.getById(id);
        return Result.ok(reportRelation);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody ReportRelation reportRelation){
		reportRelationService.save(reportRelation);
        return Result.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody ReportRelation reportRelation){
		reportRelationService.updateById(reportRelation);
        return Result.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public Result delete(@RequestBody Long[] ids){
        reportRelationService.deleteByIds(Arrays.asList(ids));
        return Result.ok();
    }

}
