|
-
- import 'package:flutter/cupertino.dart';
- import 'package:zhiying_comm/util/pdd_auth/pdd_auth_model.dart';
- import 'package:zhiying_comm/zhiying_comm.dart';
-
- class PddAuthRepository {
- ///
- /// 缓存style Data
- /// 多加一个goods_id 用于区分数据
- Future<bool> cacheData(String isShare) async {
- try {
- var result = await NetUtil.post('/api/v1/pdd/check/$isShare',
- method: NetMethod.GET,
- cache: true,
- );
- if (NetUtil.isSuccess(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) {
- return true;
- }
- } catch (e, s) {
- Logger.error(e, s);
- }
- return false;
- }
-
- ///
- /// 获取网络数据
- ///
- Future<PddAuthModel> fetchNetData({@required String isShare}) async{
- try {
- var result = await NetUtil.post('/api/v1/pdd/check/$isShare', method: NetMethod.GET);
- if (!EmptyUtil.isEmpty(result) && !EmptyUtil.isEmpty(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA])) {
- PddAuthModel model = PddAuthModel.fromJson(result[GlobalConfig.HTTP_RESPONSE_KEY_DATA]);
- return model;
- }
- } catch (e, s) {
- Logger.error(e, s);
- }
- return null;
- }
-
- ///
- /// 获取缓存的data
- /// 多加一个goods_id 用于区分数据
- ///
- Future<PddAuthModel> fetchCacheData(String isShare) async {
- try {
- var result = await NetUtil.getRequestCachedData('/api/v1/pdd/check/$isShare');
- if (!EmptyUtil.isEmpty(result)) {
- PddAuthModel model = PddAuthModel.fromJson(result);
- if (!EmptyUtil.isEmpty(model)) {
- return model;
- }
- }
- } catch (e, s) {
- Logger.error(e, s);
- }
- return null;
- }
- }
|