增加管理员帐号的部门属性设置
This commit is contained in:
parent
8704871337
commit
dc4bbcb80f
@ -34,7 +34,7 @@ class AccountController extends BaseController {
|
|||||||
@permission('admin:save')
|
@permission('admin:save')
|
||||||
@router('post /admin/save')
|
@router('post /admin/save')
|
||||||
async save(req) {
|
async save(req) {
|
||||||
const { id, username, password, roles, showname, sex, locked } = req.params
|
const { id, username, password, roles, showname, sex, locked, department } = req.params
|
||||||
let account
|
let account
|
||||||
if (id) {
|
if (id) {
|
||||||
account = await Admin.findById(id)
|
account = await Admin.findById(id)
|
||||||
@ -60,6 +60,10 @@ class AccountController extends BaseController {
|
|||||||
}
|
}
|
||||||
if (showname) account.showname = showname
|
if (showname) account.showname = showname
|
||||||
account.sex = sex || '0'
|
account.sex = sex || '0'
|
||||||
|
// 管理员不需要设置部门属性
|
||||||
|
if (ADMINS.indexOf(username) < 0) {
|
||||||
|
account.department = department
|
||||||
|
}
|
||||||
if (locked != undefined) {
|
if (locked != undefined) {
|
||||||
if (locked) {
|
if (locked) {
|
||||||
if (ADMINS.indexOf(username) >= 0) {
|
if (ADMINS.indexOf(username) >= 0) {
|
||||||
|
@ -87,6 +87,12 @@ class AdminClass extends FindOrCreate {
|
|||||||
public locked: boolean
|
public locked: boolean
|
||||||
@prop()
|
@prop()
|
||||||
public lockTime: Date
|
public lockTime: Date
|
||||||
|
/**
|
||||||
|
* 部门
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
@prop()
|
||||||
|
public department?: string
|
||||||
|
|
||||||
public static async findByName(this: ReturnModelType<typeof AdminClass>, username) {
|
public static async findByName(this: ReturnModelType<typeof AdminClass>, username) {
|
||||||
return this.findOne({ username, deleted: false }).exec()
|
return this.findOne({ username, deleted: false }).exec()
|
||||||
@ -122,7 +128,8 @@ class AdminClass extends FindOrCreate {
|
|||||||
createdBy: this.createdBy,
|
createdBy: this.createdBy,
|
||||||
introduction: this.introduction,
|
introduction: this.introduction,
|
||||||
locked: this.locked,
|
locked: this.locked,
|
||||||
comment: this.comment
|
comment: this.comment,
|
||||||
|
department: this.department
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user