ソースを参照

图书详情和预约用户列表

5 年 前
コミット
85f882d63b

+ 14 - 2
bms/pom.xml

@@ -44,10 +44,22 @@
             <artifactId>spring-boot-starter-test</artifactId>
             <scope>test</scope>
         </dependency>
+        <!-- pagehelper整合mybatis-plus-->
+        <!--Pagehelper 依赖 5.1.10 版本,需要去掉 mybatis 依赖,否则会和 mybatis plus 冲突-->
         <dependency>
             <groupId>com.github.pagehelper</groupId>
-            <artifactId>pagehelper</artifactId>
-            <version>4.1.0</version>  <!--我这里用的是4.1.0版本-->
+            <artifactId>pagehelper-spring-boot-starter</artifactId>
+            <version>1.2.12</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>org.mybatis</groupId>
+                    <artifactId>mybatis</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>org.mybatis</groupId>
+                    <artifactId>mybatis-spring</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>
 
         <!-- mybatis-plus依赖 -->

+ 0 - 13
bms/src/main/java/com/hssx/bms/BmsApplication.java

@@ -15,17 +15,4 @@ public class BmsApplication {
     public static void main(String[] args) {
         SpringApplication.run(BmsApplication.class, args);
     }
-
-    //配置分页插件
-    @Bean
-    public PageHelper pageHelper(){
-        PageHelper pageHelper = new PageHelper();
-        Properties properties = new Properties();
-        properties.setProperty("offsetAsPageNum","true");
-        properties.setProperty("rowBoundsWithCount","true");
-        properties.setProperty("reasonable","true");
-        properties.setProperty("dialect","mysql");    //配置mysql数据库的方言
-        pageHelper.setProperties(properties);
-        return pageHelper;
-    }
 }

+ 1 - 1
bms/src/main/java/com/hssx/bms/controller/BookController.java

@@ -129,7 +129,7 @@ public class BookController {
     @ResponseBody
     public HttpRespMsg detail(Book book){
         HttpRespMsg msg = new HttpRespMsg();
-        msg.data = bookService.getById(book.getId());
+        msg = bookService.getBookDetailById(book.getId());
         return msg;
     }
 

+ 1 - 1
bms/src/main/java/com/hssx/bms/controller/UserAppointmentController.java

@@ -40,7 +40,7 @@ public class UserAppointmentController {
     @RequestMapping("/list")
     @ResponseBody
     public HttpRespMsg list(SystemUser user,PageUtil page) {
-        HttpRespMsg msg = userAppointmentService.getList(user,page);
+        HttpRespMsg msg = userAppointmentService.getAppointmentList(user,page);
         return msg;
     }
 

+ 27 - 0
bms/src/main/java/com/hssx/bms/entity/vo/BookVO.java

@@ -0,0 +1,27 @@
+package com.hssx.bms.entity.vo;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.hssx.bms.entity.Book;
+import com.hssx.bms.entity.BookCategory;
+import com.hssx.bms.entity.BookPage;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-10-16
+ */
+@Data
+public class BookVO extends Book {
+    private List<BookCategory> categories;
+    private List<BookPage> bookPages;
+}

+ 1 - 0
bms/src/main/java/com/hssx/bms/entity/vo/UserAppointmentVO.java

@@ -12,4 +12,5 @@ import lombok.Data;
 @Data
 public class UserAppointmentVO extends UserAppointment {
     private String timeDate;
+    private String institutionName;
 }

+ 3 - 0
bms/src/main/java/com/hssx/bms/mapper/BookMapper.java

@@ -2,6 +2,8 @@ package com.hssx.bms.mapper;
 
 import com.hssx.bms.entity.Book;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.hssx.bms.entity.vo.BookVO;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * <p>
@@ -13,4 +15,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface BookMapper extends BaseMapper<Book> {
 
+    BookVO selectDetailById(@Param("id") String id);
 }

+ 6 - 0
bms/src/main/java/com/hssx/bms/mapper/UserAppointmentMapper.java

@@ -1,7 +1,12 @@
 package com.hssx.bms.mapper;
 
+import com.hssx.bms.entity.SystemUser;
 import com.hssx.bms.entity.UserAppointment;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.hssx.bms.entity.vo.UserAppointmentVO;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,4 +18,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  */
 public interface UserAppointmentMapper extends BaseMapper<UserAppointment> {
 
+    List<UserAppointmentVO> selectAppointmentList(@Param("user") SystemUser user);
 }

+ 2 - 0
bms/src/main/java/com/hssx/bms/service/BookService.java

@@ -21,4 +21,6 @@ public interface BookService extends IService<Book> {
     HttpRespMsg getList(PageUtil page);
 
     HttpRespMsg del(String id);
+
+    HttpRespMsg getBookDetailById(String id);
 }

+ 2 - 0
bms/src/main/java/com/hssx/bms/service/UserAppointmentService.java

@@ -20,4 +20,6 @@ public interface UserAppointmentService extends IService<UserAppointment> {
     HttpRespMsg getList(SystemUser user,PageUtil page);
 
     HttpRespMsg acceptAndUpdateDate(UserAppointmentVO userAppointment);
+
+    HttpRespMsg getAppointmentList(SystemUser user, PageUtil page);
 }

+ 9 - 0
bms/src/main/java/com/hssx/bms/service/impl/BookServiceImpl.java

@@ -7,6 +7,7 @@ import com.hssx.bms.entity.Book;
 import com.hssx.bms.entity.BookCategory;
 import com.hssx.bms.entity.BookPage;
 import com.hssx.bms.entity.InstitutionalInformation;
+import com.hssx.bms.entity.vo.BookVO;
 import com.hssx.bms.mapper.BookCategoryMapper;
 import com.hssx.bms.mapper.BookMapper;
 import com.hssx.bms.mapper.BookPageMapper;
@@ -89,4 +90,12 @@ public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements Bo
         bookCategoryMapper.delete(new QueryWrapper<BookCategory>().eq("book_id",id));
         return msg;
     }
+
+    @Override
+    public HttpRespMsg getBookDetailById(String id) {
+        HttpRespMsg msg = new HttpRespMsg();
+        BookVO detail = bookMapper.selectDetailById(id);
+        msg.data = detail;
+        return msg;
+    }
 }

