package com.zc.business.controller; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.zc.business.domain.DcInfoBoardVocabulary; import com.zc.business.enums.UniversalEnum; import com.zc.business.service.IDcInfoBoardVocabularyService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.InputStream; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.List; /** * 情报板敏感字管理Controller * * @author ruoyi * @date 2024-01-05 */ @Api(tags = {"情报板敏感字管理"}) @RestController @RequestMapping("/business/dcInfoBoardVocabulary") public class DcInfoBoardVocabularyController extends BaseController { @Autowired private IDcInfoBoardVocabularyService dcInfoBoardVocabularyService; /** * 查询情报板敏感字管理列表 */ @ApiOperation("查询情报板敏感字管理列表") // @PreAuthorize("@ss.hasPermi('business:dcInfoBoardVocabulary:list')") @GetMapping("/list") public TableDataInfo list(DcInfoBoardVocabulary dcInfoBoardVocabulary) { startPage(); List<DcInfoBoardVocabulary> list = dcInfoBoardVocabularyService.selectDcInfoBoardVocabularyList(dcInfoBoardVocabulary); return getDataTable(list); } /** * 导出情报板敏感字管理列表 */ @ApiOperation("导出情报板敏感字管理列表") // @PreAuthorize("@ss.hasPermi('business:dcInfoBoardVocabulary:export')") @Log(title = "情报板敏感字管理", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, DcInfoBoardVocabulary dcInfoBoardVocabulary) { List<DcInfoBoardVocabulary> list = dcInfoBoardVocabularyService.selectDcInfoBoardVocabularyList(dcInfoBoardVocabulary); ExcelUtil<DcInfoBoardVocabulary> util = new ExcelUtil<>(DcInfoBoardVocabulary.class); util.exportExcel(response, list, UniversalEnum.INFORMATION_BOARD_SENSITIVE_WORD_MANAGEMENT_DATA.getValue()); } @ApiOperation("导出敏感词模板") @Log(title = "导出敏感词模板", businessType = BusinessType.EXPORT) @PostMapping("/exportModel") public void exportModel(HttpServletResponse response) throws Exception { response.setContentType(UniversalEnum.DERIVE_THE_TWO_WAY_REAL_TIME_TRAFFIC_FLOW_OF_THE_WHOLE_SECTION.getValue()); response.setCharacterEncoding(UniversalEnum.LOWERCASE_UTF_8.getValue()); String fileName = URLEncoder.encode("敏感字模板.xlsx", StandardCharsets.UTF_8.toString()).replaceAll("\\+", "%20"); response.addHeader("Access-Control-Expose-Headers", "Content-Disposition,download-filename"); response.setHeader("Content-disposition", "attachment; filename="+fileName+";filename*=utf-8''"+fileName); response.setHeader("download-filename", fileName); InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(UniversalEnum.EXPORT_SENSITIVE_WORD_TEMPLATES.getValue()); try { XSSFWorkbook workbook = new XSSFWorkbook(inputStream); workbook.write(response.getOutputStream()); }catch (Exception e){ e.printStackTrace(); } } /** * 导入值敏感字 */ @ApiOperation("导入值敏感字") @PostMapping("/importVocabulary") public AjaxResult importVocabulary(MultipartFile file) throws Exception{ return dcInfoBoardVocabularyService.importVocabulary(file); } /** * 获取情报板敏感字管理详细信息 */ @ApiOperation("获取情报板敏感字管理详细信息") // @PreAuthorize("@ss.hasPermi('business:dcInfoBoardVocabulary:query')") @GetMapping(value = "/{id}") public AjaxResult getInfo(@PathVariable("id") @ApiParam(value="id", name="id", required=true) Long id) { return AjaxResult.success(dcInfoBoardVocabularyService.selectDcInfoBoardVocabularyById(id)); } /** * 新增情报板敏感字管理 */ @ApiOperation("新增情报板敏感字管理") // @PreAuthorize("@ss.hasPermi('business:dcInfoBoardVocabulary:add')") @Log(title = "情报板敏感字管理", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody DcInfoBoardVocabulary dcInfoBoardVocabulary) { return dcInfoBoardVocabularyService.insertDcInfoBoardVocabulary(dcInfoBoardVocabulary); } /** * 修改情报板敏感字管理 */ @ApiOperation("修改情报板敏感字管理") // @PreAuthorize("@ss.hasPermi('business:dcInfoBoardVocabulary:edit')") @Log(title = "情报板敏感字管理", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody DcInfoBoardVocabulary dcInfoBoardVocabulary) { return dcInfoBoardVocabularyService.updateDcInfoBoardVocabulary(dcInfoBoardVocabulary); } /** * 删除情报板敏感字管理 */ @ApiOperation("删除情报板敏感字管理") // @PreAuthorize("@ss.hasPermi('business:dcInfoBoardVocabulary:remove')") @Log(title = "情报板敏感字管理", businessType = BusinessType.DELETE) @DeleteMapping("/{id}") public AjaxResult remove(@PathVariable @ApiParam(value="id", name="id", required=true) Long id) { return toAjax(dcInfoBoardVocabularyService.deleteDcInfoBoardVocabularyById(id)); } /** * 检查情报板是否含有敏感字 */ @ApiOperation("检查情报板是否含有敏感字") @GetMapping("/checkBoardContent") public AjaxResult checkBoardContent(String content) { return dcInfoBoardVocabularyService.checkBoardContent(content); } }