95 lines
3.0 KiB
Dart
95 lines
3.0 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/models/dict_type.model.dart';
|
|
import 'package:sk_base_mobile/services/dio.service.dart';
|
|
import '../constants/constants.dart';
|
|
|
|
// 登录
|
|
Future<Response> login(String username, String password) {
|
|
return DioService.dio.post(
|
|
Urls.login,
|
|
data: {'username': username, 'password': password},
|
|
);
|
|
}
|
|
|
|
// 获取个人信息
|
|
Future<Response> getUserInfo() {
|
|
return DioService.dio.get(
|
|
Urls.getUserInfo,
|
|
);
|
|
}
|
|
|
|
// 分页获取项目列表
|
|
Future<Response<PaginationData>> getProjects(Map params) {
|
|
return DioService.dio.get<PaginationData>(Urls.getProjects,
|
|
queryParameters: {'page': 1, 'pageSize': 10, ...params});
|
|
}
|
|
|
|
// 分页获取产品列表
|
|
Future<Response<PaginationData>> getProducts(Map params) {
|
|
return DioService.dio.get<PaginationData>(Urls.getProducts,
|
|
queryParameters: {'page': 1, 'pageSize': 10, ...params});
|
|
}
|
|
|
|
// 分页获取原材料出入库列表
|
|
Future<Response<PaginationData>> getInventoryInout(Map params) {
|
|
return DioService.dio.get<PaginationData>(Urls.getInventoryInout,
|
|
queryParameters: {'page': 1, 'pageSize': 10, ...(params)});
|
|
}
|
|
|
|
// 一次性获取所有的字典类型(不分页)
|
|
Future<Response> getDictTypeAll(Map params) {
|
|
return DioService.dio.post(Urls.getDictType, data: params);
|
|
}
|
|
|
|
Future<Response> logout() {
|
|
return DioService.dio.post(
|
|
Urls.logout,
|
|
);
|
|
}
|
|
|
|
Future<Response> deleteAccount() {
|
|
return DioService.dio.post(
|
|
Urls.deleteAccount,
|
|
);
|
|
}
|
|
|
|
Future<Response> getAppConfig() {
|
|
Map<String, dynamic> query = {'ver': 0};
|
|
return DioService.dio.get(Urls.getAppConfig, queryParameters: query);
|
|
}
|
|
|
|
Future<Response> saveUserInfo(Map<String, dynamic> data) {
|
|
return DioService.dio.post(Urls.saveUserInfo, data: data);
|
|
}
|
|
|
|
Future<Response> uploadImg(File file) async {
|
|
// DateTime dateTime = DateTime.now();
|
|
// String fileName = file.path.split('/').last;
|
|
// String format = fileName.split('.').last;
|
|
// int imageTimeName = dateTime.millisecondsSinceEpoch +
|
|
// (dateTime.microsecondsSinceEpoch ~/ 1000000);
|
|
// String imageName = '$imageTimeName.$format';
|
|
// String host = AppInfoService.to.ossPolicy.host!;
|
|
// String dir = AppInfoService.to.ossPolicy.dir!;
|
|
// final filePath = await MultipartFile.fromFile(file.path, filename: fileName);
|
|
// final formData = FormData.fromMap({
|
|
// 'ossaccessKeyId': AppInfoService.to.ossPolicy.accessKeyId,
|
|
// 'policy': AppInfoService.to.ossPolicy.policy,
|
|
// 'signature': AppInfoService.to.ossPolicy.signature,
|
|
// 'callback': AppInfoService.to.ossPolicy.callback,
|
|
// 'key': '$dir/$imageName',
|
|
// 'file': filePath,
|
|
// });
|
|
|
|
// return DioService.dio.post(host, data: formData);
|
|
return {} as Response;
|
|
}
|
|
|
|
Future<Response> updateAvatar(String filename) {
|
|
return DioService.dio.post(Urls.updateAvatar, data: {'avatarPath': filename});
|
|
}
|