mobile_skt/lib/apis/index.dart

123 lines
3.7 KiB
Dart
Raw Normal View History

2024-03-26 15:30:43 +08:00
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 {
2024-04-07 17:32:46 +08:00
/// 登录
2024-03-26 15:30:43 +08:00
static Future<Response> login(String username, String password) {
return DioService.dio.post(
Urls.login,
data: {'username': username, 'password': password},
);
}
2024-04-07 17:32:46 +08:00
/// 查询参数配置信息By key
static Future<Response> getSystemParamConfigByCode(String code) {
return DioService.dio.get(
'${Urls.systemParamConfig}/key/$code',
);
}
2024-04-09 08:31:17 +08:00
// 获取我的个人信息
static Future<Response> getMyProfile() {
2024-03-26 15:30:43 +08:00
return DioService.dio.get(
2024-03-28 15:13:27 +08:00
Urls.userInfo,
2024-03-26 15:30:43 +08:00
);
}
2024-04-09 08:31:17 +08:00
// 获取个人信息
static Future<Response> getUserInfo(int userid) {
return DioService.dio.get('${Urls.userInfo}/$userid');
}
2024-03-26 15:30:43 +08:00
// 分页获取项目列表
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> 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)});
}
2024-03-28 15:13:27 +08:00
// 分页获取用户
static Future<Response<PaginationData>> getUsers(Map params) {
return DioService.dio.get<PaginationData>(Urls.sysUser,
queryParameters: {'page': 1, 'pageSize': 10, ...(params)});
}
2024-03-26 15:30:43 +08:00
// 一次性获取所有的字典类型(不分页)
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});
}
}