package com.zcloud.modules.sys.controller;

import com.zcloud.common.annotation.SysLog;
import com.zcloud.common.utils.PageUtils;
import com.zcloud.common.utils.R;
import com.zcloud.modules.sys.entity.BusImgfilesEntity;
import com.zcloud.modules.sys.service.BusImgfilesService;
import com.zcloud.modules.sys.controller.AbstractController;
import com.zcloud.modules.sys.vo.TemporaryVo;
import io.swagger.annotations.ApiParam;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

/**
 * @Author fangjiakai
 * @Desc 图片附件(BusImgfiles)表控制层
 * @Date 2023-10-19 15:09:20
 */
@Api(tags = "图片附件")
@RestController
@ApiIgnore
@RequestMapping("busImgfiles")
public class BusImgfilesController extends AbstractController {

    @Autowired
    private BusImgfilesService busImgfilesService;

    @ApiOperation("临时图片上传")
    @PostMapping("/uploadTemporary")
    public TemporaryVo uploadTemporary(@ApiParam("图片文件")
                                        @RequestPart("file") MultipartFile file) throws Exception {
        return busImgfilesService.uploadTemporary(file);
    }

    @ApiOperation("图片附件-新增数据")
    @SysLog("图片附件-新增数据")
    @PostMapping("/save")
    public R insert(@RequestBody BusImgfilesEntity param) {
        busImgfilesService.save(param);

        return R.ok();
    }


    @ApiOperation("图片附件-根据ID查详情")
    @SysLog("图片附件-根据ID查详情")
    @PostMapping("/info")
    public R info(@RequestBody BusImgfilesEntity param) {
        BusImgfilesEntity busImgfiles = busImgfilesService.getById(param.getImgfilesId());
        return R.ok().put("busImgfiles", busImgfiles);
    }

}
