const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");

class UserService extends ServiceBase {
    constructor() {
        super("auth", ServiceBase.getDaoName(UserService));
    }


    async register(user) {
        let ss = await this.dao.register(user);
    }

    async userPage(pageInfo, search) {
      var currentPage = Number(pageInfo.pageNo || 1);
      var pageSize = Number(pageInfo.pageSize || 10);

      var where = {};

      if (search.nickName) {
        where.nickName = {
          [this.db.Op.like]: "%" + search.nickName + "%"
        };
      }

      if (search.userName) {
        where.userName =  search.userName;
      }

      if (search.mobile) {
        where.mobile =  search.mobile;
      }

      if(search.isBack) {
        where.utype = Number(search.isBack) - 1;
      }

      var orderby = [
        ["id", 'desc']
      ];
      return await this.getPageList(currentPage, pageSize, where, orderby);

    }

}

module.exports = UserService;