|
@@ -1,12 +1,18 @@
|
|
package com.gqy.document.service.impl;
|
|
package com.gqy.document.service.impl;
|
|
|
|
|
|
|
|
+import com.gqy.common.core.domain.AjaxResult;
|
|
|
|
+import com.gqy.common.core.domain.AjaxResultCQY;
|
|
import com.gqy.document.domain.DcTemplate;
|
|
import com.gqy.document.domain.DcTemplate;
|
|
|
|
+import com.gqy.document.domain.DcTemplateCategory;
|
|
|
|
+import com.gqy.document.domain.TemplateCategory;
|
|
import com.gqy.document.mapper.DcTemplateMapper;
|
|
import com.gqy.document.mapper.DcTemplateMapper;
|
|
import com.gqy.document.service.IDcTemplateService;
|
|
import com.gqy.document.service.IDcTemplateService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 模板服务实现
|
|
* 模板服务实现
|
|
@@ -21,4 +27,55 @@ public class DcTemplateServiceImpl implements IDcTemplateService {
|
|
public List<DcTemplate> selectTemplateList(String name, Integer category_id, Integer status) {
|
|
public List<DcTemplate> selectTemplateList(String name, Integer category_id, Integer status) {
|
|
return dcTemplateMapper.selectTemplateList(name, category_id, status);
|
|
return dcTemplateMapper.selectTemplateList(name, category_id, status);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取模板详细信息
|
|
|
|
+ * 包括模板基本信息和关联的分类信息
|
|
|
|
+ *
|
|
|
|
+ * @param id 模板ID
|
|
|
|
+ * @return 返回组装后的模板信息,格式如下:
|
|
|
|
+ */
|
|
|
|
+ public AjaxResultCQY getInfo(Long id) {
|
|
|
|
+ // 1. 查询模板基本信息
|
|
|
|
+ DcTemplate template = dcTemplateMapper.selectTemplateById(id);
|
|
|
|
+ if (template == null) {
|
|
|
|
+ return AjaxResultCQY.error("模板不存在");
|
|
|
|
+ }
|
|
|
|
+ // 2. 查询关联的分类信息
|
|
|
|
+ DcTemplateCategory category = null;
|
|
|
|
+ if (template.getCategory_id() != null) {
|
|
|
|
+ category = dcTemplateMapper.selectTemplateCategoryById(Long.valueOf(template.getCategory_id()));
|
|
|
|
+ }
|
|
|
|
+ // 3. 构建返回数据结构
|
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
|
+ // 3.1 设置模板基本信息
|
|
|
|
+ result.put("id", template.getId());
|
|
|
|
+ result.put("code", template.getCode());
|
|
|
|
+ result.put("name", template.getName());
|
|
|
|
+ result.put("lay_id", template.getLay_id());
|
|
|
|
+ result.put("intro", template.getIntro());
|
|
|
|
+ result.put("type", template.getType());
|
|
|
|
+ result.put("category_id", template.getCategory_id());
|
|
|
|
+ result.put("content", template.getContent());
|
|
|
|
+ result.put("attrs", template.getAttrs()); // JSON格式的属性配置
|
|
|
|
+ result.put("createTime", template.getCreate_time());
|
|
|
|
+ result.put("status", template.getStatus());
|
|
|
|
+
|
|
|
|
+ // 3.2 设置分类信息(如果存在)
|
|
|
|
+ if (category != null) {
|
|
|
|
+ Map<String, Object> categoryMap = new HashMap<>();
|
|
|
|
+ categoryMap.put("id", category.getId());
|
|
|
|
+ categoryMap.put("intro", category.getIntro());
|
|
|
|
+ categoryMap.put("name", category.getName());
|
|
|
|
+ categoryMap.put("createTime", category.getCreate_time());
|
|
|
|
+ categoryMap.put("status", category.getStatus());
|
|
|
|
+ categoryMap.put("parent_id", category.getParent_id());
|
|
|
|
+ result.put("category", categoryMap);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 4. 返回成功结果
|
|
|
|
+ return AjaxResultCQY.success(result);
|
|
|
|
+ }
|
|
}
|
|
}
|