瀏覽代碼

Merge branch 'master' of http://47.100.37.243:10080/ZHOU/yunsu

sunyadv 5 年之前
父節點
當前提交
b052747e4f

+ 7 - 0
official_backend/src/main/java/com/hssx/ysofficial/controller/CooperationsController.java

@@ -12,6 +12,8 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
+
 /**
  * <p>
  * the cooperations of client company and high school 前端控制器
@@ -49,5 +51,10 @@ public class CooperationsController {
             MultipartFile multipartFile){
         return cooperationsService.editCooperations(cooperations, multipartFile);
     }
+
+    @RequestMapping("/switchCooperationSticky")
+    public HttpRespMsg switchCooperationSticky(Integer id){
+        return cooperationsService.switchCooperationSticky(id);
+    }
 }
 

+ 11 - 0
official_backend/src/main/java/com/hssx/ysofficial/controller/UserController.java

@@ -1,8 +1,13 @@
 package com.hssx.ysofficial.controller;
 
 
+import com.hssx.ysofficial.entity.User;
+import com.hssx.ysofficial.service.UserService;
+import com.hssx.ysofficial.utility.HttpRespMsg;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestMapping;
 
+import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
@@ -16,6 +21,12 @@ import org.springframework.web.bind.annotation.RestController;
 @RestController
 @RequestMapping("/user")
 public class UserController {
+    @Autowired
+    private UserService userService;
 
+    @RequestMapping("/login")
+    public HttpRespMsg login(User user){
+        return userService.login(user);
+    }
 }
 

+ 1 - 0
official_backend/src/main/java/com/hssx/ysofficial/service/CooperationsService.java

@@ -18,4 +18,5 @@ public interface CooperationsService extends IService<Cooperations> {
     HttpRespMsg addCooperations(Cooperations cooperations, MultipartFile multipartFile);
     HttpRespMsg deleteCooperationsById(Integer id);
     HttpRespMsg editCooperations(Cooperations cooperations, MultipartFile multipartFile);
+    HttpRespMsg switchCooperationSticky(Integer id);
 }

+ 2 - 1
official_backend/src/main/java/com/hssx/ysofficial/service/UserService.java

@@ -2,6 +2,7 @@ package com.hssx.ysofficial.service;
 
 import com.hssx.ysofficial.entity.User;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.hssx.ysofficial.utility.HttpRespMsg;
 
 /**
  * <p>
@@ -12,5 +13,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @since 2019-10-23
  */
 public interface UserService extends IService<User> {
-
+    HttpRespMsg login(User user);
 }

+ 4 - 2
official_backend/src/main/java/com/hssx/ysofficial/service/impl/ArticleServiceImpl.java

@@ -103,12 +103,14 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
                 //跟上一个互换的话
                 queryWrapper = new QueryWrapper<Article>()
                         .eq("type", "case")
-                        .gt("position", currentPosition);
+                        .gt("position", currentPosition)
+                        .orderByAsc("position");
             }else{
                 //跟下一个互换的话
                 queryWrapper = new QueryWrapper<Article>()
                         .eq("type", "case")
-                        .lt("position", currentPosition);
+                        .lt("position", currentPosition)
+                        .orderByDesc("position");
             }
             if(articleMapper.selectCount(queryWrapper) > 0){
                 Article targetArticle = articleMapper.selectList(queryWrapper).get(0);

+ 10 - 7
official_backend/src/main/java/com/hssx/ysofficial/service/impl/CooperationsServiceImpl.java

@@ -42,7 +42,7 @@ public class CooperationsServiceImpl extends ServiceImpl<CooperationsMapper, Coo
         HttpRespMsg httpRespMsg = new HttpRespMsg();
         httpRespMsg.data = map;
         return httpRespMsg;
-    };
+    }
 
     public HttpRespMsg addCooperations(Cooperations cooperations, MultipartFile multipartFile){
         HttpRespMsg httpRespMsg = new HttpRespMsg();
@@ -65,7 +65,7 @@ public class CooperationsServiceImpl extends ServiceImpl<CooperationsMapper, Coo
             httpRespMsg.setError("lack of file or information");
         }
         return httpRespMsg;
