bc_zhang hace 4 años
padre
commit
2e4c39a508

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

@@ -6,6 +6,8 @@ import com.github.pagehelper.PageInfo;
 import com.zglc.fm.base.Result;
 import com.zglc.fm.entity.DeleteEntity;
 import com.zglc.fm.entity.BookEntity;
+import com.zglc.fm.entity.FaultEntity;
+import com.zglc.fm.service.FaultService;
 import com.zglc.fm.service.BookService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
@@ -31,9 +33,12 @@ public class BookController {
 
     @Resource
     private final BookService bookService;
+    private FaultService faultService;
     @Autowired(required = false)
-    public BookController(BookService bookService){
+
+    public BookController(BookService bookService, FaultService faultService){
         this.bookService = bookService;
+        this.faultService = faultService;
     }
 
     @Value("${spring.article.sourcePath}")
@@ -91,15 +96,6 @@ public class BookController {
         return Result.success(bookService.listAll());
     }
 
-//    @ApiOperation("按书籍类型id列出所有")
-//    @ApiResponses({
-//            @ApiResponse(code = 0, message = "成功")
-//    })
-//    @GetMapping("listByType")
-//    public Result<List<BookEntity>> listBy(Integer typeId) {
-//        return Result.success(userService.searchAllUser(departmentId,roleId,null,null));
-//    }
-
     @ApiOperation("分页按书籍类型id筛选")
     @ApiResponses({
             @ApiResponse(code = 0, message = "成功")
@@ -110,9 +106,15 @@ public class BookController {
         return Result.success(new PageInfo<>( bookService.searchAllBook(typeId,name)));
     }
 
-
-
-
+    @ApiOperation("筛选相关故障案例")
+    @ApiResponses({
+            @ApiResponse(code = 0, message = "成功")
+    })
+    @GetMapping("relevantFault")
+    public Result<PageInfo<FaultEntity>> relevantFault(String bookName,Integer page, Integer size) {
+        PageHelper.startPage(page, size, "id desc");
+        return Result.success(new PageInfo<>( faultService.searchAllFault(bookName)));
+    }
 
     @ApiOperation("ID查找")
     @ApiResponses({

+ 4 - 0
src/main/java/com/zglc/fm/entity/FaultEntity.java

@@ -73,6 +73,10 @@ public class FaultEntity implements Serializable {
     @Column(name = "fault_time")
     private String fault_time;
 
+
+    @Column(name = "book_name")
+    private String book_name;
+
     @Column(name = "chapter")
     private String chapter;
 

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

@@ -2,7 +2,9 @@ package com.zglc.fm.service;
 
 import com.zglc.fm.base.Result;
 import com.zglc.fm.dao.BookDao;
+//import com.zglc.fm.dao.FaultDao;
 import com.zglc.fm.entity.BookEntity;
+//import com.zglc.fm.entity.FaultEntity;
 import org.springframework.stereotype.Service;
 import tk.mybatis.mapper.entity.Example;
 
@@ -14,6 +16,7 @@ import java.util.List;
 public class BookService {
 
     private BookDao bookDao;
+//    public FaultDao faultDao;
 
     public BookService(BookDao bookDao) {
         this.bookDao = bookDao;
@@ -115,4 +118,6 @@ public class BookService {
     }
 
 
+
+
 }

+ 14 - 0
src/main/java/com/zglc/fm/service/FaultService.java

@@ -97,4 +97,18 @@ public class FaultService {
         return faultDao.selectByExample(example);
     }
 
+    public List<FaultEntity> searchAllFault(String bookName) {
+
+        Example example = new Example(FaultEntity.class);
+        Example.Criteria criteria = example.createCriteria();
+        if(bookName != null)
+        {
+            criteria.andEqualTo("book_name", bookName);
+        }
+        if (criteria.isValid())
+            return faultDao.selectByExample(example);
+        else
+            return null;
+    }
+
 }

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

@@ -16,12 +16,13 @@
         <result property="file_path" column="file_path"/>
         <result property="input_time" column="input_time"/>
         <result property="fault_time" column="fault_time"/>
+        <result property="book_name" column="book_name"/>
         <result property="chapter" column="chapter"/>
         <result property="remarks" column="remarks"/>
     </resultMap>
 
     <select id="listAll" resultMap="faultMap">
-        select id,fault_name,fault_number,author,aircraft_type,major_type,description,file_path,input_time,fault_time,chapter,remarks
+        select id,fault_name,fault_number,author,aircraft_type,major_type,description,file_path,input_time,fault_time,book_name,chapter,remarks
         from t_fault
         where id > 0
     </select>
@@ -41,7 +42,7 @@
 <!--    </insert>-->
 
     <select id="findByName" parameterType="String" resultMap="faultMap">
-        select id,fault_name,fault_number,author,aircraft_type,major_type,description,file_path,input_time,fault_time,chapter,remarks from t_fault where fault_name
+        select id,fault_name,fault_number,author,aircraft_type,major_type,description,file_path,input_time,fault_time,book_name,chapter,remarks from t_fault where fault_name
         like #{fault_name}
     </select>