ソースを参照

Merge branch 'master' into dev

Junling Bu 6 年 前
コミット
d5d6e481ae

+ 7 - 0
docker/bin/deploy.sh

@@ -0,0 +1,7 @@
+#!/bin/bash
+
+cd /home/ubuntu/docker
+sudo docker-compose down
+sudo docker-compose build
+sudo docker image prune -f
+sudo docker-compose up -d

+ 36 - 0
docker/bin/reset.sh

@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# 本脚本的作用是重置部署环境
+# 1.重置数据库
+# 2.删除storage文件夹内文件
+# 3.调用deploy.sh启动服务
+# 注意:由于1和2的原因,请仅在开发测试阶段使用本脚本!
+
+# 重置数据库
+# i. 请在`XXXXXX`处设置相应的root密码
+# ii. 同时请注意root密码放在脚本是非常危险的,因此这里仅仅是用于开发测试阶段。
+ROOT=root
+PASSWORD=litemall123456
+
+if test -z "$PASSWORD"
+then
+  echo "请设置云服务器MySQL的root账号密码"
+  exit 1
+fi
+
+# 删除storage文件夹内文件
+cd /home/ubuntu/docker/litemall/storage || exit 2
+sudo rm -f ./**
+
+cd /home/ubuntu/docker || exit 3
+sudo docker-compose down
+sudo docker-compose build
+sudo docker image prune -f
+
+# 删除db/data文件夹内文件重置数据
+# 这样docker启动时会自动运行db/init-sql脚本,导入新的数据
+cd /home/ubuntu/docker/db/data || exit 1
+sudo rm -rf ./**
+
+cd /home/ubuntu/docker || exit 3
+sudo docker-compose up -d

+ 2 - 2
docker/litemall/Dockerfile

@@ -1,4 +1,4 @@
 FROM openjdk:8-jre
-COPY application.yml /litemall/application.yml
-COPY litemall.jar /litemall/litemall.jar
+COPY application.yml application.yml
+COPY litemall.jar litemall.jar
 ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","litemall.jar"]

+ 7 - 7
docker/util/lazy.sh

@@ -7,10 +7,10 @@
 
 # 请设置云服务器的IP地址和账户
 # 例如 ubuntu@122.51.199.160
-REMOTE=
+REMOTE=ubuntu@122.51.199.160
 # 请设置本地SSH私钥文件id_rsa路径
 # 例如 /home/litemall/id_rsa
-ID_RSA=
+ID_RSA=/d/00/cloud/litemall.txt
 
 if test -z "$REMOTE"
 then
@@ -38,8 +38,8 @@ cd $LITEMALL_HOME || exit 2
 scp -i $ID_RSA -r  ./docker $REMOTE:/home/ubuntu/
 
 # 远程登录云服务器并执行reset脚本
-#ssh $REMOTE -i $ID_RSA << eeooff
-#cd /home/ubuntu
-#sudo ./docker/bin/reset.sh
-#exit
-#eeooff
+ssh $REMOTE -i $ID_RSA << eeooff
+cd /home/ubuntu
+sudo ./docker/bin/reset.sh
+exit
+eeooff

+ 4 - 1
litemall-core/src/main/java/org/linlinjava/litemall/core/task/Task.java

@@ -1,5 +1,8 @@
 package org.linlinjava.litemall.core.task;
 
+import com.google.common.primitives.Ints;
+
+import java.time.LocalDateTime;
 import java.util.concurrent.Delayed;
 import java.util.concurrent.TimeUnit;
 
@@ -24,7 +27,7 @@ public abstract class Task implements Delayed, Runnable{
 
     @Override
     public int compareTo(Delayed o) {
-        return (int)(this.getDelay(TimeUnit.MILLISECONDS) - o.getDelay(TimeUnit.MILLISECONDS));
+        return Ints.saturatedCast(this.start - ((Task) o).start);
     }
 
     @Override

+ 17 - 0
litemall-core/src/test/java/org/linlinjava/litemall/core/TaskTest.java

@@ -89,4 +89,21 @@ public class TaskTest {
             e.printStackTrace();
         }
     }
+
+    @Test
+    public void test2() {
+        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String now = df.format(LocalDateTime.now());
+        System.out.println("start at time=" + now);
+
+        taskService.addTask(new DemoTask("1", 0));
+        taskService.addTask(new DemoTask("2", 1200));
+        taskService.addTask(new DemoTask("3", 5200));
+
+        try {
+            Thread.sleep(10 * 1000);
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+    }
 }

+ 3 - 3
litemall-db/sql/litemall_schema.sql

@@ -1,8 +1,8 @@
 drop database if exists litemall;
-drop user if exists 'litemall'@'localhost';
+drop user if exists 'litemall'@'%';
 -- 支持emoji:需要mysql数据库参数: character_set_server=utf8mb4
 create database litemall default character set utf8mb4 collate utf8mb4_unicode_ci;
 use litemall;
-create user 'litemall'@'localhost' identified by 'litemall123456';
-grant all privileges on litemall.* to 'litemall'@'localhost';
+create user 'litemall'@'%' identified by 'litemall123456';
+grant all privileges on litemall.* to 'litemall'@'%';
 flush privileges;

+ 7 - 0
litemall-vue/src/api/api.js

@@ -59,6 +59,13 @@ export function authProfile(data) {
   })
 }
 const AuthRegister='wx/auth/register'; //账号注册
+export function authRegister(data) {
+  return request({
+    url: AuthRegister,
+    method: 'post',
+    data
+  });
+}
 const AuthReset='wx/auth/reset'; //账号密码重置
 export function authReset(data) {
   return request({

+ 2 - 1
litemall-vue/src/router/login.js

@@ -10,8 +10,9 @@ export default [
     component: () => import('@/views/login/register-getCode')
   },
   {
-    path: '/login/registerSubmit',
+    path: '/login/registerSubmit/:phone',
     name: 'registerSubmit',
+    props: true,
     component: () => import('@/views/login/register-submit')
   },
   {

+ 16 - 1
litemall-vue/src/views/login/register-getCode/index.vue

@@ -20,6 +20,7 @@
 <script>
 import field from '@/components/field/';
 import fieldGroup from '@/components/field-group/';
+import { mobileReg } from '@/utils/validate';
 
 export default {
   data() {
@@ -30,7 +31,21 @@ export default {
 
   methods: {
     submitCode() {
-      this.$router.push({ name: 'registerSubmit' });
+      if(this.mobile === ''){
+        return
+      }
+      if(!mobileReg.test(this.mobile)){
+        this.mobile = ''
+        return
+      }
+    	try {
+        this.$router.push({
+          name: 'registerSubmit',
+          params: { phone: this.mobile}
+        });
+      } catch (error) {
+        console.log(error.message);
+      }
     }
   },
 

+ 52 - 28
litemall-vue/src/views/login/register-status/index.vue

@@ -5,39 +5,63 @@
 			<div>{{statusText}}</div>
 		</div>
 
-		<div class="status_text"><span class="red">3秒</span>后返回到登录页, 您也可以<router-link to="/login" class="red">点此登录</router-link></div>
+		<div class="status_text">
+			<span class="red">
+				<countdown v-if="counting" :time="3000" @end="countDownEnd">
+					<template slot-scope="props">{{ +props.seconds || 3 }}</template>秒
+				</countdown>
+			</span>
+			后返回到登录页, 您也可以
+			<router-link to="/login" class="red">点此登录</router-link>
+		</div>
 	</div>
 </template>
 
 <script>
+import field from '@/components/field/';
+import fieldGroup from '@/components/field-group/';
+
 export default {
-  name: 'payment-status',
-
-  props: {
-    status: String
-  },
-
-  data() {
-    return {
-      isSuccess: true
-    };
-  },
-
-  computed: {
-    statusText() {
-      return this.isSuccess ? '注册成功' : '注册失败';
-    },
-    statusIcon() {
-      return this.isSuccess ? 'checked' : 'fail';
-    },
-    statusClass() {
-      return this.isSuccess ? 'success_icon' : 'fail_icon';
-    }
-  },
-
-  activated() {
-    this.isSuccess = this.status === 'success';
-  }
+	name: 'payment-status',
+
+	props: {
+		status: String
+	},
+
+	data() {
+		return {
+			counting: true,
+			isSuccess: true
+		};
+	},
+
+	methods:{
+		countDownEnd() {
+			this.counting = false;
+			window.location = '#/login/';
+		}
+	},
+
+	computed: {
+		statusText() {
+			return this.isSuccess ? '注册成功' : '注册失败';
+		},
+		statusIcon() {
+			return this.isSuccess ? 'checked' : 'fail';
+		},
+		statusClass() {
+			return this.isSuccess ? 'success_icon' : 'fail_icon';
+		}
+	},
+
+	activated() {
+		this.isSuccess = this.status === 'success';
+	},
+
+	components: {
+		[field.name]: field,
+		[fieldGroup.name]: fieldGroup
+	}
 };
 </script>
 

+ 68 - 13
litemall-vue/src/views/login/register-submit/index.vue

@@ -2,12 +2,13 @@
 	<md-field-group class="register_submit">
 		<md-field v-model="code" icon="mobile" placeholder="请输入验证码">
 			<div slot="rightIcon" @click="getCode" class="getCode red">
-				<countdown v-if="counting" :time="60000" @end="countdownend">
+				<countdown v-if="counting" :time="60000" @end="countDownEnd">
 				  <template slot-scope="props">{{ +props.seconds || 60 }}秒后获取</template>
 				</countdown>
 				<span v-else>获取验证码</span>
 			</div>
 		</md-field>
+		<md-field v-model="username" icon="username" placeholder="请输入用户名"/>
 		<md-field v-model="password" icon="lock" placeholder="请输入密码"/>
 		<md-field v-model="repeatPassword" icon="lock" placeholder="请再次确认密码"/>
 
@@ -20,29 +21,83 @@
 <script>
 import field from '@/components/field/';
 import fieldGroup from '@/components/field-group/';
+import { authRegisterCaptcha } from '@/api/api';
+import { authRegister } from '@/api/api';
+import {Toast} from "vant";
 
 export default {
-  data() {
-    return {
-      counting: true,
-      code: '',
-      password: '',
-      repeatPassword: ''
-    };
-  },
+	props: {
+		phone: String
+	},
+	data() {
+		return {
+		  counting: true,
+		  code: '',
+		  username: '',
+		  password: '',
+		  repeatPassword: ''
+		};
+	},
+	mounted:function(){
+		this.getCode();
+	},
 
   methods: {
     registerSubmit() {
-      this.$router.push({
-        name: 'registerStatus',
-        params: { status: 'success' }
+      if(this.username === '' || this.code === ''){
+        return
+      }
+      if(this.password === '' || this.repeatPassword === ''){
+        return
+      }
+      if(this.password !== this.repeatPassword){
+        this.password = ''
+        this.repeatPassword = ''
+        return
+      }
+      let data = this.getRegisterData();
+      authRegister(data).then(res => {
+        this.$router.push({
+          name: 'registerStatus',
+          params: { status: 'success' }
+        });
+      }).catch (error => {
+        Toast.fail(error.data.errmsg);
+        if (error.data.errno == 705) {
+          window.location = '#/login/';
+        }
       });
     },
 
     getCode() {
       this.counting = true;
+      let data = {
+        mobile: this.phone
+      };
+      authRegisterCaptcha(data).then(res => {
+        this.counting = true;
+      }).catch(error => {
+        alert(error.data.errmsg);
+        this.counting = true;
+      });
     },
-    countdownend() {
+
+    getRegisterData() {
+      const password = this.password;
+      const code = this.code;
+      const repeatPassword = this.repeatPassword;
+      const mobile = this.phone;
+      const username = this.username;
+      return {
+        code: code,
+        username: username,
+        password: password,
+        repeatPassword: repeatPassword,
+        mobile: mobile
+      };
+    },
+
+    countDownEnd() {
       this.counting = false;
     }
   },

+ 1 - 2
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAuthController.java

@@ -318,14 +318,13 @@ public class WxAuthController {
 
         // token
         String token = UserTokenManager.generateToken(user.getId());
-        
+
         Map<Object, Object> result = new HashMap<Object, Object>();
         result.put("token", token);
         result.put("userInfo", userInfo);
         return ResponseUtil.ok(result);
     }
 
-
     /**
      * 请求验证码
      *

+ 1 - 1
pom.xml

@@ -78,7 +78,7 @@
             <dependency>
                 <groupId>org.hibernate.validator</groupId>
                 <artifactId>hibernate-validator</artifactId>
-                <version>6.0.15.Final</version>
+                <version>6.1.0.Final</version>
             </dependency>
 
             <!-- MySQL 连接驱动依赖 -->