bc_zhang %!s(int64=4) %!d(string=hai) anos
pai
achega
0aa16c3564

+ 7 - 7
src/main/java/com/zglc/fm/controller/BookController.java

@@ -188,18 +188,18 @@ public class BookController {
     @PostMapping("add")
     public Result<String> add(@RequestBody BookEntity data){return  bookService.add(data);}
 
-    @ApiOperation("增添文档目录")
-    @ApiResponses({
-            @ApiResponse(code = 0, message = "成功")
-    })
-    @PostMapping("addDoccatalogue")
-    public Result<String> addDoccatalogue(@RequestParam Integer id) throws Exception {return  bookService.addDoccatalogue(id);}
+//    @ApiOperation("增添文档目录")
+//    @ApiResponses({
+//            @ApiResponse(code = 0, message = "成功")
+//    })
+//    @PostMapping("addDoccatalogue")
+//    public Result<String> addDoccatalogue(@RequestParam Integer id) throws Exception {return  bookService.addDoccatalogue(id);}
 
 
     @ApiOperation("列出文档目录")
     @ApiResponses({        @ApiResponse(code = 0, message = "成功")})
     @GetMapping("listAllDoccatalogue")
-    public Result<List<CatalogueEntity>> listAllDoccatalogue(Integer bookId) {
+    public Result<List<CatalogueEntity>> listAllDoccatalogue(Integer bookId) throws Exception {
         return Result.success( bookService.listAllDoccatalogue(bookId));
     }
 

+ 7 - 0
src/main/java/com/zglc/fm/entity/BookEntity.java

@@ -90,5 +90,12 @@ public class BookEntity implements Serializable {
      */
     @Column(name = "remarks")
     private String remarks;
+
+    /**
+     * is_catalogue
+     */
+    @Column(name = "is_catalogue")
+    private Integer is_catalogue;
+
 }
 

+ 17 - 5
src/main/java/com/zglc/fm/service/BookService.java

@@ -7,6 +7,7 @@ import com.zglc.fm.entity.BookEntity;
 //import com.zglc.fm.entity.FaultEntity;
 import com.zglc.fm.entity.CatalogueEntity;
 import com.zglc.fm.utils.DocToPdf;
+import com.zglc.fm.utils.ExcelUtils;
 import com.zglc.fm.utils.FileTypeUtil;
 import org.springframework.stereotype.Service;
 import tk.mybatis.mapper.entity.Example;
@@ -113,12 +114,23 @@ public class BookService {
         return bookDao.findByName("%" + name + "%");
     }
 
-    public List<CatalogueEntity> listAllDoccatalogue(Integer bookId) {
+    public List<CatalogueEntity> listAllDoccatalogue(Integer bookId) throws Exception {
 //        return catalogueDao.listAllDoccatalogue(bookId);
-        Example example = new Example(CatalogueEntity.class);
-        Example.Criteria criteria = example.createCriteria();
-        criteria.andEqualTo("book_id", bookId);
-        return catalogueDao.selectByExample(example);
+        BookEntity data = bookDao.selectByPrimaryKey(bookId);
+        if (data.getFile_path().endsWith(ExcelUtils.DOC) || data.getFile_path().endsWith(ExcelUtils.DOCX)){
+            if (data.getIs_catalogue()!=1){
+                addDoccatalogue(bookId);
+                data.setIs_catalogue(1);
+                edit(data);
+            }
+            Example example = new Example(CatalogueEntity.class);
+            Example.Criteria criteria = example.createCriteria();
+            criteria.andEqualTo("book_id", bookId);
+            return catalogueDao.selectByExample(example);
+        }else
+        {
+            return null;
+        }
     }
 
     public BookEntity getOutline(Integer id) {

+ 3 - 2
src/main/resources/mapping/BookDao.xml

@@ -18,10 +18,11 @@
         <result property="img" column="img"/>
         <result property="input_time" column="input_time"/>
         <result property="remarks" column="remarks"/>
+        <result property="is_catalogue" column="is_catalogue"/>
     </resultMap>
 
     <select id="listAll" resultMap="bookMap">
-        select id,book_name,aircraft_type,major_type,type_id,type_name,description,author,publish_time,file_path,img,input_time,remarks
+        select *
         from t_book
         where id > 0
     </select>
@@ -41,7 +42,7 @@
 <!--    </insert>-->
 
     <select id="findByName" parameterType="String" resultMap="bookMap">
-        select id,book_name,aircraft_type,major_type,type_id,type_name,description,author,publish_time,file_path,img,input_time,remarks from t_book where book_name
+        select * from t_book where book_name
         like #{book_name}
     </select>