Reiskuchen 5 years ago
parent
commit
bc2daf8f3b

+ 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/