-    };
+    }
 
     public HttpRespMsg editCooperations(Cooperations cooperations, MultipartFile multipartFile){
         HttpRespMsg httpRespMsg = new HttpRespMsg();
@@ -90,14 +90,17 @@ public class CooperationsServiceImpl extends ServiceImpl<CooperationsMapper, Coo
             httpRespMsg.setError("lack of information");
         }
         return httpRespMsg;
-    };
+    }
 
     public HttpRespMsg deleteCooperationsById(Integer id){
         cooperationsMapper.deleteById(id);
         return new HttpRespMsg();
-    };
+    }
 
-    public HttpRespMsg editCooperations(){
-        return null;
-    };
+    public HttpRespMsg switchCooperationSticky(Integer id){
+        Cooperations cooperations = cooperationsMapper.selectById(id);
+        cooperations.setSticky(cooperations.getSticky() == 0? 1: 0);
+        cooperationsMapper.updateById(cooperations);
+        return new HttpRespMsg();
+    }
 }

+ 18 - 0
official_backend/src/main/java/com/hssx/ysofficial/service/impl/UserServiceImpl.java

@@ -1,11 +1,16 @@
 package com.hssx.ysofficial.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.hssx.ysofficial.entity.User;
 import com.hssx.ysofficial.mapper.UserMapper;
 import com.hssx.ysofficial.service.UserService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.hssx.ysofficial.utility.HttpRespMsg;
 import org.springframework.stereotype.Service;
 
+import javax.annotation.Resource;
+import java.net.HttpCookie;
+
 /**
  * <p>
  *  服务实现类
@@ -16,5 +21,18 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
+    @Resource
+    private UserMapper userMapper;
 
+    @Override
+    public HttpRespMsg login(User user){
+        HttpRespMsg httpRespMsg = new HttpRespMsg();
+        QueryWrapper queryWrapper = new QueryWrapper<>(user);
+        if(userMapper.selectCount(queryWrapper) == 0){
+            httpRespMsg.setError("account mismatch");
+        }else{
+            httpRespMsg.data = userMapper.selectList(queryWrapper).get(0);
+        }
+        return httpRespMsg;
+    }
 }

+ 5 - 1
official_backend/src/main/resources/application.properties

@@ -15,7 +15,11 @@ spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
 spring.datasource.url=jdbc:mysql://118.190.47.230:3306/cloud_model_website?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8
 spring.datasource.username=root
 spring.datasource.password=p011430seya1026
-spring.datasource.hikari.max-lifetime=540000
+spring.datasource.hikari.max-lifetime=60000
+spring.datasource.hikari.IdleTimeout=60000
+spring.datasource.hikari.ConnectionTimeout=60000
+spring.datasource.hikari.ValidationTimeout=3000
+spring.datasource.hikari.LoginTimeout=5
 
 #ÎļþÉÏ´«Â·¾¶
 upload.path=D:/ysofficial/upload/

+ 5 - 3
website/pom.xml

@@ -15,9 +15,11 @@
 
     <properties>
         <java.version>1.8</java.version>
-        <!--springboot默认使用的版本是thymeleaf2.0,如果要使用修改thymeleaf为3.0-->
-        <!--<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>-->
-        <!--<thymeleaf-layout-dialect.version>2.0.4</thymeleaf-layout-dialect.version>-->
+        <!--修改thymeleaf版本 注:经过本人测试这两个版本没有冲突问题,别乱修改版本
+        否则会导致页面跳转的问题-->
+        <thymeleaf.version>3.0.11.RELEASE</thymeleaf.version>
+        <!--        布局功能的支持 thymeleaf3 layout2以上版本-->
+        <thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
 
     </properties>
 

+ 14 - 4
website/src/main/java/com/hssx/website/controller/ArticleController.java

@@ -1,7 +1,9 @@
 package com.hssx.website.controller;
 
 
+import com.hssx.website.entity.Cooperations;
 import com.hssx.website.service.ArticleService;
+import com.hssx.website.service.CooperationsService;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -21,12 +23,14 @@ public class ArticleController {
 
     @Autowired
     private ArticleService articleService;
+    @Autowired
+    private CooperationsService cooperationsService;
 
-    @ApiOperation("添加/修改公司")
-    @GetMapping("/add")
-    public String indexHtml(Model model) {
+    @ApiOperation("案例")
+    @GetMapping("/article")
+    public String index(Model model) {
         model = articleService.getList(model);
-        return "hello";
+        return "index";
     }
 //    @GetMapping("/")
 //    public String index(Model model) {
@@ -34,5 +38,11 @@ public class ArticleController {
 //        return "index";
 //    }
 
+    @ApiOperation("合作伙伴")
+    @GetMapping("/cooperations")
+    public String cooperations(Model model) {
+        model = cooperationsService.getList(model);
+        return "index";
+    }
 }
 

+ 19 - 0
website/src/main/java/com/hssx/website/defaultviewconfig/DefaultView.java

@@ -0,0 +1,19 @@
+package com.hssx.website.defaultviewconfig;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.core.Ordered;
+import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+
+/**
+ * 用于配置自定义的首页;
+ */
+@Configuration
+public class DefaultView extends WebMvcConfigurerAdapter {
+  @Override
+  public void addViewControllers(ViewControllerRegistry registry) {
+    registry.addViewController("/").setViewName("index");
+    registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
+    super.addViewControllers(registry);
+  }
+}

