增加管理员帐号的部门属性设置

This commit is contained in:
zhl 2021-04-20 13:11:27 +08:00
parent 8704871337
commit dc4bbcb80f
2 changed files with 13 additions and 2 deletions

View File

@ -34,7 +34,7 @@ class AccountController extends BaseController {
@permission('admin:save')
@router('post /admin/save')
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
if (id) {
account = await Admin.findById(id)
@ -60,6 +60,10 @@ class AccountController extends BaseController {
}
if (showname) account.showname = showname
account.sex = sex || '0'
// 管理员不需要设置部门属性
if (ADMINS.indexOf(username) < 0) {
account.department = department
}
if (locked != undefined) {
if (locked) {
if (ADMINS.indexOf(username) >= 0) {

View File

@ -87,6 +87,12 @@ class AdminClass extends FindOrCreate {
public locked: boolean
@prop()
public lockTime: Date
/**
*
* @type {string}
*/
@prop()
public department?: string
public static async findByName(this: ReturnModelType<typeof AdminClass>, username) {
return this.findOne({ username, deleted: false }).exec()
@ -122,7 +128,8 @@ class AdminClass extends FindOrCreate {
createdBy: this.createdBy,
introduction: this.introduction,
locked: this.locked,
comment: this.comment
comment: this.comment,
department: this.department
}
}
}