增加模版
This commit is contained in:
+101
@@ -0,0 +1,101 @@
|
||||
package com.bms.web.controller.system;
|
||||
|
||||
import java.util.List;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import com.bms.common.annotation.Log;
|
||||
import com.bms.common.core.controller.BaseController;
|
||||
import com.bms.common.core.domain.AjaxResult;
|
||||
import com.bms.common.core.page.TableDataInfo;
|
||||
import com.bms.common.enums.BusinessType;
|
||||
import com.bms.system.domain.SysFileTemplate;
|
||||
import com.bms.system.service.ISysFileTemplateService;
|
||||
|
||||
/** System file template CRUD + OSS upload/download. */
|
||||
@RestController
|
||||
@RequestMapping("/system/fileTemplate")
|
||||
public class SysFileTemplateController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ISysFileTemplateService fileTemplateService;
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:fileTemplate:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysFileTemplate query)
|
||||
{
|
||||
startPage();
|
||||
List<SysFileTemplate> list = fileTemplateService.selectSysFileTemplateList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:fileTemplate:query')")
|
||||
@GetMapping("/{templateId}")
|
||||
public AjaxResult getInfo(@PathVariable Long templateId)
|
||||
{
|
||||
return success(fileTemplateService.selectSysFileTemplateById(templateId));
|
||||
}
|
||||
|
||||
/** Meta by file code (authenticated; used by import dialogs). */
|
||||
@GetMapping("/code/{fileCode}")
|
||||
public AjaxResult getByCode(@PathVariable String fileCode)
|
||||
{
|
||||
return success(fileTemplateService.selectByFileCode(fileCode));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:fileTemplate:add')")
|
||||
@Log(title = "File template", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody SysFileTemplate row)
|
||||
{
|
||||
row.setCreateBy(getUsername());
|
||||
fileTemplateService.insertSysFileTemplate(row);
|
||||
return success(row);
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:fileTemplate:edit')")
|
||||
@Log(title = "File template", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@Validated @RequestBody SysFileTemplate row)
|
||||
{
|
||||
row.setUpdateBy(getUsername());
|
||||
return toAjax(fileTemplateService.updateSysFileTemplate(row));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:fileTemplate:remove')")
|
||||
@Log(title = "File template", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{templateIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] templateIds)
|
||||
{
|
||||
return toAjax(fileTemplateService.deleteSysFileTemplateByIds(templateIds));
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasPermi('system:fileTemplate:upload')")
|
||||
@Log(title = "File template upload", businessType = BusinessType.UPDATE)
|
||||
@PostMapping("/upload")
|
||||
public AjaxResult upload(@RequestParam("templateId") Long templateId,
|
||||
@RequestParam("file") MultipartFile file) throws Exception
|
||||
{
|
||||
return success(fileTemplateService.uploadFile(templateId, file, getUsername()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Download by file_code. Login required; no admin perm so import pages can use it.
|
||||
*/
|
||||
@GetMapping("/download/{fileCode}")
|
||||
public void download(@PathVariable String fileCode, HttpServletResponse response) throws Exception
|
||||
{
|
||||
fileTemplateService.downloadByFileCode(fileCode, response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user