+ 2 - 0
website/src/main/java/com/hssx/website/service/CooperationsService.java

@@ -2,6 +2,7 @@ package com.hssx.website.service;
 
 import com.hssx.website.entity.Cooperations;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.springframework.ui.Model;
 
 /**
  * <p>
@@ -13,4 +14,5 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface CooperationsService extends IService<Cooperations> {
 
+    Model getList(Model model);
 }

+ 2 - 3
website/src/main/java/com/hssx/website/service/impl/ArticleServiceImpl.java

@@ -27,9 +27,8 @@ public class ArticleServiceImpl extends ServiceImpl<ArticleMapper, Article> impl
 
     @Override
     public Model getList(Model model) {
-        List<Article> list = articleMapper.selectList(new QueryWrapper<Article>().orderByAsc("id"));
-        model.addAttribute("list", list);
-        model.addAttribute("name", "name");
+        List<Article> articles = articleMapper.selectList(new QueryWrapper<Article>().orderByAsc("id"));
+        model.addAttribute("articles", articles);
         return model;
     }
 }

+ 14 - 1
website/src/main/java/com/hssx/website/service/impl/CooperationsServiceImpl.java

@@ -1,10 +1,16 @@
 package com.hssx.website.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.hssx.website.entity.Article;
 import com.hssx.website.entity.Cooperations;
 import com.hssx.website.mapper.CooperationsMapper;
 import com.hssx.website.service.CooperationsService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
+import org.springframework.ui.Model;
+
+import javax.annotation.Resource;
+import java.util.List;
 
 /**
  * <p>
@@ -16,5 +22,12 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class CooperationsServiceImpl extends ServiceImpl<CooperationsMapper, Cooperations> implements CooperationsService {
-
+    @Resource
+    private CooperationsMapper cooperationsMapper;
+    @Override
+    public Model getList(Model model) {
+        List<Cooperations> cooperations = cooperationsMapper.selectList(new QueryWrapper<Cooperations>().orderByAsc("id"));
+        model.addAttribute("cooperations", cooperations);
+        return model;
+    }
 }

+ 1 - 1
website/src/main/resources/templates/index.html

@@ -1,5 +1,5 @@
 <!DOCTYPE html>
-<html>
+<html xmlns:th="http://www.thymeleaf.org">
     <head>
         <meta charset="utf-8">
         <meta http-equiv="X-UA-Compatible" content="IE=edge">