package com.yunhai.campusnotice.controller.api; import com.yunhai.campusnotice.config.Config; import com.yunhai.campusnotice.service.ITemplateService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; /** * 通知模板接口(模板域)。 *

路径前缀:{@code Config.API_PATH + "/template/"}(原 notice/Template/ 三级路径已修正)。 * 写操作一律 POST(原 EditType/DelTemplate 为 GET 写操作,已 POST 化)。 */ @RestController @RequestMapping(value = Config.API_PATH + "/template/") public class TemplateController { @Autowired private ITemplateService templateService; /** * 获取模板类型列表。 */ @GetMapping("Typelist") public List> getTypelist() { return templateService.getTypelist(); } /** * 新增/编辑模板类型(原 GET EditType,已 POST 化)。 */ @PostMapping("TypeEdit") public void typeEdit( @RequestParam("typeid") Integer typeid, @RequestParam("TypeName") String typeName) { templateService.editType(typeid, typeName); } /** * 删除模板类型(原 GET DelType,已 POST 化)。 */ @PostMapping("TypeDelete") public void typeDelete(@RequestParam("typeid") Integer typeid) { templateService.delType(typeid); } /** * 分页获取模板列表。 */ @GetMapping("List") public Map list( @RequestParam("PageSize") Integer pageSize, @RequestParam("PageIndex") Integer pageIndex, @RequestParam(value = "typeid", defaultValue = "0") Integer typeid) { return templateService.getTemplatelist(pageSize, pageIndex, typeid); } /** * 新增/编辑模板。 */ @PostMapping("TemplateEdit") public void templateEdit( @RequestParam(value = "SerID", required = false) Integer serID, @RequestParam("Title") String title, @RequestParam("Contents") String contents, @RequestParam(value = "Type", required = false) Integer type, @RequestParam(value = "Cover", required = false) Integer cover) { templateService.editTemplate(serID, title, contents, type, cover); } /** * 删除模板(原 GET DelTemplate,已 POST 化)。 */ @PostMapping("TemplateDelete") public void templateDelete(@RequestParam("SerID") Integer serid) { templateService.delTemplate(serid); } /** * 获取单个模板详情。 */ @GetMapping("TemplateFirst") public Map templateFirst(@RequestParam("serid") Integer serid) { return templateService.getTemplateFist(serid); } }