linzhijie
2021-03-11 93af1c6ffb9ae0e894689ad3a37b548e57d54cff
src/main/java/com/ots/project/exam/controller/TLibraryCodeController.java
@@ -1,4 +1,5 @@
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;
@@ -22,31 +23,43 @@
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());
@@ -54,7 +67,10 @@
        }
        return getDataTable(list);
    }
    /**
     * 导出报告字典列表
     */
    @RequiresPermissions("exam:librarycode:export")
    @PostMapping("/export")
    @ResponseBody
@@ -63,12 +79,18 @@
        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")
@@ -82,7 +104,10 @@
        CacheServiceFactory.getInstance().reLoad();
        return result;
    }
    /**
     * 修改报告字典
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        TLibraryCode tLibraryCode = tLibraryCodeService.selectTLibraryCodeById(id);
@@ -90,7 +115,10 @@
        mmap.put("tLibraryCode", tLibraryCode);
        return prefix + "/edit";
    }
    /**
     * 修改保存报告字典
     */
    @RequiresPermissions("exam:librarycode:edit")
    @Log(title = "报告字典", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
@@ -100,11 +128,15 @@
            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")
@@ -112,6 +144,7 @@
    public AjaxResult remove(String ids) {
        return toAjax(tLibraryCodeService.deleteTLibraryCodeByIds(ids));
    }
    @Log(title = "报告字典导入", businessType = BusinessType.IMPORT)
    @RequiresPermissions("exam:librarycode:import")
    @PostMapping("/importData")
@@ -134,16 +167,18 @@
        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;
    }