package com.ruoyi.office.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.office.domain.TtCopyTemplate; import com.ruoyi.office.service.ITtCopyTemplateService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** * 文案模板Controller * * @author ruoyi * @date 2026-04-10 */ @RestController @RequestMapping("/office/copyTemplate") public class TtCopyTemplateController extends BaseController { @Autowired private ITtCopyTemplateService ttCopyTemplateService; /** * 查询文案模板列表 */ @PreAuthorize("@ss.hasPermi('office:copyTemplate:list')") @GetMapping("/list") public TableDataInfo list(TtCopyTemplate ttCopyTemplate) { startPage(); List list = ttCopyTemplateService.selectTtCopyTemplateList(ttCopyTemplate); return getDataTable(list); } /** * 查询所有启用的文案模板(供源码明细页动态按钮使用,无需分页权限) */ @GetMapping("/enabled") public AjaxResult listEnabled() { return success(ttCopyTemplateService.selectEnabledTemplates()); } /** * 导出文案模板列表 */ @PreAuthorize("@ss.hasPermi('office:copyTemplate:export')") @Log(title = "文案模板", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, TtCopyTemplate ttCopyTemplate) { List list = ttCopyTemplateService.selectTtCopyTemplateList(ttCopyTemplate); ExcelUtil util = new ExcelUtil(TtCopyTemplate.class); util.exportExcel(response, list, "文案模板数据"); } /** * 获取文案模板详细信息 */ @PreAuthorize("@ss.hasPermi('office:copyTemplate:query')") @GetMapping(value = "/{templateId}") public AjaxResult getInfo(@PathVariable("templateId") Long templateId) { return success(ttCopyTemplateService.selectTtCopyTemplateByTemplateId(templateId)); } /** * 新增文案模板 */ @PreAuthorize("@ss.hasPermi('office:copyTemplate:add')") @Log(title = "文案模板", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody TtCopyTemplate ttCopyTemplate) { return toAjax(ttCopyTemplateService.insertTtCopyTemplate(ttCopyTemplate)); } /** * 修改文案模板 */ @PreAuthorize("@ss.hasPermi('office:copyTemplate:edit')") @Log(title = "文案模板", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody TtCopyTemplate ttCopyTemplate) { return toAjax(ttCopyTemplateService.updateTtCopyTemplate(ttCopyTemplate)); } /** * 删除文案模板 */ @PreAuthorize("@ss.hasPermi('office:copyTemplate:remove')") @Log(title = "文案模板", businessType = BusinessType.DELETE) @DeleteMapping("/{templateIds}") public AjaxResult remove(@PathVariable Long[] templateIds) { return toAjax(ttCopyTemplateService.deleteTtCopyTemplateByTemplateIds(templateIds)); } }