2025-12-29 First Commit
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import './clock_in_model.dart';
|
||||
import '../services/generic_api_service.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class ClockInApiService {
|
||||
final GenericApiService _apiService = GenericApiService();
|
||||
|
||||
// 獲取個人打卡歷史 (預設按時間降冪)
|
||||
Future<List<ClockInRecord>> fetchHistory(String userId) async {
|
||||
String queryFilter = "1^100^ClockInDateTime^*^ClockInUserId^=^$userId";
|
||||
|
||||
return await _apiService.fetchList<ClockInRecord>(
|
||||
tableName: "hrs_ClockInRecord",
|
||||
pk: "ClockInId",
|
||||
queryFilter: queryFilter,
|
||||
fromJson: (json) => ClockInRecord.fromJson(json),
|
||||
);
|
||||
}
|
||||
|
||||
// 新增打卡紀錄 (POST)
|
||||
Future<bool> postClockIn(ClockInRecord record) async {
|
||||
// 假設後端有一個通用保存 API
|
||||
final data = {
|
||||
"ClockInUserId": record.userId,
|
||||
"ClockInDateTime": DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
|
||||
"ClockInLatitude": record.latitude,
|
||||
"ClockInLongitude": record.longitude,
|
||||
"ClockInType": record.type,
|
||||
"ClockInStoreId": record.storeId,
|
||||
"CreatorId": record.userId,
|
||||
"CreateDateTime": DateFormat('yyyy-MM-dd HH:mm:ss').format(DateTime.now()),
|
||||
};
|
||||
|
||||
// 呼叫 API 並回傳結果
|
||||
// return await _apiService.saveData("hrs_ClockInRecord", data);
|
||||
return true; // 模擬成功
|
||||
}
|
||||
|
||||
// 在 ClockInApiService 類別中新增:
|
||||
Future<List<ClockInStore>> fetchStores() async {
|
||||
return await _apiService.fetchList<ClockInStore>(
|
||||
tableName: "hrs_ClockInStore",
|
||||
pk: "StoreId",
|
||||
queryFilter: "1^100^StoreId^*^^^Stat^Y", // 僅抓取啟用狀態為 Y 的店點
|
||||
fromJson: (json) => ClockInStore.fromJson(json),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user