+ 10 - 0
bms/src/main/java/com/hssx/bms/service/impl/UserAppointmentServiceImpl.java

@@ -70,4 +70,14 @@ public class UserAppointmentServiceImpl extends ServiceImpl<UserAppointmentMappe
         userAppointmentMapper.updateById(userAppointment);
         return msg;
     }
+
+    @Override
+    public HttpRespMsg getAppointmentList(SystemUser user, PageUtil page) {
+        HttpRespMsg msg = new HttpRespMsg();
+        PageHelper.startPage(page.getPageNum(),page.getPageSize());
+        List<UserAppointmentVO> list = userAppointmentMapper.selectAppointmentList(user);
+        PageInfo<UserAppointmentVO> pageInfo = new PageInfo<>(list);
+        msg.data = pageInfo;
+        return msg;
+    }
 }

+ 35 - 1
bms/src/main/resources/mapper/BookMapper.xml

@@ -11,10 +11,44 @@
         <result column="descrip" property="descrip" />
         <result column="read_cnt" property="readCnt" />
     </resultMap>
+    <resultMap id="BaseResultMapVO" type="com.hssx.bms.entity.vo.BookVO">
+        <result column="id" property="id" />
+        <result column="name" property="name" />
+        <result column="cover" property="cover" />
+        <result column="author" property="author" />
+        <result column="descrip" property="descrip" />
+        <result column="read_cnt" property="readCnt" />
+        <collection property="bookPages" ofType="com.hssx.bms.entity.BookPage">
+                <result column="bpid" property="id" />
+                <result column="book_id" property="bookId" />
+                <result column="bppagenum" property="pageNum" />
+                <result column="file" property="file" />
+        </collection>
+        <collection property="categories" ofType="com.hssx.bms.entity.BookCategory">
+                <result column="bcid" property="id" />
+                <result column="book_id" property="bookId" />
+                <result column="rank" property="rank" />
+                <result column="bcname" property="name" />
+                <result column="page_num" property="pageNum" />
+        </collection>
+    </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id, name, cover, author, descrip, read_cnt
     </sql>
-
+    
+    <select id="selectDetailById" resultMap="BaseResultMapVO">
+        select
+             b.id, b.name, b.cover, b.author, b.descrip, b.read_cnt,
+             bp.id bpid,bp.page_num bppagenum, bp.file,
+             bc.id bcid, bc.rank, bc.name bcname, bc.page_num
+        from book b
+        left join book_category bc
+        on bc.book_id = b.id
+        left join book_page bp
+        on bp.book_id = b.id
+        where
+          b.id = #{id}
+    </select>
 </mapper>

+ 26 - 0
bms/src/main/resources/mapper/UserAppointmentMapper.xml

@@ -16,10 +16,36 @@
         <result column="content" property="content" />
         <result column="stage" property="stage" />
     </resultMap>
+    <resultMap id="BaseResultMapVO" type="com.hssx.bms.entity.vo.UserAppointmentVO">
+        <id column="id" property="id" />
+        <result column="user_id" property="userId" />
+        <result column="org_id" property="orgId" />
+        <result column="appoint_date" property="appointDate" />
+        <result column="time" property="time" />
+        <result column="name" property="name" />
+        <result column="mobile" property="mobile" />
+        <result column="indate" property="indate" />
+        <result column="age" property="age" />
+        <result column="content" property="content" />
+        <result column="stage" property="stage" />
+        <result column="institutionName" property="institutionName" />
+    </resultMap>
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id, user_id, org_id, appoint_date, time, name, mobile, indate, age, content, stage
     </sql>
 
+    <select id="selectAppointmentList" resultMap="BaseResultMap">
+        select
+         ua.id, ua.user_id, ua.org_id, ua.appoint_date, ua.time,
+         ua.name, ua.mobile, ua.indate, ua.age, ua.content, ua.stage,
+         ii.name institutionName
+         from
+          user_appointment ua
+          left join institutional_information ii
+          on ii.id = ua.org_id
+          where ii.sys_id = #{user.id}
+    </select>
+
 </mapper>