Files
RuoYi-Vue/ruoyi-office/src/main/java/com/ruoyi/office/controller/TtCopyTemplateController.java
王鹏 6940541216 feat: 新增文案模板管理功能,源码明细页按钮支持动态配置
- 新增 tt_copy_template 表及 CRUD 后端接口
- 新增文案模板管理页面,支持 {变量} 占位符动态替换
- 源码明细页复制按钮由硬编码改为数据库驱动
- 支持占位符:codeName、projectCode、projectName、codeDesc、codeEnvironment、codeTechnology、diskLink、screenshots

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-10 19:20:32 +08:00

106 lines
3.9 KiB
Java

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<TtCopyTemplate> 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<TtCopyTemplate> list = ttCopyTemplateService.selectTtCopyTemplateList(ttCopyTemplate);
ExcelUtil<TtCopyTemplate> util = new ExcelUtil<TtCopyTemplate>(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));
}
}