明树Git Lab

Commit d46725c0 authored by zengfanpei's avatar zengfanpei

update

parent 06325b1e
const crypto = require('crypto');
const _ = require('lodash');
const mongoose = require('mongoose');
const createError = require('http-errors');
......@@ -330,6 +331,8 @@ async function updateRole(req, res, next) {
async function deleteRole(req, res, next) {
try {
// 角色删除 将用户中的角色去掉。$pull 从数组中删除一个指定元素
await DB.User.updateMany({}, {$pull: {roles: (req.body._id)}});
const ret = await DB.Role.findOneAndUpdate({ _id: req.body._id }, { del: 1 });
res.sendData(ret)
} catch (error) {
......
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const moment = require('moment');
/**
* 农事决策--由专家录入
*/
const AgrTaskSchema = new Schema({
name: {
type: "任务名称",
},
agrType: {
type: Number,
comment: "农事类型",
},
startTime: {
type: Date,
omment: "任务开始日期",
},
endTime: {
type: Date,
omment: "任务结束日期",
},
leader: {
type: mongoose.Types.ObjectId,
ref: 'User',
comment: "负责人--从分配负责人开始, 任务就开启"
},
status: {
type: Number,
comment: "1. 待分配(没有leader), 3. 进行中, 5 已完成"
},
auditStatus: {
type: Number,
comment: "1. 待审核, 2, 审核通过, 3.审核不通过, 记录最新的审核记录"
},
creator: {
type: mongoose.Types.ObjectId,
ref: 'User',
comment: "创建人"
},
createdAt: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD HH:mm:ss"),
},
updatedAt: {
type: Date,
default: Date.now,
get: v => moment(v).format("YYYY-MM-DD HH:mm:ss"),
},
del: {
type: Number,
default: 0,
comment: '默认0 , 1:表示删除, 若有其他隐藏业务 不要混用此字段。'
}
}, {
toJSON: {
getters: true
}
});
const AgrTask = mongoose.model('AgrTask', AgrTaskSchema, 'letianAgrTask');
module.exports = AgrTask;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment