import { Common, User } from "@/api/interface/index";
import { PORT1 } from "@/api/config/servicePort";
import http from "@/api";

/**
 * @name 公共模块
 */

// 获取字典数据
export const getDictOptions = (code: string, params?: any) => {
  return http.get<Common.DictOptions[]>(PORT1 + `/system/dict/data/type/${code}`, params, { loading: false });
};

// 获取个人信息
export const getUserInfoApi = () => {
  return http.get<Common.UserInfo>(PORT1 + "/getInfo");
};

// 修改个人密码
export const updateProfilePwd = (params: { oldPassword: string; newPassword: string }) => {
  return http.put(PORT1 + `/system/user/profile/updatePwd?oldPassword=${params.oldPassword}&newPassword=${params.newPassword}`);
};

// 获取首见条文下拉框数据
export const getFirstClauseOptions = () => {
  return http.get<Common.ClauseOptions[]>(PORT1 + `/article/first/dropDownList`, {}, { loading: false });
};

// 通用查询条文属性列表
export const getAttrTreeList = () => {
  return http.get<Common.ResTreeOptions[]>(PORT1 + `/attributeLib/allTreeList`, {}, { loading: false });
};

// 通用查询命名列表
export const getTagTreeList = () => {
  return http.get<Common.ResTreeOptions[]>(PORT1 + `/tagLib/allTreeList`, {}, { loading: false });
};

// 通用查询命名列表
export const getWordTreeList = () => {
  return http.get<Common.ResTreeOptions[]>(PORT1 + `/standardWordLib/allTreeList`, {}, { loading: false });
};

// 通用查询用户列表
export const getAllUserList = () => {
  return http.get<User.ResUserList[]>(PORT1 + `/article/anno/userList`, {}, { loading: false });
};
