| | |
| | | package com.ots.project.exam.controller; |
| | | |
| | | import com.ots.common.utils.file.FileUploadUtils; |
| | | import com.ots.common.utils.poi.ExcelUtil; |
| | | import com.ots.framework.aspectj.lang.annotation.Log; |
| | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 报告字典Controller |
| | | * |
| | | * @author ots |
| | | * @date 2020-03-24 |
| | | */ |
| | | @Controller |
| | | @Slf4j |
| | | @RequestMapping("/exam/librarycode") |
| | | public class TLibraryCodeController extends BaseController { |
| | | private String prefix = "exam/librarycode"; |
| | | |
| | | @Autowired |
| | | private ITLibraryCodeService tLibraryCodeService; |
| | | |
| | | @RequiresPermissions("exam:librarycode:view") |
| | | @GetMapping() |
| | | public String librarycode() { |
| | | return prefix + "/librarycode"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询报告字典列表 |
| | | */ |
| | | @RequiresPermissions("exam:librarycode:list") |
| | | @PostMapping("/list") |
| | | @ResponseBody |
| | | public TableDataInfo list(TLibraryCode tLibraryCode) { |
| | | startPage(); |
| | | List<TLibraryCode> list = tLibraryCodeService.selectTLibraryCodeList(tLibraryCode); |
| | | |
| | | // 展示图片 |
| | | for (TLibraryCode tLibraryCodeTemp : list) { |
| | | if (StringUtils.isNotEmpty(tLibraryCodeTemp.getIcon())) { |
| | | tLibraryCodeTemp.setIcon(EssConfig.getHttpProfilePath() +"/upload" + tLibraryCodeTemp.getIcon()); |
| | |
| | | } |
| | | return getDataTable(list); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出报告字典列表 |
| | | */ |
| | | @RequiresPermissions("exam:librarycode:export") |
| | | @PostMapping("/export") |
| | | @ResponseBody |
| | |
| | | ExcelUtil<TLibraryCode> util = new ExcelUtil<TLibraryCode>(TLibraryCode.class); |
| | | return util.exportExcel(list, "librarycode"); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增报告字典 |
| | | */ |
| | | @GetMapping("/add") |
| | | public String add() { |
| | | return prefix + "/add"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新增保存报告字典 |
| | | */ |
| | | @RequiresPermissions("exam:librarycode:add") |
| | | @Log(title = "报告字典", businessType = BusinessType.INSERT) |
| | | @PostMapping("/add") |
| | |
| | | CacheServiceFactory.getInstance().reLoad(); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改报告字典 |
| | | */ |
| | | @GetMapping("/edit/{id}") |
| | | public String edit(@PathVariable("id") Long id, ModelMap mmap) { |
| | | TLibraryCode tLibraryCode = tLibraryCodeService.selectTLibraryCodeById(id); |
| | |
| | | mmap.put("tLibraryCode", tLibraryCode); |
| | | return prefix + "/edit"; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改保存报告字典 |
| | | */ |
| | | @RequiresPermissions("exam:librarycode:edit") |
| | | @Log(title = "报告字典", businessType = BusinessType.UPDATE) |
| | | @PostMapping("/edit") |
| | |
| | | String ufi = FileUploadUtils.upload(EssConfig.getUploadPath(), tLibraryCode.getIconFile()); |
| | | tLibraryCode.setIcon(ufi.split("profile/upload")[1]); |
| | | } |
| | | |
| | | AjaxResult result = toAjax(tLibraryCodeService.updateTLibraryCode(tLibraryCode)); |
| | | CacheServiceFactory.getInstance().reLoad(); |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 删除报告字典 |
| | | */ |
| | | @RequiresPermissions("exam:librarycode:remove") |
| | | @Log(title = "报告字典", businessType = BusinessType.DELETE) |
| | | @PostMapping("/remove") |
| | |
| | | public AjaxResult remove(String ids) { |
| | | return toAjax(tLibraryCodeService.deleteTLibraryCodeByIds(ids)); |
| | | } |
| | | |
| | | @Log(title = "报告字典导入", businessType = BusinessType.IMPORT) |
| | | @RequiresPermissions("exam:librarycode:import") |
| | | @PostMapping("/importData") |
| | |
| | | List<TLibraryCode> list = libraryCodes.stream().filter(item -> { |
| | | return StringUtils.isNotBlank(item.getLibraryCode()); |
| | | }).collect(Collectors.toList()); |
| | | |
| | | String message = tLibraryCodeService.importLibraryCodes(list, updateSupport); |
| | | CacheServiceFactory.getInstance().reLoad(); |
| | | return AjaxResult.success(message); |
| | | } |
| | | |
| | | @RequiresPermissions("exam:librarycode:import") |
| | | @GetMapping("/importTemplate") |
| | | @ResponseBody |
| | | public AjaxResult importTemplate() { |
| | | ExcelUtil<TLibraryCode> util = new ExcelUtil<>(TLibraryCode.class); |
| | | AjaxResult result = util.importTemplateExcel("报告字典内容(Report Library Entries)"); |
| | | AjaxResult result = util.importTemplateExcel("报告字典数据"); |
| | | CacheServiceFactory.getInstance().reLoad(); |
| | | return result; |
| | | } |