import { defHttp } from '/@/utils/http/axios';
import { setParams } from '/@/utils/index';

enum Api {
  sysConstantQueryPage = '/sys/constant/constantmenu/query/page',
  sysConstantDetail = '/sys/constant/constantmenu/detail',
  sysConstantAdd = '/sys/constant/constantmenu/add',
  sysConstantEdit = '/sys/constant/constantmenu/edit',
  sysConstantRemove = '/sys/constant/constantmenu/removeByIds',
}

/**
 *
 * @author zsl
 * @date  2023/05/18 15:54
 * @description: 根据条件查询常量菜单列表,权限 - constant:constant:query
 * @method: POST
 * @param:
 *       {String}  code  like   目录编码
 *       {Boolean}  disable  eq   是否可用
 * @return:
 *       {String}  type  目录类型
 *       {String}  code  目录编码
 *       {String}  name  菜单名称
 *       {String}  parentId  上级菜单
 *       {Integer}  sort  排序
 *       {String}  remarks  备注
 *       {Boolean}  disable  是否可用
 *       {String}  remark  备注
 */

export const sysConstantQueryPage = (params?: object) => {
  return defHttp.post({ url: Api.sysConstantQueryPage, params: setParams(params) });
};
/**
 *
 * @author zsl
 * @date  2023/05/18 15:54
 * @description: 根据id查询常量菜单详细信息,权限 - constant:constant:query
 * @method: GET
 * @param:  id 常量菜单主键id
 * @return:
 *       {String}  type  目录类型
 *       {String}  code  目录编码
 *       {String}  name  菜单名称
 *       {String}  parentId  上级菜单
 *       {Integer}  sort  排序
 *       {String}  remarks  备注
 *       {Boolean}  disable  是否可用
 *       {String}  remark  备注
 */
export const sysConstantDetail = (id: string) => {
  return defHttp.get({ url: Api.sysConstantDetail + '/' + id });
};

/**
 *
 * @author zsl
 * @date  2023/05/18 15:54
 * @description: 添加常量菜单,权限 - constant:constant:add
 * @method: POST
 * @param:
 *       {String}  type  目录类型
 *       {String}  code  目录编码
 *       {String}  name  菜单名称
 *       {String}  parentId  上级菜单
 *       {Integer}  sort  排序
 *       {String}  remarks  备注
 *       {Boolean}  disable  是否可用
 *       {String}  remark  备注
 * @return:
 *       0 添加失败
 *       1 添加成功
 */
export const sysConstantAdd = (params?: object) => {
  return defHttp.post({ url: Api.sysConstantAdd, params: params });
};

/**
 *
 * @author zsl
 * @date  2023/05/18 15:54
 * @description: 通过主键id编辑常量菜单,权限 - constant:constant:edit
 * @method: POST
 * @param:
 *       {String}  type  目录类型
 *       {String}  code  目录编码
 *       {String}  name  菜单名称
 *       {String}  parentId  上级菜单
 *       {Integer}  sort  排序
 *       {String}  remarks  备注
 *       {Boolean}  disable  是否可用
 *       {String}  remark  备注
 * @return:
 *       0 编辑失败
 *       1 编辑成功
 */
export const sysConstantEdit = (params?: object) => {
  return defHttp.post({ url: Api.sysConstantEdit, params: params });
};

/**
 * @description: 删除,权限 - constant:constant:remove
 * @method: POST
 */
export const sysConstantRemove = (params: Array<string | number>) => {
  return defHttp.post({ url: Api.sysConstantRemove, params: params });
};
