182 lines
5.7 KiB
Dart
182 lines
5.7 KiB
Dart
|
import 'dart:async';
|
||
|
import 'dart:io';
|
||
|
import 'package:dio/dio.dart';
|
||
|
import 'package:sk_base_mobile/constants/global_url.dart';
|
||
|
import 'package:sk_base_mobile/models/base_response.dart';
|
||
|
import 'package:sk_base_mobile/services/dio.service.dart';
|
||
|
import '../constants/constants.dart';
|
||
|
|
||
|
class Api {
|
||
|
/// 登录
|
||
|
static Future<Response> login(String username, String password) {
|
||
|
return DioService.dio.post(
|
||
|
Urls.login,
|
||
|
data: {'username': username, 'password': password},
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/// 删除报价模板列表
|
||
|
static Future<Response<PaginationData>> deleteSaleQuotationTemplate(int id) {
|
||
|
return DioService.dio
|
||
|
.delete<PaginationData>('${Urls.saleQuotationTemplate}/$id');
|
||
|
}
|
||
|
|
||
|
/// 获取报价模板列表
|
||
|
static Future<Response<PaginationData>> getSaleQuotationTemplate(
|
||
|
{Map? params}) {
|
||
|
return DioService.dio.get<PaginationData>(Urls.saleQuotationTemplate,
|
||
|
queryParameters: {'page': 1, 'pageSize': 99, ...(params ?? {})});
|
||
|
}
|
||
|
|
||
|
/// 获取报价配件列表
|
||
|
static Future<Response<PaginationData>> getSaleQuotationComponents(
|
||
|
{Map? params}) {
|
||
|
return DioService.dio.get<PaginationData>(Urls.saleQuotationComponent,
|
||
|
queryParameters: {'page': 1, 'pageSize': 99, ...(params ?? {})});
|
||
|
}
|
||
|
|
||
|
/// 获取报价分组列表
|
||
|
static Future<Response<PaginationData>> getSaleQuotationGroups(
|
||
|
{Map? params}) {
|
||
|
return DioService.dio.get<PaginationData>(Urls.saleQuotationGroup,
|
||
|
queryParameters: {'page': 1, 'pageSize': 99, ...(params ?? {})});
|
||
|
}
|
||
|
|
||
|
/// 获取权限资源
|
||
|
static Future<Response> getResources() {
|
||
|
return DioService.dio.get(Urls.accountResources);
|
||
|
}
|
||
|
|
||
|
/// 获取分页角色列表
|
||
|
static Future<Response<PaginationData>> getRoles(Map params) {
|
||
|
return DioService.dio.get<PaginationData>(Urls.roles,
|
||
|
queryParameters: {'page': 1, 'pageSize': 10, ...params});
|
||
|
}
|
||
|
|
||
|
/// 获取部门树
|
||
|
static Future<Response> getDepts() {
|
||
|
return DioService.dio.get(Urls.depts);
|
||
|
}
|
||
|
|
||
|
/// 查询参数配置信息By key
|
||
|
static Future<Response> getSystemParamConfigByCode(String code) {
|
||
|
return DioService.dio.get(
|
||
|
'${Urls.systemParamConfig}/key/$code',
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/// 获取我的个人信息
|
||
|
static Future<Response> getMyProfile() {
|
||
|
return DioService.dio.get(
|
||
|
Urls.myProfile,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/// 获取个人信息
|
||
|
static Future<Response> getUserInfo(int userid) {
|
||
|
return DioService.dio.get('${Urls.sysUser}/$userid');
|
||
|
}
|
||
|
|
||
|
/// 更新个人信息
|
||
|
static Future<Response> updateUserInfo(int userid, Map params) {
|
||
|
return DioService.dio.put('${Urls.sysUser}/$userid', data: params);
|
||
|
}
|
||
|
|
||
|
/// 分页获取项目列表
|
||
|
static Future<Response<PaginationData>> getProjects(Map params) {
|
||
|
return DioService.dio.get<PaginationData>(Urls.projects,
|
||
|
queryParameters: {'page': 1, 'pageSize': 10, ...params});
|
||
|
}
|
||
|
|
||
|
/// 分页获取产品列表
|
||
|
static Future<Response<PaginationData>> getProducts(Map params) {
|
||
|
return DioService.dio.get<PaginationData>(Urls.products,
|
||
|
queryParameters: {'page': 1, 'pageSize': 10, ...params});
|
||
|
}
|
||
|
|
||
|
/// 分页获取原材料出入库列表
|
||
|
static Future<Response<PaginationData>> getInventoryInout(Map params) {
|
||
|
return DioService.dio.get<PaginationData>(Urls.inventoryInout,
|
||
|
queryParameters: {'page': 1, 'pageSize': 10, ...(params)});
|
||
|
}
|
||
|
|
||
|
/// 获取原材料出入库详情
|
||
|
static Future<Response> getInventoryInOutInfo(int id) {
|
||
|
return DioService.dio.get(
|
||
|
'${Urls.inventoryInout}/$id',
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/// 创建出入库记录
|
||
|
static Future<Response> createInventoryInout(Map params) {
|
||
|
return DioService.dio.post(Urls.inventoryInout, data: params);
|
||
|
}
|
||
|
|
||
|
/// 创建报价计算模板
|
||
|
static Future<Response> createSaleQuotationTemplate(Map params) {
|
||
|
return DioService.dio.post(Urls.saleQuotationTemplate, data: params);
|
||
|
}
|
||
|
|
||
|
/// 更新报价计算模板
|
||
|
static Future<Response> updateSaleQuotationTemplate(int id, Map params) {
|
||
|
return DioService.dio
|
||
|
.put('${Urls.saleQuotationTemplate}/$id', data: params);
|
||
|
}
|
||
|
|
||
|
/// 更新出入库记录
|
||
|
static Future<Response> updateInventoryInout(int id, Map params) {
|
||
|
return DioService.dio.put('${Urls.inventoryInout}/$id', data: params);
|
||
|
}
|
||
|
|
||
|
/// 分页获取库存列表
|
||
|
static Future<Response<PaginationData>> getInventory(Map params) {
|
||
|
return DioService.dio.get<PaginationData>(Urls.inventory,
|
||
|
queryParameters: {'page': 1, 'pageSize': 10, ...(params)});
|
||
|
}
|
||
|
|
||
|
/// 分页获取用户
|
||
|
static Future<Response<PaginationData>> getUsers(Map params) {
|
||
|
return DioService.dio.get<PaginationData>(Urls.sysUser,
|
||
|
queryParameters: {'page': 1, 'pageSize': 10, ...(params)});
|
||
|
}
|
||
|
|
||
|
/// 一次性获取所有的字典类型(不分页)
|
||
|
static Future<Response> getDictTypeAll(Map params) {
|
||
|
return DioService.dio.post(Urls.getDictType, data: params);
|
||
|
}
|
||
|
|
||
|
static Future<Response> logout() {
|
||
|
return DioService.dio.post(
|
||
|
Urls.logout,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
static Future<Response> deleteAccount() {
|
||
|
return DioService.dio.post(
|
||
|
Urls.deleteAccount,
|
||
|
);
|
||
|
}
|
||
|
|
||
|
static Future<Response> saveUserInfo(Map<String, dynamic> data) {
|
||
|
return DioService.dio.post(Urls.saveUserInfo, data: data);
|
||
|
}
|
||
|
|
||
|
static Future<Response> uploadImg(File file,
|
||
|
{String? bussinessModule, String? bussinessRecordId}) async {
|
||
|
String fileName = file.path.split('/').last;
|
||
|
final filePath =
|
||
|
await MultipartFile.fromFile(file.path, filename: fileName);
|
||
|
final formData = FormData.fromMap({
|
||
|
'bussinessRecordId': bussinessRecordId,
|
||
|
'bussinessModule': bussinessModule,
|
||
|
'file': filePath,
|
||
|
});
|
||
|
return DioService.dio.post(Urls.uploadAttachemnt, data: formData);
|
||
|
}
|
||
|
|
||
|
static Future<Response> updateAvatar(String filename) {
|
||
|
return DioService.dio
|
||
|
.post(Urls.updateAvatar, data: {'avatarPath': filename});
|
||
|
}
|
||
|
}
|