const system = require("../../../system");
const ServiceBase = require("../../svems.base")
class UserService extends ServiceBase {
  constructor() {
    super();
    this.platformUtils = system.getObject("util.businessManager.opPlatformUtils");

  }

  /**
   *   添加 
   * @param {*} params 
   */
  async addUser(params) {
    try {
      // TODO 处理平台用户
      // var puser = await this.platformUtils.userInfo(params.ucname, params.password);
      params.ucid = await this.getBusUid("test");
      return await this.callms("uc", "addUser", params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  /**
   *   更新
   * @param {*} params 
   */
  async updUser(params) {
    try {
      return await this.callms("uc", "updUser", params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  async enabled(params) {
    try {
      return await this.callms("uc", "enabled", params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  /**
   *  删除 
   * @param {*} params 
   */
  async delUser(params) {
    try {
      return await this.callms("uc", "delUser", params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  /**
   *   查询明细
   * @param {*} params 
   */
  async queryById(params) {
    try {
      return await this.callms("uc", "userInfo", params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  /**
   * 根据pid查出子
   * @param {*} params 
   */
  async page(params) {
    try {
      return await this.callms("uc", "userPage", params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

  /**
   * 查询整个树结构
   * @param {*} params 
   */
  async tree(params) {
    try {
      return await this.callms("uc", "authTree", params);
    } catch (error) {
      return system.getResult(null, `系统错误 错误信息 ${error}`);
    }
  }

}
module.exports = UserService;