package com.kcim.web;

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

import java.util.Arrays;


/**
 * 文件记录
 *
 * @author huangrui
 * @date 2021-09-01 15:49:14
 */
@RestController
@RequestMapping("filerecord")
public class FileRecordController {
    @Autowired
    private FileRecordService fileRecordService;

    /**
     * 分页查询列表
     * 查询的是
     */
    @RequestMapping("/list")
    public Result list(@RequestParam(value = "current", defaultValue = "1") Integer current,
                       @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){
		FileRecord fileRecord = fileRecordService.getById(id);
        return Result.ok(fileRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public Result save(@RequestBody FileRecord fileRecord){
		fileRecordService.save(fileRecord);
        return Result.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public Result update(@RequestBody FileRecord fileRecord){
		fileRecordService.updateById(fileRecord);
        return Result.ok();
    }

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

}
