|
@@ -0,0 +1,506 @@
|
|
|
+import 'dart:typed_data';
|
|
|
+
|
|
|
+import 'package:domain/entity/response/job_template_edit_index_entity.dart';
|
|
|
+import 'package:domain/entity/response/job_template_s_g_entity.dart';
|
|
|
+import 'package:domain/entity/response/job_title_edit_index_entity.dart';
|
|
|
+import 'package:domain/entity/response/job_title_s_g_entity.dart';
|
|
|
+import 'package:get/get.dart';
|
|
|
+import 'package:plugin_platform/dio_export.dart';
|
|
|
+import 'package:plugin_platform/http/http_provider.dart';
|
|
|
+import 'package:plugin_platform/http/http_result.dart';
|
|
|
+import 'package:shared/utils/util.dart';
|
|
|
+
|
|
|
+import '../constants/api_constants.dart';
|
|
|
+
|
|
|
+/// 用工相关(新加坡)
|
|
|
+class LabourSGRepository extends GetxService {
|
|
|
+ HttpProvider httpProvider;
|
|
|
+
|
|
|
+ LabourSGRepository({required this.httpProvider});
|
|
|
+
|
|
|
+ /// 用工模版中的工作标题列表
|
|
|
+ Future<HttpResult<JobTitleSGEntity>> fetchJobTitleList(
|
|
|
+ String? keyword, {
|
|
|
+ required int curPage,
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ //参数
|
|
|
+ Map<String, String> params = {};
|
|
|
+ params["cur_page"] = curPage.toString();
|
|
|
+ params["page_size"] = "10";
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(keyword)) {
|
|
|
+ params["keyword"] = keyword!;
|
|
|
+ }
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTitleListSG,
|
|
|
+ params: params,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = JobTitleSGEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert<JobTitleSGEntity>(data: data);
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 根据ID获取主列表的Item数据,用于刷新Item
|
|
|
+ Future<HttpResult<JobTitleSGEntity>> fetchJobTitleListByIds(
|
|
|
+ String? ids, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ //参数
|
|
|
+ Map<String, String> params = {};
|
|
|
+ params["cur_page"] = "1";
|
|
|
+ params["page_size"] = "9999";
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(ids)) {
|
|
|
+ params["ids"] = ids!;
|
|
|
+ }
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTitleListSG,
|
|
|
+ params: params,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = JobTitleSGEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert<JobTitleSGEntity>(data: data);
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 添加工作标题的详情或选项数据
|
|
|
+ Future<HttpResult<JobTitleEditIndexEntity>> fetchJobTitleAddIndex({
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTitleAddIndexSG,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = JobTitleEditIndexEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert<JobTitleEditIndexEntity>(data: data);
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 编辑工作标题的详情或选项数据
|
|
|
+ Future<HttpResult<JobTitleEditIndexEntity>> fetchJobTitleEditIndex(
|
|
|
+ String? titleId, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ Map<String, String> params = {};
|
|
|
+ params["title_id"] = titleId ?? "";
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTitleEditIndexSG,
|
|
|
+ params: params,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = JobTitleEditIndexEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert<JobTitleEditIndexEntity>(data: data);
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 添加工作标题的提交
|
|
|
+ Future<HttpResult> addJobTitleSubmit(
|
|
|
+ String? jobTitle,
|
|
|
+ String? sort,
|
|
|
+ String? templateId, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ //参数
|
|
|
+ Map<String, String> params = {};
|
|
|
+ params['job_title'] = jobTitle ?? "";
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(templateId)) {
|
|
|
+ params["template_id"] = templateId!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(sort)) {
|
|
|
+ params["sort"] = sort!;
|
|
|
+ }
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTitleAddSubmitSG,
|
|
|
+ method: HttpMethod.POST,
|
|
|
+ params: params,
|
|
|
+ networkDebounce: true,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 编辑工作标题的提交
|
|
|
+ Future<HttpResult> editJobTitleSubmit(
|
|
|
+ String? titleId,
|
|
|
+ String? jobTitle,
|
|
|
+ String? sort,
|
|
|
+ String? templateId, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ //参数
|
|
|
+ Map<String, String> params = {};
|
|
|
+ params['job_title'] = jobTitle ?? "";
|
|
|
+ params['title_id'] = titleId ?? "";
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(templateId)) {
|
|
|
+ params["template_id"] = templateId!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(sort)) {
|
|
|
+ params["sort"] = sort!;
|
|
|
+ }
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTitleEditSubmitSG,
|
|
|
+ method: HttpMethod.POST,
|
|
|
+ params: params,
|
|
|
+ networkDebounce: true,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 删除工作标题的提交
|
|
|
+ Future<HttpResult> deleteJobTitleSubmit(
|
|
|
+ String? titleId, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ //参数
|
|
|
+ Map<String, String> params = {};
|
|
|
+
|
|
|
+ params['title_id'] = titleId ?? "";
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTitleDeleteSG,
|
|
|
+ method: HttpMethod.POST,
|
|
|
+ params: params,
|
|
|
+ networkDebounce: true,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ // =================================== Template ↓ ===================================
|
|
|
+
|
|
|
+ /// 用工模版中的工作标题列表
|
|
|
+ Future<HttpResult<JobTemplateSGEntity>> fetchJobTemplateList(
|
|
|
+ String? keyword, {
|
|
|
+ required int curPage,
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ //参数
|
|
|
+ Map<String, String> params = {};
|
|
|
+ params["cur_page"] = curPage.toString();
|
|
|
+ params["page_size"] = "10";
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(keyword)) {
|
|
|
+ params["keyword"] = keyword!;
|
|
|
+ }
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTemplateListSG,
|
|
|
+ params: params,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = JobTemplateSGEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert<JobTemplateSGEntity>(data: data);
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 根据ID获取主列表的Item数据,用于刷新Item
|
|
|
+ Future<HttpResult<JobTemplateSGEntity>> fetchJobTemplateListByIds(
|
|
|
+ String? ids, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ //参数
|
|
|
+ Map<String, String> params = {};
|
|
|
+ params["cur_page"] = "1";
|
|
|
+ params["page_size"] = "9999";
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(ids)) {
|
|
|
+ params["ids"] = ids!;
|
|
|
+ }
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTemplateListSG,
|
|
|
+ params: params,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = JobTemplateSGEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert<JobTemplateSGEntity>(data: data);
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 添加工作模板的详情或选项数据
|
|
|
+ Future<HttpResult<JobTemplateEditIndexEntity>> fetchJobTemplateAddIndex({
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTemplateAddIndexSG,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = JobTemplateEditIndexEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert<JobTemplateEditIndexEntity>(data: data);
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 编辑工作模板的详情或选项数据
|
|
|
+ Future<HttpResult<JobTemplateEditIndexEntity>> fetchJobTemplateEditIndex(
|
|
|
+ String? templateId, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ Map<String, String> params = {};
|
|
|
+ params["template_id"] = templateId ?? "";
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTemplateEditIndexSG,
|
|
|
+ params: params,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ final json = result.getDataJson();
|
|
|
+ var data = JobTemplateEditIndexEntity.fromJson(json!);
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert<JobTemplateEditIndexEntity>(data: data);
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 添加工作模板的提交
|
|
|
+ Future<HttpResult> addJobTemplateSubmit(
|
|
|
+ String? name,
|
|
|
+ String? contact,
|
|
|
+ String? contact_no,
|
|
|
+ String? description,
|
|
|
+ String? note,
|
|
|
+ String? age,
|
|
|
+ String? sex,
|
|
|
+ String? with_food_cert,
|
|
|
+ String? language, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ //参数
|
|
|
+ Map<String, String> params = {};
|
|
|
+ params['name'] = name ?? "";
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(contact)) {
|
|
|
+ params["contact"] = contact!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(contact_no)) {
|
|
|
+ params["contact_no"] = contact_no!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(description)) {
|
|
|
+ params["description"] = description!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(note)) {
|
|
|
+ params["note"] = note!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(age)) {
|
|
|
+ params["age"] = age!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(sex)) {
|
|
|
+ params["sex"] = sex!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(with_food_cert)) {
|
|
|
+ params["with_food_cert"] = with_food_cert!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(language)) {
|
|
|
+ params["language"] = language!;
|
|
|
+ }
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTemplateAddSubmitSG,
|
|
|
+ method: HttpMethod.POST,
|
|
|
+ params: params,
|
|
|
+ networkDebounce: true,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 编辑工作模板的提交
|
|
|
+ Future<HttpResult> editJobTemplateSubmit(
|
|
|
+ String? templateId,
|
|
|
+ String? name,
|
|
|
+ String? contact,
|
|
|
+ String? contact_no,
|
|
|
+ String? description,
|
|
|
+ String? note,
|
|
|
+ String? age,
|
|
|
+ String? sex,
|
|
|
+ String? with_food_cert,
|
|
|
+ String? language, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ //参数
|
|
|
+ Map<String, String> params = {};
|
|
|
+ params['name'] = name ?? "";
|
|
|
+ params['template_id'] = templateId ?? "";
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(contact)) {
|
|
|
+ params["contact"] = contact!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(contact_no)) {
|
|
|
+ params["contact_no"] = contact_no!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(description)) {
|
|
|
+ params["description"] = description!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(note)) {
|
|
|
+ params["note"] = note!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(age)) {
|
|
|
+ params["age"] = age!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(sex)) {
|
|
|
+ params["sex"] = sex!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(with_food_cert)) {
|
|
|
+ params["with_food_cert"] = with_food_cert!;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!Utils.isEmpty(language)) {
|
|
|
+ params["language"] = language!;
|
|
|
+ }
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTemplateEditSubmitSG,
|
|
|
+ method: HttpMethod.POST,
|
|
|
+ params: params,
|
|
|
+ networkDebounce: true,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+
|
|
|
+ /// 删除工作标题的提交
|
|
|
+ Future<HttpResult> deleteJobTemplateSubmit(
|
|
|
+ String? templateId, {
|
|
|
+ CancelToken? cancelToken,
|
|
|
+ }) async {
|
|
|
+ //参数
|
|
|
+ Map<String, String> params = {};
|
|
|
+
|
|
|
+ params['template_id'] = templateId ?? "";
|
|
|
+
|
|
|
+ final result = await httpProvider.requestNetResult(
|
|
|
+ ApiConstants.apiJobTemplateDeleteSG,
|
|
|
+ method: HttpMethod.POST,
|
|
|
+ params: params,
|
|
|
+ networkDebounce: true,
|
|
|
+ isShowLoadingDialog: true,
|
|
|
+ cancelToken: cancelToken,
|
|
|
+ );
|
|
|
+
|
|
|
+ //根据返回的结果,封装原始数据为Bean/Entity对象
|
|
|
+ if (result.isSuccess) {
|
|
|
+ //重新赋值data或list
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+ return result.convert();
|
|
|
+ }
|
|
|
+}
|