Ver código fonte

系统用户登录

5 anos atrás
pai
commit
1c3a061615

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

@@ -0,0 +1,54 @@
+package com.hssx.bms.controller;
+
+
+import com.hssx.bms.entity.Book;
+import com.hssx.bms.service.BookService;
+import com.hssx.bms.until.HttpRespMsg;
+import com.hssx.bms.until.PageUtil;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * @author 吴涛涛
+ * @since 2019-10-16
+ */
+@Controller
+@RequestMapping("/book")
+public class BookController {
+
+    @Autowired
+    private BookService bookService;
+    /**
+     * 图书信息的录入
+     * 参数:name 名称,author 作者,descrip 描述
+     *      file 封面文件(可不传)
+     * 修改时需要:id 图书id
+     * @return
+     */
+    @ApiOperation(value = "图书信息的录入", notes = "图书信息的录入")
+    @RequestMapping("/addOrUpdateBook")
+    @ResponseBody
+    public HttpRespMsg addOrUpdateBook(Book book, @RequestParam(required = false) MultipartFile file){
+        HttpRespMsg msg = bookService.addOrUpdateBook(book,file);
+        return msg;
+    }
+
+    /**
+     * 图书信息的列表
+     * 参数:
+     * @return
+     */
+    @ApiOperation(value = "图书信息的列表", notes = "图书信息的列表方法")
+    @RequestMapping("/list")
+    @ResponseBody
+    public HttpRespMsg list(PageUtil page){
+        HttpRespMsg msg = bookService.getList(page);
+        return msg;
+    }
+}
+

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

