import { Injectable } from '@angular/core';
import {environment} from '../../environments/environment';
import {HttpClient} from '@angular/common/http';
import {CommonsService} from './commons.service';

@Injectable({
  providedIn: 'root'
})
export class UserService {

  constructor(
      private http: HttpClient,
      private common: CommonsService
  ) { }

  /**
   * 校验是否填写过密码
   *
   * @param userId  用户id
   * @param callBack 返回参数
   */
  public passwordIsEmpty(userId: number, callBack) {
    this.http.get(environment.baseUrl + 'bsUser/passwordIsEmpty?userId=' + userId).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 修改密码
   * @param param 参数
   * @param callBack 返回参数
   */
  public editPassword(param: object, callBack) {
    this.http.post(environment.baseUrl + 'bsUser/editPassword', param).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 查询用户列表
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public getListUser(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highUser/getListUser?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * @Author Sum1Dream
   * @methodName queryGold
   * @Description //获取金币统计
   * @Date 16:32 2021/9/22
   * @Param mod
   **/
  public queryGold(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highGoldRec/queryGold?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 获取金币情况
   *
   * @param  paramsObject   对象
   * @param  callBack   回调
   */
  public getGoldRecList(paramsObject: object, callBack) {
    this.http.get(environment.baseUrl + 'highGoldRec/getGoldRecList?' + this.common.getWhereCondition(paramsObject)).subscribe(data => {
      callBack(data);
    });
  }

  /**
   * 禁用启用当前用户
   *
   * @param userId  用户id
   * @param callBack 返回参数
   */
  public forbiddenUser(userId: number, callBack) {
    this.http.get(environment.baseUrl + 'highUser/forbiddenUser?userId=' + userId).subscribe(data => {
      callBack(data);
    });
  }


  /**
   * @Author Sum1Dream
   * @methodName setAgent
   * @Description // 设置代理商
   * @Date 15:41 2022/8/19
   * @Param userId: number, callBack
   */
    public setUpAgent(userId: number, callBack) {
        this.http.get(environment.baseUrl + 'highUser/setUpAgent?userId=' + userId).subscribe(data => {
            callBack(data);
        });
    }

}
