diff --git a/alpha/admin/js_sdk/validator/mustgo-school-activity.js b/alpha/admin/js_sdk/validator/mustgo-school-activity.js index 6c7181c7024c9aff20cc3450cd8e42fff8d758d8..5d2c781be6979d2b3f7bfd6141858a355c1ea95a 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 0c4c1aa8e9663003c1ea13404502f7edad78e66e..fc9d896d20fa1587316ccd8d3c47ba5d4f01f61a 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 ca6a68521f216e14172a2eb224760f751bcab213..2f92af81bb5c7712483879f9f5b932ed825d3346 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 f1f3b42d1e2fbf26c0e752983c1ed7a6fc41930e..d7dd6e0820655131fdfe06b9e8394c9c3d75966c 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 55dbe5c4e5a52b0e8a6cff6d83bd6fa39606da8f..2428ce4e43472e81817e4af4340dfae41bf7cc11 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 56e48411fe1b39da051523d5f0f83900b52a2d41..8693501036bceac3985f9d982e29c8e922b4f1a6 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 0000000000000000000000000000000000000000..7ae183b541f3e415b535961394692b3c264c806a --- /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 0000000000000000000000000000000000000000..e1c1b10ec120fcf1a7218b1585a8b3dc4c95eaa0 --- /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 0000000000000000000000000000000000000000..93086cab5ec0ebb0bc4fb8ccfdd3e35479b8565b --- /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