@@ -29,8 +29,6 @@ import java.util.List;
 public class InstitutionalInformationController {
     @Autowired
     private InstitutionalInformationService institutionalService;
-//    @Autowired
-//    private SystemUserService systemUserService;
     @Autowired
     private InstitutionalPicService institutionalPicService;
 
@@ -71,7 +69,7 @@ public class InstitutionalInformationController {
     @ResponseBody
     public HttpRespMsg updateInstitutionPics(Integer id, @RequestParam(required = false) MultipartFile[] file){
         HttpRespMsg msg = institutionalPicService.institutionalPicService(id,file);
-        return null;
+        return msg;
     }
     /**
      * 教育机构信息的背景图片的删除

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

@@ -1,6 +1,7 @@
 package com.hssx.bms.controller;
 
 
+import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.web.bind.annotation.RestController;
@@ -13,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
  * @author 吴涛涛
  * @since 2019-10-15
  */
-@RestController
+@Controller
 @RequestMapping("/institutionalpic")
 public class InstitutionalPicController {
 

+ 108 - 0
bms/src/main/java/com/hssx/bms/entity/Book.java

@@ -0,0 +1,108 @@
+package com.hssx.bms.entity;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-10-16
+ */
+public class Book extends Model<Book> {
+
+    private static final long serialVersionUID=1L;
+
+    @TableField("id")
+    private String id;
+
+    @TableField("name")
+    private String name;
+
+    @TableField("cover")
+    private String cover;
+
+    @TableField("author")
+    private String author;
+
+    /**
+     * 描述
+     */
+    @TableField("descrip")
+    private String descrip;
+
+    /**
+     * 阅读人数
+     */
+    @TableField("read_cnt")
+    private Integer readCnt;
+
+
+    public String getId() {
+        return id;
+    }
+
+    public void setId(String id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getCover() {
+        return cover;
+    }
+
+    public void setCover(String cover) {
+        this.cover = cover;
+    }
+
+    public String getAuthor() {
+        return author;
+    }
+
+    public void setAuthor(String author) {
+        this.author = author;
+    }
+
+    public String getDescrip() {
+        return descrip;
+    }
+
+    public void setDescrip(String descrip) {
+        this.descrip = descrip;
+    }
+
+    public Integer getReadCnt() {
+        return readCnt;
+    }
+
+    public void setReadCnt(Integer readCnt) {
+        this.readCnt = readCnt;
+    }
+
+    @Override
+    protected Serializable pkVal() {
+        return null;
+    }
+
+    @Override
+    public String toString() {
+        return "Book{" +
+        "id=" + id +
+        ", name=" + name +
+        ", cover=" + cover +
+        ", author=" + author +
+        ", descrip=" + descrip +
+        ", readCnt=" + readCnt +
+        "}";
+    }
+}

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

@@ -0,0 +1,16 @@
+package com.hssx.bms.mapper;
+
+import com.hssx.bms.entity.Book;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-10-16
+ */
+public interface BookMapper extends BaseMapper<Book> {
+
+}

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

@@ -0,0 +1,22 @@
+package com.hssx.bms.service;
+
+import com.hssx.bms.entity.Book;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.hssx.bms.until.HttpRespMsg;
+import com.hssx.bms.until.PageUtil;
+import org.springframework.web.multipart.MultipartFile;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-10-16
+ */
+public interface BookService extends IService<Book> {
+
+    HttpRespMsg addOrUpdateBook(Book book, MultipartFile file);
+
+    HttpRespMsg getList(PageUtil page);
+}

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

@@ -0,0 +1,107 @@
+package com.hssx.bms.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.hssx.bms.entity.Book;
+import com.hssx.bms.entity.InstitutionalInformation;
+import com.hssx.bms.mapper.BookMapper;
+import com.hssx.bms.service.BookService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.hssx.bms.until.HttpRespMsg;
+import com.hssx.bms.until.PageUtil;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.Resource;
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+import java.util.UUID;
+
+/**
+ * <p>
+ * 服务实现类
+ * </p>
+ *
+ * @author 吴涛涛
+ * @since 2019-10-16
+ */
+@Service
+public class BookServiceImpl extends ServiceImpl<BookMapper, Book> implements BookService {
+    @Resource
+    private BookMapper bookMapper;
+    @Value("${upload.path}")
+    private String path;
+
+    @Override
+    public HttpRespMsg addOrUpdateBook(Book book, MultipartFile file) {
+        HttpRespMsg msg = new HttpRespMsg();
+        String fileName = "";
+        if (null != file) {
+            fileName = uploadFile(file, path);
+        }
+        if (null != book.getId()) {
+            //添加操作
+            if (!"".equals(fileName)) {
+                book.setCover(fileName);
+            }
+            bookMapper.insert(book);
+        } else {
+            //添加操作
+            if (!"".equals(fileName)) {
+                book.setCover(fileName);
+            }
+            bookMapper.insert(book);
+        }
+        msg.data = book;
+        return msg;
+    }
+
+    @Override
+    public HttpRespMsg getList(PageUtil page) {
+        HttpRespMsg msg = new HttpRespMsg();
+        if(null == page.getPageNum() && null == page.getPageSize()){
+            page = new PageUtil();
+        }
+        PageHelper.startPage(page.getPageNum(),page.getPageSize());
+        List<Book> institutionalInformations = bookMapper.selectList(new QueryWrapper<Book>());
+        PageInfo<Book> pageInfo = new PageInfo<>(institutionalInformations);
+        msg.data = pageInfo;
+        return msg;
+    }
+
+
+    private String uploadFile(MultipartFile file, String path) {
+        String afterUploadFileName = "";
+        if (file != null) {
+            File dir = null;
+            dir = new File(path);
+            // D://dolphin/upload 文件上传后所存储的位置,部署到服务器上时配置服务器地址即可
+            if (!dir.exists()) {
+                dir.mkdirs();
+            }
+            String fileName = "";
+            if (file != null) {
+                fileName = file.getOriginalFilename();
+                System.out.println("上传文件名称" + file.getName() + ", dir = " + dir.getAbsolutePath());
+                int pos = fileName.lastIndexOf(".");
+                String rand = UUID.randomUUID().toString().replaceAll("-", "");
+                String sufix = fileName.substring(pos);
+                fileName = rand + sufix;
+                afterUploadFileName = "/upload/" + fileName;
+                File saveFile = new File(dir, fileName);
+                try {
+                    saveFile.createNewFile();
+                    file.transferTo(saveFile);
+                } catch (IOException e) {
+                    e.printStackTrace();
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return afterUploadFileName;
+    }
+}

+ 1 - 1
bms/src/main/java/com/hssx/bms/until/CodeGenerator.java

@@ -204,7 +204,7 @@ public class CodeGenerator {
         //若想要生成的实体类继承某个Controller,则可打开下面注释。写上需要继承的Controller的位置即可
 //        strategy.setSuperControllerClass("com.baomidou.ant.common.BaseController");
         //此处user是表名,多个英文逗号分割
-        strategy.setInclude("institutional_pic");
+        strategy.setInclude("book");
 //        strategy.setExclude();//数据库表全生成
 //        strategy.setInclude(scanner("user").split(","));//表名,多个英文逗号分割
         strategy.setControllerMappingHyphenStyle(true);

+ 2 - 5
bms/src/main/resources/application-prod.properties

@@ -39,13 +39,10 @@ spring.thymeleaf.prefix=classpath:/static/
 #spring.redis.port=6379
 ######################################################################################################
 # 文件上传路径
-upload.path=E:/staticproject/cloudmodel/upload/
+upload.path=E:/staticproject/dolphin/upload/
 # 备用密码
-sysPwd=yunmo
+sysPwd=htjy
 ######################################################################################################
-# 邀请人员链接前缀
-invitation.url.prefix=http://118.190.47.230:9098/#/invite/
-#######################################################################################################
 # 配置上传文件的大小设置
 # Single file max size  即单个文件大小
 spring.servlet.multipart.max-file-size=1000MB

+ 20 - 0
bms/src/main/resources/mapper/BookMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.hssx.bms.mapper.BookMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.hssx.bms.entity.Book">
+        <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" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        id, name, cover, author, descrip, read_cnt
+    </sql>
+
+</mapper>