Browse Source

1.模板管理相关接口开发
2.表修改

GouGengquan 8 months ago
parent
commit
84ecba9b51

+ 8 - 6
biz-base/src/main/java/com/dayou/controller/TmplAssetCalculateController.java

@@ -1,7 +1,10 @@
 package com.dayou.controller;
 
+import cn.dev33.satoken.annotation.SaCheckRole;
 import com.dayou.common.DropDownBoxData;
 import com.dayou.result.Result;
+import com.dayou.vo.TmplAssetCalculateDetailVO;
+import com.github.pagehelper.PageInfo;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -22,7 +25,7 @@ import java.util.List;
 @RestController
 @RequestMapping("tmplAssetCalculate")
 @Slf4j
-@CrossOrigin
+@SaCheckRole("ADMIN")
 public class TmplAssetCalculateController {
     @Autowired
     private TmplAssetCalculateService tmplAssetCalculateService;
@@ -31,8 +34,8 @@ public class TmplAssetCalculateController {
     * 资产测算表模板信息表列表
     */
     @GetMapping("/page")
-    public Result<Page<TmplAssetCalculate>> page(TmplAssetCalculate tmplAssetCalculate, Page page){
-        Page<TmplAssetCalculate> pages=tmplAssetCalculateService.selectPage(page,tmplAssetCalculate);
+    public Result<PageInfo<TmplAssetCalculate>> page(TmplAssetCalculate tmplAssetCalculate, PageInfo page){
+        PageInfo<TmplAssetCalculate> pages=tmplAssetCalculateService.selectPage(page,tmplAssetCalculate);
         return Result.build(pages);
     }
 
@@ -40,9 +43,8 @@ public class TmplAssetCalculateController {
      * 资产测算表模板信息表详情
      */
     @GetMapping("/detail/{id}")
-    public Result<TmplAssetCalculate> detail(@PathVariable Long id){
-        TmplAssetCalculate xTmplAssetCalculate =tmplAssetCalculateService.detail(id);
-        return Result.build(xTmplAssetCalculate);
+    public Result<TmplAssetCalculateDetailVO> detail(@PathVariable Long id){
+        return Result.build(tmplAssetCalculateService.detail(id));
      }
 
     /**

+ 1 - 1
biz-base/src/main/resources/application-local.yaml

@@ -33,7 +33,7 @@ mybatis-plus:
   global-config:
     db-config:
       id-type: auto
-      logic-delete-field: deleted
+      logic-delete-field: deleteStatus
       logic-delete-value: 1
       logic-not-delete-value: 0
 #分页插件

+ 9 - 0
dao/src/main/java/com/dayou/mapper/TmplAssetCalculateMapper.java

@@ -3,6 +3,8 @@ package com.dayou.mapper;
 import com.dayou.common.DropDownBoxData;
 import com.dayou.entity.TmplAssetCalculate;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.dayou.vo.TmplAssetCalculateDetailVO;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
@@ -22,4 +24,11 @@ public interface TmplAssetCalculateMapper extends BaseMapper<TmplAssetCalculate>
      */
     List<DropDownBoxData> getDropDownBoxData();
 
+    /**
+     * 根据id获取模板详细信息
+     * @param templateCalculateId 模板id
+     * @return TmplAssetCalculateDetailVO
+     */
+    TmplAssetCalculateDetailVO getTmplAssetCalculateDetailById(@Param("templateCalculateId") Long templateCalculateId);
+
 }

+ 8 - 0
dao/src/main/java/com/dayou/mapper/TmplAssetCalculateSectionMapper.java

@@ -2,6 +2,7 @@ package com.dayou.mapper;
 
 import com.dayou.entity.TmplAssetCalculateSection;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -13,4 +14,11 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface TmplAssetCalculateSectionMapper extends BaseMapper<TmplAssetCalculateSection> {
 
+    /**
+     * 根据测算表主模板id更新段落模板删除状态
+     * @param TCId 主模板id
+     * @return Boolean
+     */
+    Boolean updateDeleteStatusByTCId(@Param("TCId") Long TCId);
+
 }

+ 8 - 0
dao/src/main/resources/mapper/TmplAssetCalculateMapper.xml

@@ -34,4 +34,12 @@
           AND has_section = 1
     </select>
 
+    <!--根据id获取模板详细信息-->
+    <select id="getTmplAssetCalculateDetailById" resultType="com.dayou.vo.TmplAssetCalculateDetailVO">
+        SELECT id, calculate_name, file_name, file_url, calculate_type, has_section, update_time, tmpl_code
+        FROM tmpl_asset_calculate
+        WHERE delete_status = 0
+        AND id = #{templateCalculateId}
+    </select>
+
 </mapper>

+ 8 - 0
dao/src/main/resources/mapper/TmplAssetCalculateSectionMapper.xml

@@ -24,4 +24,12 @@
         template_report_id, section_name, section_file_name, section_file_url, tmpl_code
     </sql>
 
+    <!--根据测算表主模板id更新段落模板删除状态-->
+    <update id="updateDeleteStatusByTCId">
+        UPDATE tmpl_asset_calculate_section
+        SET delete_status = 1
+        WHERE delete_status = 0
+        AND template_calculate_id = #{TCId}
+    </update>
+
 </mapper>

+ 1 - 1
domain/src/main/java/com/dayou/entity/TmplAssetCalculateSection.java

@@ -22,7 +22,7 @@ public class TmplAssetCalculateSection extends BaseEntity implements Serializabl
     /**
      * 测算表模板id
      */
-    private Long templateReportId;
+    private Long templateCalculateId;
 
     /**
      * 测算表段落模板名称

+ 60 - 0
domain/src/main/java/com/dayou/vo/TmplAssetCalculateDetailVO.java

@@ -0,0 +1,60 @@
+package com.dayou.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.dayou.entity.TmplAssetCalculateSection;
+import lombok.Data;
+
+import java.util.Date;
+import java.util.List;
+
+@Data
+public class TmplAssetCalculateDetailVO {
+
+    /**
+     * 主键id
+     */
+    protected Long id;
+
+    /**
+     * 测算表名字
+     */
+    private String calculateName;
+
+    /**
+     * 模板文件名字
+     */
+    private String fileName;
+
+    /**
+     * 模板文件存储位置
+     */
+    private String fileUrl;
+
+    /**
+     * 测算类型
+     */
+    private String calculateType;
+
+
+    /**
+     * 是否有段落模板
+     */
+    private Boolean hasSection;
+
+    /**
+     * 模板code
+     */
+    private String tmplCode;
+
+    /**
+     * 最后更新时间
+     */
+    private Date updateTime;
+
+    /**
+     * 段落模板信息
+     */
+    List<TmplAssetCalculateSection> sectionList;
+
+}

+ 4 - 2
service/src/main/java/com/dayou/service/TmplAssetCalculateService.java

@@ -5,6 +5,8 @@ import com.dayou.entity.TmplAssetCalculate;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.dayou.vo.TmplAssetCalculateDetailVO;
+import com.github.pagehelper.PageInfo;
 
 import java.util.List;
 
@@ -18,9 +20,9 @@ import java.util.List;
  */
 public interface TmplAssetCalculateService extends IService<TmplAssetCalculate> {
 
-    Page<TmplAssetCalculate> selectPage(Page page, TmplAssetCalculate tmplAssetCalculate);
+    PageInfo<TmplAssetCalculate> selectPage(PageInfo page, TmplAssetCalculate tmplAssetCalculate);
 
-    TmplAssetCalculate detail(Long id);
+    TmplAssetCalculateDetailVO detail(Long id);
 
     Boolean add(TmplAssetCalculate tmplAssetCalculate);
 

+ 26 - 11
service/src/main/java/com/dayou/service/impl/TmplAssetCalculateServiceImpl.java

@@ -2,9 +2,14 @@ package com.dayou.service.impl;
 
 import com.dayou.common.DropDownBoxData;
 import com.dayou.entity.TmplAssetCalculate;
+import com.dayou.entity.TmplAssetCalculateSection;
 import com.dayou.mapper.TmplAssetCalculateMapper;
+import com.dayou.mapper.TmplAssetCalculateSectionMapper;
 import com.dayou.service.TmplAssetCalculateService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.dayou.vo.TmplAssetCalculateDetailVO;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -14,8 +19,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+
 import java.util.List;
 import java.util.ArrayList;
+
 import org.springframework.transaction.annotation.Transactional;
 
 /**
@@ -32,36 +39,44 @@ public class TmplAssetCalculateServiceImpl extends ServiceImpl<TmplAssetCalculat
     @Autowired
     private TmplAssetCalculateMapper tmplAssetCalculateMapper;
 
+    @Autowired
+    private TmplAssetCalculateSectionMapper tmplAssetCalculateSectionMapper;
+
     @Override
-    @SuppressWarnings("unchecked")
-    public Page<TmplAssetCalculate> selectPage(Page page,TmplAssetCalculate tmplAssetCalculate){
-        return this.page(page, new QueryWrapper<TmplAssetCalculate>(tmplAssetCalculate));
+    public PageInfo<TmplAssetCalculate> selectPage(PageInfo page, TmplAssetCalculate tmplAssetCalculate) {
+        PageHelper.startPage(page.getPageNum(), page.getPageSize());
+        PageInfo<TmplAssetCalculate> pageInfo = new PageInfo<>(this.list(new QueryWrapper<TmplAssetCalculate>(tmplAssetCalculate)));
+        return pageInfo;
     }
 
-
     @Override
-    public TmplAssetCalculate detail(Long id){
-        return this.getById(id);
+    public TmplAssetCalculateDetailVO detail(Long id) {
+        TmplAssetCalculateDetailVO detail = tmplAssetCalculateMapper.getTmplAssetCalculateDetailById(id);
+        detail.setSectionList(tmplAssetCalculateSectionMapper.selectList(new LambdaQueryWrapper<TmplAssetCalculateSection>().eq(TmplAssetCalculateSection::getTemplateCalculateId, id)));
+        return detail;
     }
 
     @Override
-    public Boolean add(TmplAssetCalculate tmplAssetCalculate){
-        return  this.save(tmplAssetCalculate);
+    public Boolean add(TmplAssetCalculate tmplAssetCalculate) {
+        return this.save(tmplAssetCalculate);
     }
 
     @Override
-    public Boolean update(TmplAssetCalculate tmplAssetCalculate){
-        return  this.updateById(tmplAssetCalculate);
+    public Boolean update(TmplAssetCalculate tmplAssetCalculate) {
+        return this.updateById(tmplAssetCalculate);
     }
 
     @Override
-    public Boolean delete(Long id){
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean delete(Long id) {
+        tmplAssetCalculateSectionMapper.updateDeleteStatusByTCId(id);
         //逻辑删除
         return this.removeById(id);
     }
 
     /**
      * 获取资产测算表的下拉框数据
+     *
      * @return List<DropDownBoxData>
      */
     @Override

+ 7 - 0
sql/update_sql.sql

@@ -206,3 +206,10 @@ CREATE TABLE `house_guaranty_process-platform`  (
     修改人:吴长林
  */
 ALTER TABLE house_guaranty_process ADD COLUMN doc_no VARCHAR(128) NOT NULL COMMENT '文档编号';
+
+/**
+  日期:2024-11-11
+  修改人:苟耕铨
+  未更新到test-env
+ */
+ALTER TABLE tmpl_asset_calculate_section CHANGE COLUMN template_report_id template_calculate_id BIGINT(20) NOT NULL COMMENT '测算表模板id';