Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
saveTodos: function(){
let dataString = JSON.stringify(this.todoList)
var AVTodos = AV.Object.extend('AllTodos');
var avTodos = new AVTodos();
var acl = new AV.ACL()
acl.setReadAccess(AV.User.current(),true) // 只有这个 user 能读
acl.setWriteAccess(AV.User.current(),true) // 只有这个 user 能写
avTodos.set('content', dataString);
avTodos.setACL(acl) // 设置访问控制
avTodos.save().then((todo) =>{
this.todoList.id = todo.id // 一定要记得把 id 挂到 this.todoList 上,否则下次就不会调用 updateTodos 了
console.log('保存成功');
}, function (error) {
alert('保存失败');
});
},
saveOrUpdateTodos: function(){
for (let key of Object.keys(payload)) {
teams.set(key, payload[key])
}
// 默认不置顶
teams.set('stick', 0)
teams.set('show', 1)
if (!payload['avatar']) {
teams.set('avatar', config.BASE_PIC_URL + '/logo.png')
}
const userTeamMap = new AV.Object('UserTeamMap')
userTeamMap.set('user', currentUser)
userTeamMap.set('team', teams)
userTeamMap.set('leader', true)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(AV.User.currentAsync(), true)
userTeamMap.setACL(acl)
return userTeamMap.save().then(function(result) {
return result.get('team').toJSON()
})
}
}
// 默认不置顶
teams.set('stick', 0)
teams.set('show', 1)
if (!payload['avatar']) {
teams.set('avatar', config.BASE_PIC_URL + '/logo.png')
}
const user = getCurrentUser()
const userTeamMap = new AV.Object('UserTeamMap')
userTeamMap.set('user', user)
userTeamMap.set('team', teams)
userTeamMap.set('leader', true)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(AV.User.current(), true)
userTeamMap.setACL(acl)
return userTeamMap.save().then(function(result) {
return result.get('team').toJSON()
})
}
export function cerateGroupOrder(payload, userinfo, currentUser) {
const groupOrders = new AV.Object('GroupOrders')
groupOrders.set('title', payload.title)
groupOrders.set('description', payload.description)
groupOrders.set('contact', payload.contact)
const endDate = new Date(payload.endDate)
groupOrders.set('endDate', endDate)
groupOrders.set('user', currentUser)
groupOrders.set('stick', 0)
groupOrders.set('show', 1)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(currentUser, true)
groupOrders.setACL(acl)
return groupOrders.save().then(function(result) {
return { ...result.toJSON(), userinfo }
})
}
export function cerateGroupOrder(payload, userinfo) {
const user = getCurrentUser()
const groupOrders = new AV.Object('GroupOrders')
groupOrders.set('title', payload.title)
groupOrders.set('description', payload.description)
groupOrders.set('contact', payload.contact)
const endDate = new Date(payload.endDate)
groupOrders.set('endDate', endDate)
groupOrders.set('user', user)
groupOrders.set('stick', 0)
groupOrders.set('show', 1)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(user, true)
groupOrders.setACL(acl)
return groupOrders.save().then(function(result) {
return { ...result.toJSON(), userinfo }
})
}
export function cerateWarOrder(payload, team) {
const user = getCurrentUser()
const teamData = AV.Object.createWithoutData('Teams', payload.teamid)
const warOrders = new AV.Object('WarOrders')
warOrders.set('title', payload.title)
warOrders.set('description', payload.description)
warOrders.set('contact', payload.contact)
warOrders.set('stick', 0)
warOrders.set('show', 1)
const endDate = new Date(payload.endDate)
warOrders.set('endDate', endDate)
warOrders.set('user', user)
warOrders.set('team', teamData)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(user, true)
warOrders.setACL(acl)
return warOrders.save().then(function(result) {
return {...result.toJSON(), team}
})
}
export function cerateRecruitOrder(payload, team, currentUser) {
const teamData = AV.Object.createWithoutData('Teams', payload.teamid)
const recruitOrders = new AV.Object('RecruitOrders')
recruitOrders.set('title', payload.title)
recruitOrders.set('description', payload.description)
recruitOrders.set('contact', payload.contact)
recruitOrders.set('stick', 0)
recruitOrders.set('show', 1)
const endDate = new Date(payload.endDate)
recruitOrders.set('endDate', endDate)
recruitOrders.set('user', currentUser)
recruitOrders.set('team', teamData)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(currentUser, true)
recruitOrders.setACL(acl)
return recruitOrders.save().then(function(result) {
return { ...result.toJSON(), team }
})
}
export function cerateResumeOrder(payload, userinfo) {
const user = getCurrentUser()
const resumeOrders = new AV.Object('ResumeOrders')
resumeOrders.set('title', payload.title)
resumeOrders.set('description', payload.description)
resumeOrders.set('contact', payload.contact)
const endDate = new Date(payload.endDate)
resumeOrders.set('endDate', endDate)
resumeOrders.set('user', user)
resumeOrders.set('stick', 0)
resumeOrders.set('show', 1)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(user, true)
resumeOrders.setACL(acl)
return resumeOrders.save().then(function(result) {
return { ...result.toJSON(), userinfo }
})
}
export function cerateRecruitOrder(payload, team) {
const user = getCurrentUser()
const teamData = AV.Object.createWithoutData('Teams', payload.teamid)
const recruitOrders = new AV.Object('RecruitOrders')
recruitOrders.set('title', payload.title)
recruitOrders.set('description', payload.description)
recruitOrders.set('contact', payload.contact)
recruitOrders.set('stick', 0)
recruitOrders.set('show', 1)
const endDate = new Date(payload.endDate)
recruitOrders.set('endDate', endDate)
recruitOrders.set('user', user)
recruitOrders.set('team', teamData)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(user, true)
recruitOrders.setACL(acl)
return recruitOrders.save().then(function(result) {
return { ...result.toJSON(), team }
})
}
export function cerateWarOrder(payload, team, currentUser) {
const teamData = AV.Object.createWithoutData('Teams', payload.teamid)
const warOrders = new AV.Object('WarOrders')
warOrders.set('title', payload.title)
warOrders.set('description', payload.description)
warOrders.set('contact', payload.contact)
warOrders.set('stick', 0)
warOrders.set('show', 1)
const endDate = new Date(payload.endDate)
warOrders.set('endDate', endDate)
warOrders.set('user', currentUser)
warOrders.set('team', teamData)
var acl = new AV.ACL()
acl.setPublicReadAccess(true)
acl.setWriteAccess(currentUser, true)
warOrders.setACL(acl)
return warOrders.save().then(function(result) {
return {...result.toJSON(), team}
})
}