SysFileController.java 1.57 KB
package com.glsx.smart.controller;

import com.glsx.plat.core.web.R;
import com.glsx.smart.pojo.FileDTO;
import com.glsx.smart.service.SmartSysFileService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>Description:
 * <p>Project: chejia-smart
 *
 * @author wbh
 * @date 2021-03-15
 */
@Slf4j
@RestController
@RequestMapping("/sysFile")
@Api(value = "图片管理", tags = {"图片管理"})
public class SysFileController {

    @Autowired
    private SmartSysFileService sysFileService;

    @RequestMapping(value = "/findAll", method = {RequestMethod.GET})
    @ApiOperation(value = "查询图片")
    public R findAll(@RequestParam("type") Byte type) {
        return R.ok().data(sysFileService.findByType(type));
    }

    @RequestMapping(value = "/saveFile", method = {RequestMethod.POST})
    @ApiOperation(value = "保存图片")
    public R saveFile(@RequestBody List<FileDTO> files) {
        try {
            sysFileService.saveFile(files);
        } catch (Exception e) {
            return R.error();
        }
        return R.ok();
    }

    @RequestMapping(value = "/updateFile", method = {RequestMethod.POST})
    @ApiOperation(value = "更新图片")
    public R updateFile(@RequestBody FileDTO fileDTO) {
        try {
            sysFileService.updateFile(fileDTO);
        } catch (Exception e) {
            return R.error();
        }
        return R.ok();
    }
}