fuchengshen
2022-06-28 b00ac813e5be3fedb10ca49e7e57a757295e19fe
src/app/modules/base/service/sys/user.ts
@@ -34,6 +34,7 @@
   * @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
@@ -50,21 +51,21 @@
            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);
@@ -117,9 +118,11 @@
   * @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('用户名已经存在~');
    }