From 6863b9512e12f983b1d755fba0a8706c5871f6ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?052004122=E6=B8=A9=E5=AE=B8=E6=9D=B0?= <734868971@qq.com>
Date: Thu, 25 May 2023 23:14:40 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=90=8E=E5=8F=B0=E7=AE=A1?=
=?UTF-8?q?=E7=90=86=E7=B3=BB=E7=BB=9F=EF=BC=8C=E5=AE=8C=E6=88=90=E6=B6=88?=
=?UTF-8?q?=E6=81=AF=E9=80=9A=E7=9F=A5=E5=90=8E=E7=AB=AF=E6=8E=A5=E5=8F=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../validator/mustgo-school-activity.js | 6 ++--
.../content/mustgo-activity/school/edit.vue | 22 +++++++++---
.../content/mustgo-activity/team/edit.vue | 19 +++++++---
.../fe-college-commentPost/index.js | 11 ++++++
.../fe-college-likePost/index.js | 35 ++++++++++++++++++-
.../fe-college-myPostList/index.js | 10 +++++-
.../fe-college-postList/index.js | 12 ++++++-
.../fe-message-checkMessage/index.js | 26 ++++++++++++++
.../fe-message-checkMessage/package.json | 7 ++++
.../database/mustgo-message.schema.json | 1 +
10 files changed, 134 insertions(+), 15 deletions(-)
create mode 100644 alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-checkMessage/index.js
create mode 100644 alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-checkMessage/package.json
create mode 100644 alpha/admin/uniCloud-aliyun/database/mustgo-message.schema.json
diff --git a/alpha/admin/js_sdk/validator/mustgo-school-activity.js b/alpha/admin/js_sdk/validator/mustgo-school-activity.js
index 6c7181c..5d2c781 100644
--- a/alpha/admin/js_sdk/validator/mustgo-school-activity.js
+++ b/alpha/admin/js_sdk/validator/mustgo-school-activity.js
@@ -23,7 +23,7 @@ const validator = {
"start_date": {
"rules": [
{
- "format": "string"
+ "format": "datetime"
}
],
"title": "开始时间",
@@ -32,7 +32,7 @@ const validator = {
"end_date": {
"rules": [
{
- "format": "string"
+ "format": "datetime"
}
],
"title": "结束时间",
@@ -77,7 +77,7 @@ const validator = {
"contact": {
"rules": [
{
- "format": "string"
+ "format": " /^1[3|4|5|7|8][0-9]\d{8}$/"
}
],
"title": "联系方式",
diff --git a/alpha/admin/pages/content/mustgo-activity/school/edit.vue b/alpha/admin/pages/content/mustgo-activity/school/edit.vue
index 0c4c1aa..fc9d896 100644
--- a/alpha/admin/pages/content/mustgo-activity/school/edit.vue
+++ b/alpha/admin/pages/content/mustgo-activity/school/edit.vue
@@ -8,20 +8,31 @@
-
+
+
-
+
+
-
+
-
+
+
+
+
-
+
+
-
+
@@ -23,13 +31,14 @@
-->
-
+
+
-
+
diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-commentPost/index.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-commentPost/index.js
index ca6a685..2f92af8 100644
--- a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-commentPost/index.js
+++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-commentPost/index.js
@@ -4,6 +4,7 @@ exports.main = async (event, context) => {
const user_table = db.collection("mustgo-user")
const comment_table = db.collection("mustgo-post-comment")
const post_table = db.collection("mustgo-post")
+ const message_table = db.collection("mustgo-message")
const res = await user_table.where({
_id:event.userId
@@ -30,6 +31,16 @@ exports.main = async (event, context) => {
content:event.content
})
+ const res5 = await message_table.add({
+ state:false,
+ types:"评论",
+ content:event.content,
+ time:getSystemTime(),
+ from_id:event.userId,
+ to_id:res2.data[0]["owner_id"],
+ post_id:event.postId
+ })
+
return{
code:200,
message:"评论帖子成功",
diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-likePost/index.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-likePost/index.js
index f1f3b42..d7dd6e0 100644
--- a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-likePost/index.js
+++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-likePost/index.js
@@ -4,6 +4,7 @@ exports.main = async (event, context) => {
const db = uniCloud.database();
const post_table = db.collection("mustgo-post")
const like_table = db.collection("mustgo-post-like")
+ const message_table = db.collection("mustgo-message")
const res = await post_table.where({
_id:event.postId
}).get()
@@ -23,6 +24,16 @@ exports.main = async (event, context) => {
owner_id:event.userId
})
+ const res4 = await message_table.add({
+ state:false,
+ types:"点赞",
+ content:"",
+ time:getSystemTime(),
+ from_id:event.userId,
+ to_id:res.data[0]["owner_id"],
+ post_id:event.postId
+ })
+
return {
code: 200,
message: "点赞帖子成功",
@@ -56,4 +67,26 @@ exports.main = async (event, context) => {
message: "服务器错误",
data: {}
}
-};
\ No newline at end of file
+};
+
+function getSystemTime() {
+ // 实例化日期类
+ var time = new Date();
+ // 获取完整的年份(4位)
+ var year = time.getFullYear();
+ // 获取月份(0-11,0代表1月)
+ var month = time.getMonth() + 1;
+ // 获取日期(1-31)
+ var date = time.getDate();
+ // 获取小时
+ var h = time.getHours() + 8;
+ h = h < 10 ? '0' + h : h;
+ // 获取分钟
+ var m = time.getMinutes();
+ m = m < 10 ? '0' + m : m;
+ // 获取秒钟
+ var s = time.getSeconds();
+ s = s < 10 ? '0' + s : s;
+ // 合并返回
+ return(year + "-" + month + "-" + date + " " + h + ":" + m + ":" + s) ;
+}
\ No newline at end of file
diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-myPostList/index.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-myPostList/index.js
index 55dbe5c..2428ce4 100644
--- a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-myPostList/index.js
+++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-myPostList/index.js
@@ -4,6 +4,7 @@ exports.main = async (event, context) => {
const post_table = db.collection("mustgo-post")
const user_table = db.collection("mustgo-user")
const like_table = db.collection("mustgo-post-like")
+ const message_table = db.collection("mustgo-message")
const res = await post_table.orderBy("date","desc").where({
owner_id:event.userId
}).get()
@@ -22,6 +23,12 @@ exports.main = async (event, context) => {
owner_id:event.userId,
post_id:arr[i]["_id"]
}).get()
+
+ const res4 = await message_table.where({
+ to_id:event.userId,
+ state:false
+ }).get()
+
if(res3.affectedDocs == 1) like = 1
if(res2.affectedDocs == 1){
@@ -43,7 +50,8 @@ exports.main = async (event, context) => {
code:200,
message:"成功返回我的帖子列表",
data:{
- postList:list
+ postList:list,
+ messageNum:res4.affectedDocs
}
}
}
diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-postList/index.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-postList/index.js
index 56e4841..8693501 100644
--- a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-postList/index.js
+++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-college-postList/index.js
@@ -5,6 +5,7 @@ exports.main = async (event, context) => {
const post_table = db.collection("mustgo-post")
const user_table = db.collection("mustgo-user")
const like_table = db.collection("mustgo-post-like")
+ const message_table = db.collection("mustgo-message")
const res = await post_table.orderBy("date","desc").get();
var list = new Array
var arr = new Array;
@@ -19,6 +20,7 @@ exports.main = async (event, context) => {
owner_id:event.uid,
post_id:arr[i]["_id"]
}).get()
+
var like = 0
if(res3.affectedDocs == 1) like = 1
@@ -37,11 +39,19 @@ exports.main = async (event, context) => {
list.push(post);
}
}
+
+ const res4 = await message_table.where({
+ to_id:event.uid,
+ state:false
+ }).get()
+ var num = res4.affectedDocs
+
return {
code: 200,
message: "成功返回帖子列表",
data: {
- postList: list
+ postList: list,
+ messageNum: num
}
}
}
diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-checkMessage/index.js b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-checkMessage/index.js
new file mode 100644
index 0000000..7ae183b
--- /dev/null
+++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-checkMessage/index.js
@@ -0,0 +1,26 @@
+'use strict';
+exports.main = async (event, context) => {
+ const db = uniCloud.database();
+ const message_table = db.collection("mustgo-message")
+ var res = await message_table.where({
+ to_id:event.userId,
+ state:false
+ }).update({
+ state:true
+ })
+
+ if(res.affectedDocs < 0){
+ return{
+ code:400,
+ message:"查看信息列表失败",
+ data:{}
+ }
+ }
+
+ return {
+ code: 200,
+ message: "查看信息列表成功",
+ data: {
+ }
+ }
+};
diff --git a/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-checkMessage/package.json b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-checkMessage/package.json
new file mode 100644
index 0000000..e1c1b10
--- /dev/null
+++ b/alpha/admin/uniCloud-aliyun/cloudfunctions/fe-message-checkMessage/package.json
@@ -0,0 +1,7 @@
+{
+ "name": "fe-message-checkMessage",
+ "dependencies": {},
+ "extensions": {
+ "uni-cloud-jql": {}
+ }
+}
\ No newline at end of file
diff --git a/alpha/admin/uniCloud-aliyun/database/mustgo-message.schema.json b/alpha/admin/uniCloud-aliyun/database/mustgo-message.schema.json
new file mode 100644
index 0000000..93086ca
--- /dev/null
+++ b/alpha/admin/uniCloud-aliyun/database/mustgo-message.schema.json
@@ -0,0 +1 @@
+{"bsonType":"object","required":[],"permission":{"read":false,"create":false,"update":false,"delete":false},"properties":{"_id":{"description":"消息id","title":"id"},"state":{"bsonType":"bool","title":"状态","description":"消息状态"},"types":{"bsonType":"string","title":"类型","description":"消息类型"},"content":{"bsonType":"string","title":"内容","description":"消息内容"},"time":{"bsonType":"string","title":"时间","description":"消息时间"},"from_id":{"bsonType":"string","title":"发起人id","description":"发起人id","foreignKey":"mustgo-user._id"},"to_id":{"bsonType":"string","title":"接收者id","description":"接收者id","foreignKey":"mustgo-user._id"},"post_id":{"bsonType":"string","title":"帖子id","description":"帖子id","foreignKey":"mustgo-post._id"}}}
\ No newline at end of file
--
GitLab