Procházet zdrojové kódy

Merge branch 'dev_v2.0.1' of http://git.qmth.com.cn/wangliang/distributed-print-service into dev_v2.0.1

xiaof před 4 roky
rodič
revize
8a1cc3665e

+ 9 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/bean/dto/TemplateDto.java

@@ -25,6 +25,7 @@ public class TemplateDto {
     private String remark;
     private String createId;
     private Long createTime;
+    private String cardId;
     private List<SysOrg> orgs;
 
     public String getId() {
@@ -107,6 +108,14 @@ public class TemplateDto {
         this.createTime = createTime;
     }
 
+    public String getCardId() {
+        return cardId;
+    }
+
+    public void setCardId(String cardId) {
+        this.cardId = cardId;
+    }
+
     public List<SysOrg> getOrgs() {
         return orgs;
     }

+ 2 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/BasicTemplateService.java

@@ -23,4 +23,6 @@ public interface BasicTemplateService extends IService<BasicTemplate> {
     boolean enable(BasicTemplate template);
 
     BasicTemplate getOne(Long id);
+
+    Object readContent(Long attachmentId);
 }

+ 20 - 0
distributed-print-business/src/main/java/com/qmth/distributed/print/business/service/impl/BasicTemplateServiceImpl.java

@@ -21,6 +21,7 @@ import com.qmth.distributed.print.common.enums.ExceptionResultEnum;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
 import java.util.List;
 import java.util.Objects;
@@ -61,6 +62,15 @@ public class BasicTemplateServiceImpl extends ServiceImpl<BasicTemplateMapper, B
                 //查询适用学院
                 List<SysOrg> sysOrgs = basicTemplateOrgService.listByTypeAndTemplateId(type, Long.valueOf(m.getId()));
                 m.setOrgs(sysOrgs);
+
+                if(type.equals(TemplateTypeEnum.GENERIC.name())){
+                    QueryWrapper<ExamCard> queryWrapper = new QueryWrapper<>();
+                    queryWrapper.lambda().eq(ExamCard::getTemplateId, m.getId());
+                    List<ExamCard> examCards = examCardService.list(queryWrapper);
+                    if(!CollectionUtils.isEmpty(examCards)){
+                        m.setCardId(examCards.get(0).getId().toString());
+                    }
+                }
             });
         }
         return templateDtoIPage;
@@ -164,4 +174,14 @@ public class BasicTemplateServiceImpl extends ServiceImpl<BasicTemplateMapper, B
         return basicTemplate;
     }
 
+    @Override
+    public Object readContent(Long attachmentId) {
+        BasicAttachment attachment = basicAttachmentService.getById(attachmentId);
+        if (attachment.getType().equals(".ftl") || attachment.getType().equals(".html")) {
+            String content = commonService.readFileContent(attachment.getPath());
+            return content;
+        }
+        return null;
+    }
+
 }

+ 1 - 0
distributed-print-business/src/main/resources/db/init-table.sql

@@ -932,6 +932,7 @@ INSERT INTO `sys_privilege` VALUES (188,'考务明细查询-学生明细','/api/
 INSERT INTO `sys_privilege` VALUES (189,'卷库查询-修改','/api/admin/exam/task/paper_update','URL',42,4,'AUTH',NULL,1619502584844,1);
 INSERT INTO `sys_privilege` VALUES (190,'任务管理-重新生成pdf','/api/admin/data/task/reset_create_pdf','URL',113,2,'AUTH',NULL,1619502584844,1);
 INSERT INTO `sys_privilege` VALUES (191,'卷库查询-批量下载试卷PDF、题卡', '/api/admin/exam/task/paper_card_download_pdf', 'URL', 42, 5, 'AUTH',NULL, 1619502584844, '1');
+INSERT INTO `sys_privilege` VALUES (192,'读取模板内容', '/api/admin/basic/template/read_content', 'URL', 10, 4, 'AUTH',NULL,1619502584844, '1');
 INSERT INTO `sys_privilege` VALUES (199,'客户端','client','MENU',NULL,22,NULL,NULL,1619502252306,1);
 INSERT INTO `sys_privilege` VALUES (200,'试卷打样-查询列表','/api/admin/client/paper_try/list','URL',199,2,'AUTH',NULL,NULL,1);
 INSERT INTO `sys_privilege` VALUES (201,'试卷打样-查看/试印/重印','/api/admin/client/paper_try/print','URL',199,3,'AUTH',NULL,NULL,1);

+ 13 - 0
distributed-print/src/main/java/com/qmth/distributed/print/api/BasicTemplateController.java

@@ -94,5 +94,18 @@ public class BasicTemplateController {
         boolean isSuccess = basicTemplateService.enable(template);
         return ResultUtil.ok(isSuccess);
     }
+
+    /**
+     * 读取模板内容
+     *
+     * @param attachmentId
+     * @return
+     */
+    @ApiOperation(value = "读取模板内容")
+    @RequestMapping(value = "/read_content", method = RequestMethod.POST)
+    public Result enable(@RequestParam("attachmentId") Long attachmentId) {
+        Object content = basicTemplateService.readContent(attachmentId);
+        return ResultUtil.ok(content);
+    }
 }