| | |
| | | * @param query |
| | | */ |
| | | async page(query) { |
| | | console.log(query, "page 打印 query") |
| | | const { keyWord, status, departmentIds = [] } = query; |
| | | const permsDepartmentArr = await this.baseSysPermsService.departmentIds( |
| | | this.ctx.admin.userId |
| | |
| | | LEFT JOIN t_sys_department d on a.departmentId = d.id |
| | | WHERE 1 = 1 |
| | | ${this.setSql( |
| | | !_.isEmpty(departmentIds), |
| | | 'and a.departmentId in (?)', |
| | | [departmentIds] |
| | | )} |
| | | !_.isEmpty(departmentIds), |
| | | 'and a.departmentId in (?)', |
| | | [departmentIds] |
| | | )} |
| | | ${this.setSql(status, 'and a.status = ?', [status])} |
| | | ${this.setSql(keyWord, 'and (a.name LIKE ? or a.username LIKE ?)', [ |
| | | `%${keyWord}%`, |
| | | `%${keyWord}%`, |
| | | ])} |
| | | `%${keyWord}%`, |
| | | `%${keyWord}%`, |
| | | ])} |
| | | ${this.setSql(true, 'and a.username != ?', ['admin'])} |
| | | ${this.setSql( |
| | | this.ctx.admin.username !== 'admin', |
| | | 'and a.departmentId in (?)', |
| | | [!_.isEmpty(permsDepartmentArr) ? permsDepartmentArr : [null]] |
| | | )} |
| | | this.ctx.admin.username !== 'admin', |
| | | 'and a.departmentId in (?)', |
| | | [!_.isEmpty(permsDepartmentArr) ? permsDepartmentArr : [null]] |
| | | )} |
| | | GROUP BY a.id |
| | | `; |
| | | return this.sqlRenderPage(sql, query); |
| | |
| | | * @param param |
| | | */ |
| | | async add(param) { |
| | | console.log(param, "param") |
| | | const exists = await this.baseSysUserEntity.findOne({ |
| | | username: param.username, |
| | | }); |
| | | console.log(exists, "exists") |
| | | if (!_.isEmpty(exists)) { |
| | | throw new CoolCommException('用户名已经存在~'); |
| | | } |