import request from '@/config/axios'
import type { TableData } from './types'
import SM4Util from '@/utils/sm4'

/** 获取用户列表 */
export const getUserListApi = (params: any) => {
  return request.post({ url: '/sysuser/allUser', params })
}

/** 批量删除数据接口 */
export const delUserListApi = (ids: string[] | number[]): Promise<IResponse> => {
  return request.post({ url: '/sysuser/batchDelUser', data: { ids } })
}

/** 删除数据接口 */
export const delUserApi = (id: string): Promise<IResponse> => {
  return request.post({ url: '/sysuser/delete', data: { id } })
}

/** 保存接口 */
export const saveUserApi = (data: Partial<TableData>): Promise<IResponse> => {
  return request.post({ url: '/sysuser/save', data })
}

/** 编辑| 查询接口 */
export const queryUserApi = (id: string | number): Promise<IResponse> => {
  return request.post({ url: '/sysuser/edit/getParams', data: { id } })
}

/** 重置密码接口 */
export const resetPassword = (id: string | number): Promise<IResponse> => {
  return request.post({ url: '/sysuser/resetPassword', data: { id } })
}

/** 批量重置密码接口 */
export const resetPasswordbatch = (ids: string[] | number[]): Promise<IResponse> => {
  const sm4 = new SM4Util()
  return request.post({
    url: '/sysuser/resetPasswordbatch',
    data: { ids, password: sm4.encryptData_ECB('123456') }
  })
}

/** 获取字典接口[部门&单位名称] */
export const getUserDictApi = (): Promise<IResponse> => {
  return request.post({ url: '/sysuser/initParams' })
}

/** 获取角色列表接口 */
export const getRoleListParamsApi = (): Promise<IResponse> => {
  return request.post({ url: '/sysuser/add/getParams' })
}

/** 判断是否存在登录号 */
export const checkUserNameApi = (username: string | number): Promise<IResponse> => {
  return request.post({ url: '/sysuser/checkname', data: { username } })
}

/** 获得当前登录用户系统组 */
export const getProfessionGroup = (): Promise<IResponse> => {
  return request.post({ url: '/system/spi/system/SysRoleProfession/SysRoleProfession' })
}






