Commit 72c99147 authored by 汪林玲's avatar 汪林玲

Initial commit

parents
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
#.vscode/
# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
.packages
.pub-cache/
.pub/
build/
# Android related
**/android/**/gradle-wrapper.jar
**/android/.gradle
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*
# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
.vscode/
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
# This file should be version controlled and should not be manually edited.
version:
revision: 84f3d28555368a70270e9ac8390a9441df95e752
channel: stable
project_type: package
# 小熊网络模块
### 引入说明
```
xiaoxiong_repository:
git:
url: 'git@git.xiaomanxiong.com:flutter-plugin/app-xiaoxiong-repository.git'
ref: 'null-safety'
```
\ No newline at end of file
library xiaoxiong_repository;
export 'repository/config_repository.dart';
export 'repository/footprint_repository.dart';
export 'repository/suning_repository.dart';
export 'repository/price_repository.dart';
export 'entity/config_entity.dart';
export 'entity/suning_item_entity.dart';
export 'entity/turn_chain_entity.dart';
export 'entity/product_details_entity.dart';
export 'entity/map_place_entity.dart';
export 'entity/product_item_entity.dart';
export 'entity/share_poster_entity.dart';
export 'package:base_repository/base_repository.dart';
export 'package:base_repository/src/entity/ds_response_object.dart';
export 'entity/config_entity.dart';
export 'entity/turn_chain_entity.dart';
export 'repository/config_repository.dart';
export 'repository/footprint_repository.dart';
export 'repository/assets_repository.dart';
export 'repository/user_repository.dart';
export 'repository/price_repository.dart';
export 'repository/product_repository.dart';
\ No newline at end of file
class ConfigEntity {
String isAuditMode;
String version;
String adSwitch;
ConfigEntity({this.isAuditMode,this.version,this.adSwitch});
static ConfigEntity fromJson(Map<String, dynamic> json) {
return ConfigEntity(
isAuditMode: json['is_audit_mode']?.toString(),
version: json['version']?.toString(),
adSwitch: json['ad_switch']?.toString(),
);
}
Map<String, dynamic> toJson() {
return {
'is_audit_mode':this.isAuditMode,
'version':this.version,
'ad_switch':this.adSwitch,
};
}
}
\ No newline at end of file
class MapPlaceEntity {
String id;
String title;
String address;
String category;
int type;
MapLocation location;
int adcode;
String province;
String city;
String district;
MapPlaceEntity({
this.id,
this.title,
this.address,
this.category,
this.type,
this.location,
this.adcode,
this.province,
this.city,
this.district
});
static MapPlaceEntity fromJson(Map<String, dynamic> json) {
return MapPlaceEntity(
id: json['id']?.toString(),
title: json['title']?.toString(),
address: json['address']?.toString(),
category: json['category']?.toString(),
type: json['type'] as int,
location:MapLocation.fromJson(json['location']),
adcode: json['adcode'] as int,
province: json['province']?.toString(),
city: json['city']?.toString(),
district: json['district']?.toString(),
);
}
}
class MapLocation {
double lat;
double lng;
MapLocation({
this.lat,
this.lng
});
static MapLocation fromJson(Map<String, dynamic> json) {
return MapLocation(
lat:json['lat'] as double,
lng:json['lng'] as double,
);
}
}
\ No newline at end of file
class ProductDetailsEntity {
String id;
String itemId;
String itemTitle;
String platform;
List<String> itemPics;
String price;
String itemStatus;
String endPrice;
String special;
String description;
String collegeTimes;
String likeTimes;
String releaseTime;
String buttonText;
List<CouponInfo> couponInfos;
String userCommission;
String isCollect;
String isLike;
String checkText;
String shareUrl;
String shareMessage;
String couponText;
String isOverdue;
String shopTitle;
String rebate;
List<dynamic> collectOrders;
Map<String,dynamic> newItemInfo;
ProductDetailsEntity({
this.id,
this.itemId,
this.itemTitle,
this.platform,
this.itemPics,
this.price,
this.itemStatus,
this.endPrice,
this.special,
this.description,
this.collegeTimes,
this.likeTimes,
this.releaseTime,
this.buttonText,
this.couponInfos,
this.userCommission,
this.isCollect,
this.isLike,
this.checkText,
this.shareUrl,
this.shareMessage,
this.couponText,
this.isOverdue,
this.shopTitle,
this.rebate,
this.collectOrders,
this.newItemInfo
});
static ProductDetailsEntity fromJson(Map<String, dynamic> json) {
List<dynamic> couponInfos = List<dynamic>.from(json['coupon_info']);
return ProductDetailsEntity(
id: json['id']?.toString(),
itemId: json['item_id']?.toString(),
itemTitle: json['item_title']?.toString(),
platform: json['platform']?.toString(),
itemPics:List<String>.from(json['item_pic']),
price: json['price']?.toString(),
itemStatus: json['item_status']?.toString(),
endPrice: json['end_price']?.toString(),
special: json['special']?.toString(),
description: json['description']?.toString(),
collegeTimes: json['college_times']?.toString(),
likeTimes: json['like_times']?.toString(),
releaseTime:json['release_time']?.toString(),
buttonText:json['button_text']?.toString(),
couponInfos:List<CouponInfo>.generate(couponInfos.length, (index) => CouponInfo.fromJson(couponInfos[index])),
userCommission:json['user_commission']?.toString(),
isCollect:json['is_collect']?.toString(),
isLike:json['is_like']?.toString(),
checkText:json['check_text']?.toString(),
shareUrl:json['share_url']?.toString(),
couponText:json['coupon_text']?.toString(),
shareMessage:json['share_message']?.toString(),
isOverdue:json['is_overdue']?.toString(),
shopTitle:json['shop_title']?.toString(),
rebate:json['rebate']?.toString(),
collectOrders:(json['collect_orders'] is List)?List.from(json['collect_orders']):[],
newItemInfo:(json['new_item_info'] is Map)?Map<String,dynamic>.from(json['new_item_info']):null,
);
}
}
class CouponInfo {
String url;
String couponName;
String status;
CouponInfo({this.url,this.couponName,this.status});
static CouponInfo fromJson(Map<String, dynamic> json) {
return CouponInfo(
url:json['url']?.toString(),
couponName:json['coupon_name']?.toString(),
status:json['status']?.toString(),
);
}
}
class ProductItemEntity {
String id;
String platform;
String itemTitle;
String itemPic;
String special;
String releaseTime;
String endPrice;
String descriptionText;
List<dynamic> tags;
String rebate;
ProductItemEntity({this.id,this.platform,this.itemTitle,this.itemPic,this.special,this.releaseTime,this.rebate,this.tags,this.descriptionText,this.endPrice});
static ProductItemEntity fromJson(Map<String, dynamic> json) {
return ProductItemEntity(
id: json['id']?.toString(),
platform: json['platform']?.toString(),
itemTitle: json['item_title']?.toString(),
itemPic: json['item_pic']?.toString(),
special: json['special']?.toString(),
releaseTime: json['release_time']?.toString(),
endPrice: json['end_price']?.toString(),
descriptionText: json['description_text']?.toString(),
tags: (json['tags'] is List)?List.from(json['tags']):[],
rebate: json['rebate']?.toString(),
);
}
Map<String, dynamic> toJson() {
return {
'id':this.id,
'platform':this.platform,
'item_title':this.itemTitle,
'item_pic':this.itemPic,
'special':this.special,
'release_time':this.releaseTime,
'end_price':this.endPrice,
'description_text':this.descriptionText,
'tags':this.tags,
'rebate':this.rebate,
};
}
}
\ No newline at end of file
class SharePosterEntity {
String url;
List<String> sharePoster;
SharePosterEntity({this.url,this.sharePoster});
static SharePosterEntity fromJson(Map<String, dynamic> json) {
List<String> list = [];
if(json['share_poster'] is List){
list = List<String>.from(json['share_poster']);
}
return SharePosterEntity(
url: json['url']?.toString(),
sharePoster: list
);
}
Map<String, dynamic> toJson() {
return {
'url':this.url,
'share_poster':this.sharePoster,
};
}
}
\ No newline at end of file
class SuningItemEntity {
String itemId;
String sellerId;
String itemPic;
String itemTitle;
String discountType;
String discountAmount;
String shopTitle;
String userCommission;
String price;
String endPrice;
String volumeText;
String platform;
String priceText;
String discountText;
String userCommissionText;
SuningItemEntity({
this.itemId,
this.sellerId,
this.itemPic,
this.itemTitle,
this.discountType,
this.discountAmount,
this.shopTitle,
this.userCommission,
this.price,
this.endPrice,
this.volumeText,
this.platform,
this.priceText,
this.discountText,
this.userCommissionText,
});
static SuningItemEntity fromJson(Map<String, dynamic> json) {
return SuningItemEntity(
itemId: json['item_id']?.toString(),
sellerId: json['seller_id']?.toString(),
itemPic: json['item_pic']?.toString(),
itemTitle: json['item_title']?.toString(),
discountType: json['discount_type']?.toString(),
discountAmount: json['discount_amount']?.toString(),
shopTitle: json['shop_title']?.toString(),
userCommission: json['user_commission']?.toString(),
price: json['price']?.toString(),
endPrice: json['end_price']?.toString(),
volumeText: json['volume_text']?.toString(),
platform: json['platform']?.toString(),
priceText: json['price_text']?.toString(),
discountText: json['discount_text']?.toString(),
userCommissionText: json['user_commission_text']?.toString(),
);
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['item_id'] = this.itemId;
data['seller_id'] = this.sellerId;
data['item_pic'] = this.itemPic;
data['item_title'] = this.itemTitle;
data['discount_type'] = this.discountType;
data['discount_amount'] = this.discountAmount;
data['shop_title'] = this.shopTitle;
data['user_commission'] = this.userCommission;
data['price'] = this.price;
data['end_price'] = this.endPrice;
data['volume_text'] = this.volumeText;
data['platform'] = this.platform;
data['price_text'] = this.priceText;
data['discount_text'] = this.discountText;
data['user_commission_text'] = this.userCommissionText;
return data;
}
}
\ No newline at end of file
class TurnChainEntity {
String appLink;
String platform;
TurnChainEntity({this.appLink,this.platform});
static TurnChainEntity fromJson(Map<String, dynamic> json) {
return TurnChainEntity(
appLink: json['app_link']?.toString(),
platform: json['platform']?.toString(),
);
}
Map<String, dynamic> toJson() {
return {
'app_link':this.appLink,
'platform':this.platform,
};
}
}
\ No newline at end of file
import 'package:base_repository/base_repository.dart';
import 'package:flutter/material.dart';
import 'impl/assets_repository_impl.dart';
///
/// VirtualRepository
/// 虚拟资产相关的网络库
///
abstract class AssetsRepository {
static AssetsRepository get() {
return AssetsRepositoryImpl();
}
///
/// 获取免单商品列表
/// [page] 当前页
/// [pagesize] 每页显示数据量大小
/// [freeType] 1:天天免单 2:新人后返 3:直播超级返 4:拼多多免单 5:直播ysh免单,7程七直播免单 这一版只有5 和7
///
Future<DSResponseList> itemFreeList({
int page = 1,
int pagesize = 10,
@required int freeType,
});
///
/// 获取免单记录
/// [page] 当前页
/// [pagesize] 每页显示数据量大小
///
Future<DSResponseList<Map<String, dynamic>>> itemFreeRecord({
int page = 1,
int pagesize = 10,
});
///
/// 收益明细列表
/// [page] 当前页
/// [pagesize] 每页显示数据量大小
/// [source] 来源 1全部,2我的订单,3团队订单
/// [type] 类型 0全部 1人民币,2积分,3免单点
///
Future<DSResponseList> qryBillRecord({
int page = 1,
int pagesize = 10,
int source = 1,
int type = 0,
});
///
/// 收益明细详情
/// [id] 数据id
///
Future<DSResponseObject> qryBillRecordDetail({
@required String id,
});
///
/// 积分兑换
/// [type] 选中积分的类型
/// [value] 输入的自定义值
///
Future<DSResponseObject> scoreExchange({
@required String type,
String value,
});
///
/// 获取虚拟资产任务列表
///
Future<DSResponseList> getVirtualTask();
///
/// 领取任务奖励接口
/// [id] 任务Id
///
Future<DSResponseObject> receiveTaskAward({@required String id});
///
/// 获取广告位id
/// [type] 系统: 1、Android 2、iOS
/// [category] 1:激励视频广告 ,2:插屏广告,3:开屏广告 ,4:Banner广告,5.信息流广告,6.全屏广告,7.信息流广告
///
Future<DSResponseList<Map<String, dynamic>>> videoAdGetSite({@required int type,@required int category});
///
/// 观看视频的积分兑换
///
Future<DSResponseObject> videoScoreConvert();
}
import 'package:xiaoxiong_repository/entity/config_entity.dart';
import 'package:base_repository/base_repository.dart';
import 'impl/config_repository_impl.dart';
///
/// ConfigRepository
/// 配置相关的网络库
///
abstract class ConfigRepository {
static get() {
return ConfigRepositoryImpl();
}
///
/// 获取实时配置
/// 备注请求【{{v4}}config.getConfig】接口,如果缓存中配置版本字段小于这个接口中的version,需要拉取【{{v4}}config.commonList】获取全部配置
///
Future<DSResponseObject<ConfigEntity>> getConfig();
}
import 'impl/footprint_repository_impl.dart';
///
/// FootprintRepository
/// 足迹/点赞相关的网络库
///
abstract class FootprintRepository {
static get() {
return FootprintRepositoryImpl();
}
///
/// 删除用户足迹
///
Future<dynamic> deleteUserFootprint();
///
/// 猜你喜欢
/// [page] 第几页
/// [pagesize] 每页显示大小
///
Future<dynamic> getLikeList();
}
///
/// FreeOrderRepository
/// 免单商品相关的网络接口
///
abstract class FreeOrderRepository {
//
//
// var itemFreeItemUrl = v5Http.get("itemFree.itemUrl"); // 获取免单获取跳转链接 ok
//
///
/// 获取免单记录
///
Future<dynamic> getFreeRecords({
int page = 1,
int pagesize = 10,
});
}
import 'package:base_repository/base_repository.dart';
import 'package:flutter/material.dart';
import '../assets_repository.dart';
class AssetsRepositoryImpl extends AssetsRepository {
AssetsRepositoryImpl.get();
static final AssetsRepositoryImpl _instance = AssetsRepositoryImpl.get();
factory AssetsRepositoryImpl() {
return _instance;
}
@override
Future<DSResponseList> itemFreeList({
int page = 1,
int pagesize = 10,
@required int freeType,
}) async {
dynamic result = await DSDioUtil.getInstance().get(
'/itemFree.getItemList',
queryParameters: {
'page': page,
'pagesize': pagesize,
'free_type': freeType,
},
);
return DSResponseList.fromJson(
result,
(item){
String productId = "${item['id']}";
Map<String,dynamic> idata = Map<String, dynamic>.from(item);
idata['product_id'] = productId;
return idata;
},
);
}
@override
Future<DSResponseList> getVirtualTask() async {
dynamic result = await DSDioUtil.getInstance().get('/sign.getTask');
return DSResponseList.fromJson(
result,
(item) => Map<String, dynamic>.from(item),
);
}
@override
Future<DSResponseList> qryBillRecord({
int page = 1,
int pagesize = 10,
int source = 1,
int type = 0,
}) async {
dynamic result = await DSDioUtil.getInstance().get(
'/billRecord.list',
queryParameters: {
'page': page,
'pagesize': pagesize,
'source': source,
'type': type,
},
);
return DSResponseList.fromJson(
result,
(item) => Map<String, dynamic>.from(item),
);
}
@override
Future<DSResponseObject> qryBillRecordDetail({String id}) async {
dynamic result = await DSDioUtil.getInstance()
.get('/billRecord.detail', queryParameters: {'id': id});
return DSResponseObject.fromJson(
result,
(item) => Map<String, dynamic>.from(item),
);
}
@override
Future<DSResponseObject> receiveTaskAward({String id}) async {
dynamic result =
await DSDioUtil.getInstance().post('/sign.distributeReward',data:{'id':id});
return DSResponseObject.fromJson(
result,
(item) => Map<String, dynamic>.from(item),
);
}
@override
Future<DSResponseObject> scoreExchange({@required String type, String value}) async {
Map<String,dynamic> data = {};
if(type != null){
data['type'] = type;
}
if(value != null){
data['value'] = value;
}
dynamic result = await DSDioUtil.getInstance().post('/sign.scoreExchange',data:data);
return DSResponseObject.fromJson(
result,
(item) => Map<String, dynamic>.from(item),
);
}
@override
Future<DSResponseList<Map<String, dynamic>>> itemFreeRecord(
{int page = 1, int pagesize = 10}) async {
dynamic result = await DSDioUtil.getInstance().get('/itemFree.getRecord');
return DSResponseList.fromJson(
result,
(item) => Map<String, dynamic>.from(item),
);
}
///
/// 获取广告位id
/// [type] 系统: 1、Android 2、iOS
/// [category] 1:激励视频广告 ,2:插屏广告,3:开屏广告 ,4:Banner广告,5.信息流广告,6.全屏广告,7.信息流广告
///
@override
Future<DSResponseList<Map<String, dynamic>>> videoAdGetSite({int type, int category}) async{
dynamic result = await DSDioUtil.getInstance().get('/video.getSite',queryParameters:{'type':type,'category':category});
return DSResponseList.fromJson(
result,
(item) => Map<String, dynamic>.from(item),
);
}
@override
Future<DSResponseObject> videoScoreConvert() async{
dynamic result = await DSDioUtil.getInstance().post('/video.convert');
return DSResponseObject.fromJson(
result,
(data) => Map<String, dynamic>.from(data),
);
}
}
import 'package:base_repository/base_repository.dart';
import 'package:xiaoxiong_repository/entity/config_entity.dart';
import '../config_repository.dart';
class ConfigRepositoryImpl extends ConfigRepository {
@override
Future<DSResponseObject<ConfigEntity>> getConfig() async {
dynamic result = await DSDioUtil.getInstance().get('/config.getConfig');
return DSResponseObject<ConfigEntity>.fromJson(
result, ConfigEntity.fromJson);
}
}
import 'package:base_repository/base_repository.dart';
import '../footprint_repository.dart';
///
/// FootprintRepository
/// 足迹/点赞相关的实现网络库
///
class FootprintRepositoryImpl extends FootprintRepository {
FootprintRepositoryImpl.get();
static final FootprintRepositoryImpl _instance =
FootprintRepositoryImpl.get();
factory FootprintRepositoryImpl() {
return _instance;
}
///
/// 删除用户足迹
///
@override
Future deleteUserFootprint() async {
Options options = Options(headers: {'interceptor': 'interceptor1'});
dynamic result = await DSDioUtil.getInstance()
.post('viewRecord.deleteView', options: options);
return result;
}
@override
Future getLikeList() {
throw UnimplementedError();
}
}
import 'package:flutter/material.dart';
import 'package:base_repository/base_repository.dart';
import 'package:xiaoxiong_repository/entity/product_details_entity.dart';
import 'package:xiaoxiong_repository/entity/product_item_entity.dart';
import 'package:xiaoxiong_repository/entity/turn_chain_entity.dart';
import '../price_repository.dart';
class PriceRepositoryImpl extends PriceRepository {
PriceRepositoryImpl.get();
static final PriceRepositoryImpl _instance = PriceRepositoryImpl.get();
factory PriceRepositoryImpl() {
return _instance;
}
///
/// 获取好价商品列表
/// [page] 当前页数
/// [pagesize] 每页显示的数量
/// [keywords] 搜索的关键词
/// [filters] 过滤条件
///
@override
Future<DSResponseList<ProductItemEntity>> qryProductList(
{int page = 1,
int pagesize = 10,
String categoryId,
String excludeId,
String keywords,
List<dynamic> filters}) async {
Map<String, dynamic> query = {
'page': page,
'pagesize': pagesize,
};
if (keywords != null && keywords.isNotEmpty) {
query['keywords'] = keywords;
}
if (filters != null && filters.length > 0) {
query['filters'] = filters;
}
if (categoryId != null && categoryId.isNotEmpty) {
query['category_id'] = categoryId;
}
if (excludeId != null && excludeId.isNotEmpty) {
query['exclude_id'] = excludeId;
}
dynamic result = await DSDioUtil.getInstance()
.get('/itemSelling.getList', queryParameters: query);
return DSResponseList<ProductItemEntity>.fromJson(
result, ProductItemEntity.fromJson);
}
///
/// 获取商品详情
/// [id] 商品详情Id
///
@override
Future<DSResponseObject<ProductDetailsEntity>> qryProductDetails(
{String id}) async {
dynamic result = await DSDioUtil.getInstance()
.get('itemSelling.detail', queryParameters: {'id': id});
return DSResponseObject.fromJson(result, ProductDetailsEntity.fromJson);
}
///
/// 举报
/// [id] 举报的商品Id
/// [report_type] 举报的商品类型
///
@override
Future<DSResponseBool> report({String id, String reportType}) async {
dynamic result = await DSDioUtil.getInstance().post('itemSelling.report',
data: {'id': id, 'report_type': reportType});
return DSResponseBool.fromJson(result);
}
///
/// 用户点赞
///
///
@override
Future<DSResponseBool> userLike(
{@required String markId,
String type = '2',
String status = '1',
String platform = '20'}) async {
dynamic result = await DSDioUtil.getInstance().post('itemLike.userLike',
data: {
'mark_id': markId,
'type': type,
'status': status,
'platform': platform
});
return DSResponseBool.fromJson(result);
}
@override
Future<DSResponseBool> userCollect(
{String itemId,
String type = '2',
String platform = '20',
String status = '1'}) async {
dynamic result = await DSDioUtil.getInstance().post('collect.doCollect',
data: {
'item_id': itemId,
'type': type,
'status': status,
'platform': platform
});
return DSResponseBool.fromJson(result);
}
///
/// 通过商品Id进行转链
/// [itemId] 商品id
/// [platform] 平台,1淘宝 2京东 3拼多多 4唯品会 7、苏宁
/// [type] 转链类型 好价传6 默认为5
///
@override
Future<DSResponseObject<TurnChainEntity>> turnChainForItemId(
{String itemId,
String platform,
String type = '5',
String sellerId = ''}) async {
Map<String, dynamic> data = {
'item_id': itemId,
'platform': platform,
'type': type
};
if (sellerId != null && sellerId.isNotEmpty) {
data['seller_id'] = sellerId;
}
dynamic result = await DSDioUtil.getInstance()
.get('turnChain.getItemUrl', queryParameters: data);
return DSResponseObject<TurnChainEntity>.fromJson(
result, TurnChainEntity.fromJson);
}
///
/// 好价推荐列表
/// [keywords] 搜索关键词
/// [excludeId] 排除id
/// [page] 当前页码
/// [pagesize] 当前页显示的大小
///
@override
Future<DSResponseList<ProductItemEntity>> getSellingRecommends({
String keywords,
String excludeId,
int page = 1,
int pagesize = 10,
}) async {
Map<String, dynamic> data = {'page': page, 'pagesize': pagesize};
if (keywords != null) {
data['keywords'] = keywords;
}
if (excludeId != null) {
data['exclude_id'] = excludeId;
}
dynamic result = await DSDioUtil.getInstance()
.get('itemSelling.getRecommends', queryParameters: data);
return DSResponseList<ProductItemEntity>.fromJson(
result, ProductItemEntity.fromJson);
}
}
import 'package:base_repository/base_repository.dart';
import 'package:flutter/material.dart';
import '../product_repository.dart';
class ProductRepositoryImpl extends ProductRepository {
ProductRepositoryImpl.get();
static final ProductRepositoryImpl _instance = ProductRepositoryImpl.get();
factory ProductRepositoryImpl() {
return _instance;
}
@override
Future<DSResponseList> getNines({
int page = 1,
int pagesize = 10,
@required int type,
}) async {
dynamic result =
await DSDioUtil.getInstance().get('/item.getNine', queryParameters: {
'page': page,
'type': type,
'pagesize': pagesize,
});
return DSResponseList.fromJson(
result,
(item) => Map<String, dynamic>.from(item),
);
}
@override
Future<DSResponseObject> qryGoFreeBuy({String id, int needUrl}) async {
dynamic result = await DSDioUtil.getInstance()
.post('/itemFree.goBuy', data: {'id': id, 'need_url': needUrl});
return DSResponseObject.fromJson(
result,
(data) => Map<String, dynamic>.from(data),
);
}
@override
Future<DSResponseObject> qryFreeShareInfo() async {
dynamic result =
await DSDioUtil.getInstance().get('/itemFree.getShareInfo');
return DSResponseObject.fromJson(
result,
(data) => Map<String, dynamic>.from(data),
);
}
@override
Future<DSResponseObject> qryFreeProductResult({@required String id}) async{
dynamic result = await DSDioUtil.getInstance().get('/itemFree.getItemResult',queryParameters:{'id':id});
return DSResponseObject.fromJson(result,(data) => Map<String, dynamic>.from(data));
}
}
import 'package:dio/dio.dart';
import 'package:base_repository/base_repository.dart';
import 'package:xiaoxiong_repository/entity/suning_item_entity.dart';
import '../suning_repository.dart';
class SuningRepositoryImpl extends SuningRepository {
SuningRepositoryImpl.get();
static final SuningRepositoryImpl _instance = SuningRepositoryImpl.get();
factory SuningRepositoryImpl() {
return _instance;
}
///
/// 苏宁商品【商品主页】
/// [eliteId] 1、苏宁主页 2、实时热销 3、当日热购 4、高佣爆款 6、9.9专区
/// [page] 当前页
/// [pagesize] 每页显示大小
///
@override
Future<DSResponseList<SuningItemEntity>> getSuningList(
{String eliteId = '1', int page = 1, int pagesize = 10}) async {
dynamic result = await DSDioUtil.getInstance()
.get('suningItem.getSuningItemList', queryParameters: {
'elite_id': eliteId,
'page': page,
'pagesize': pagesize
});
return DSResponseList.fromJson(result, SuningItemEntity.fromJson);
}
///
/// 苏宁活动转链
/// [itemUrl] 待转链的苏宁商品链接
///
@override
Future<dynamic> suningActTurnChainLink({String itemUrl}) async {
Options options = Options(headers: {'interceptor': 'interceptor1'});
dynamic result = await DSDioUtil.getInstance().post(
'turnchain.suningActLink',
data: {'item_url': itemUrl},
options: options);
return result;
}
}
import 'package:base_repository/base_repository.dart';
import 'package:xiaoxiong_repository/entity/map_place_entity.dart';
import '../tencent_repository.dart';
class TencentRepositoryImpl extends TencentRepository {
@override
Future<DSResponseList<MapPlaceEntity>> qryPlaceByCity(
String key, String keyword,
{String region, int regionFix = 1, String output = 'json'}) async {
Options options = Options(headers: {'base_url': 'TencentMap'});
dynamic result =
await DSDioUtil.getInstance().get('/ws/place/v1/suggestion',
queryParameters: {
'key': key,
'keyword': keyword,
'region_fix': regionFix,
'region': region,
'output': output
},
options: options);
Map<String, dynamic> value = Map<String, dynamic>.from(result);
value['code'] = value['status'];
value['msg'] = value['message'];
value.remove('status');
value.remove('message');
print(value);
DSResponseList<MapPlaceEntity> responseList =
DSResponseList<MapPlaceEntity>.fromJson(value, MapPlaceEntity.fromJson);
return responseList;
}
}
import 'package:base_repository/base_repository.dart';
import 'package:xiaoxiong_repository/repository/user_repository.dart';
class UserRepositoryImpl extends UserRepository {
UserRepositoryImpl.get();
static final UserRepositoryImpl _instance = UserRepositoryImpl.get();
factory UserRepositoryImpl() {
return _instance;
}
@override
Future<DSResponseObject> qryUserInfo({int dataType = 0}) async {
dynamic result = await DSDioUtil.getInstance().get(
'/user.info',
queryParameters: {
'dataType': dataType,
},
);
DSResponseObject object = DSResponseObject.fromJson(
result,
(data) => Map<String, dynamic>.from(data),
);
return object;
}
///
/// 判断用户是否签到
///
@override
Future<DSResponseObject> isUserSign() async {
dynamic result = await DSDioUtil.getInstance().post(
'/sign.isSign',
);
return DSResponseObject.fromJson(
result,
(data) => Map<String, dynamic>.from(data),
);
}
@override
Future<DSResponseObject> userSign() async {
dynamic result = await DSDioUtil.getInstance().post(
'/sign.userSign',
);
return DSResponseObject.fromJson(
result,
(data) => Map<String, dynamic>.from(data),
);
}
///
/// 获取签到幸运点
///
@override
Future<DSResponseObject> getSignLucky() async {
dynamic result = await DSDioUtil.getInstance().get(
'/sign.getLuckyNew',
);
return DSResponseObject.fromJson(
result,
(data) => Map<String, dynamic>.from(data),
);
}
@override
Future<DSResponseObject> watchVideoRewardScore() async {
dynamic result = await DSDioUtil.getInstance().post(
'/video.watchVideoRewardScore',
);
return DSResponseObject.fromJson(
result,
(data) => Map<String, dynamic>.from(data),
);
}
@override
Future<DSResponseObject> videoGetVideoInfo() async {
dynamic result = await DSDioUtil.getInstance().get(
'/video.getVideoInfo',
);
return DSResponseObject.fromJson(
result,
(data) => Map<String, dynamic>.from(data),
);
}
///
/// 积分兑换初始化
///
@override
Future<DSResponseObject> signConvertInData() async {
dynamic result = await DSDioUtil.getInstance().get(
'/sign.convertInData',
);
return DSResponseObject.fromJson(
result,
(data) => Map<String, dynamic>.from(data),
);
}
}
import 'package:flutter/foundation.dart';
import 'package:base_repository/base_repository.dart';
import 'package:xiaoxiong_repository/entity/product_details_entity.dart';
import 'package:xiaoxiong_repository/entity/product_item_entity.dart';
import 'package:xiaoxiong_repository/entity/turn_chain_entity.dart';
import 'impl/price_repository_impl.dart';
///
/// PriceRepository
/// 好价相关的网络库
///
abstract class PriceRepository {
static PriceRepository get() {
return PriceRepositoryImpl();
}
///
/// 好价商品列表
/// [POST] itemSelling.getList
/// [page] 查询的页码
/// [pagesize] 查询每页的长度
/// [keywords] 搜索的关键词
/// [categoryId] 快捷分类id
/// [excludeId] 需要排除的Id
/// [filters] 搜索的条件
///
Future<DSResponseList<ProductItemEntity>> qryProductList(
{int page = 1,
int pagesize = 10,
String keywords,
String categoryId,
String excludeId,
List<dynamic> filters});
///
/// 获取商品详情
/// [id] 商品详情Id
///
Future<DSResponseObject<ProductDetailsEntity>> qryProductDetails(
{@required String id});
///
/// 好价推荐列表
/// [keywords] 搜索关键词
/// [excludeId] 排除id
/// [page] 当前页码
/// [pagesize] 当前页显示的大小
///
Future<DSResponseList<ProductItemEntity>> getSellingRecommends({
String keywords,
String excludeId,
int page = 1,
int pagesize = 10,
});
///
/// 优惠举报
/// [id] 数据库Id
/// [reportType] 举报类型
///
Future<DSResponseBool> report(
{@required String id, @required String reportType});
///
/// 点赞
/// [mark_id] 商品id
/// [type] 点赞类型, 1普通商品 2好价商品
/// [status] 点赞状态1点赞 2取消点赞
/// [platform] 平台 20好价
///
Future<DSResponseBool> userLike(
{@required String markId,
String type = '2',
String status = '1',
String platform = '20'});
///
/// 用户收藏/取消商品
/// [itemId] 商品id
/// [type] 点赞类型, 1普通商品 2好价商品
/// [platform] 平台类型
/// [status] 点赞状态1点赞 2取消点赞
///
Future<DSResponseBool> userCollect(
{@required String itemId,
String type = '2',
String platform = '20',
String status = '1'});
///
/// 通过商品Id进行转链
/// [itemId] 商品id
/// [platform] 平台,1淘宝 2京东 3拼多多 4唯品会
/// [type] 转链类型 好价传6 默认为5
///
Future<DSResponseObject<TurnChainEntity>> turnChainForItemId(
{@required String itemId,
@required String platform,
String type = '5',
String sellerId = ''});
}
import 'package:base_repository/base_repository.dart';
import 'package:flutter/material.dart';
import 'impl/product_repository_impl.dart';
///
/// ProductRepository
/// 商品相关的网络库
///
abstract class ProductRepository {
static ProductRepository get() {
return ProductRepositoryImpl();
}
///
/// 捡漏神单榜
/// [page] 第N页
/// [type] 类型:1.精选专区;2. 9.9专区;3. 6.9专区;4. 3.9专区
///
Future<DSResponseList> getNines({
int page = 1,
int pagesize = 10,
@required int type,
});
///
/// 兑换免单商品
/// [id] 商品数据id,不是商品id
/// [needUrl] 是否需要跳链 1需要 0不需要
///
Future<DSResponseObject> qryGoFreeBuy({
@required String id,
@required int needUrl,
});
///
/// 获取免单获取跳转链接
///
Future<DSResponseObject> qryFreeShareInfo();
///
/// 兑换免单商品结果
/// [id] 数据id
///
Future<DSResponseObject> qryFreeProductResult({@required String id});
}
import 'package:base_repository/base_repository.dart';
import 'package:flutter/foundation.dart';
import 'package:xiaoxiong_repository/entity/suning_item_entity.dart';
import 'impl/suning_repository_impl.dart';
///
/// SuningRepository
/// 苏宁相关的网络库
///
abstract class SuningRepository {
static get() {
return SuningRepositoryImpl();
}
///
/// 苏宁商品【商品主页】
/// [eliteId] 1、苏宁主页 2、实时热销 3、当日热购 4、高佣爆款 6、9.9专区
/// [page] 当前页
/// [pagesize] 每页显示大小
///
Future<DSResponseList<SuningItemEntity>> getSuningList(
{String eliteId = '1', int page = 1, int pagesize = 10});
///
/// 苏宁活动转链
/// [itemUrl] 待转链的苏宁商品链接
///
Future<dynamic> suningActTurnChainLink({@required String itemUrl});
}
import 'package:base_repository/base_repository.dart';
import 'package:flutter/material.dart';
import 'package:xiaoxiong_repository/entity/map_place_entity.dart';
import 'impl/tencent_repository_impl.dart';
///
/// TencentRepository
/// 腾讯相关的网络库
///
abstract class TencentRepository {
static get() {
return TencentRepositoryImpl();
}
///
/// 腾讯地图,关键词输入提示
/// [key] 开发密钥(Key) \r\n
/// [keyword] 关键词 \r\n
/// [region] 限制城市范围:缺省时侧进行全国范围搜索; \r\n
/// [regionFix] 0:[默认]当前城市无结果时,自动扩大范围到全国匹配,1:固定在当前城市 \r\n
/// [output] 返回格式:支持JSON/JSONP,默认JSON \r\n
///
Future<DSResponseList<MapPlaceEntity>> qryPlaceByCity(
String key, String keyword,
{@required String region, int regionFix = 1, String output = 'json'});
}
import 'package:xiaoxiong_repository/app_xiaoxiong_repository.dart';
import 'impl/user_repository_impl.dart';
///
/// UserRepository
/// 用户相关的网络库
///
abstract class UserRepository {
static UserRepository get() {
return UserRepositoryImpl();
}
Future<DSResponseObject> qryUserInfo({int dataType = 0});
///
/// 判断用户是否签到的接口
///
Future<DSResponseObject> isUserSign();
///
/// 用户签到接口
///
Future<DSResponseObject> userSign();
///
/// 获取签到幸运点
///
Future<DSResponseObject> getSignLucky();
///
/// 用户观看视频给奖励
///
Future<DSResponseObject> watchVideoRewardScore();
///
/// 获取用户积分豆详情
///
Future<DSResponseObject> videoGetVideoInfo();
///
/// 积分兑换初始化
///
Future<DSResponseObject> signConvertInData();
}
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.8.1"
base_repository:
dependency: "direct main"
description:
path: "."
ref: null-safety
resolved-ref: "5b60d47410e4bb47d0e8f4fc8c6be00e28b2002d"
url: "git@git.xiaomanxiong.com:flutter-plugin/app-base-repository.git"
source: git
version: "1.0.0"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.15.0"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.1"
crypto:
dependency: "direct dev"
description:
name: crypto
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.4"
dio:
dependency: transitive
description:
name: dio
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.flutter-io.cn"
source: hosted
version: "4.0.0"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.7.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.0"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.4.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.flutter-io.cn"
source: hosted
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.1.0"
sdks:
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0"
name: xiaoxiong_repository
description: 小熊网络模块.
version: 1.0.0
homepage:
publish_to: none
environment:
sdk: ">=2.7.0 <3.0.0"
flutter: ">=1.17.0 <2.0.0"
dependencies:
flutter:
sdk: flutter
base_repository: #基础网络模块
git:
url: 'git@git.xiaomanxiong.com:flutter-plugin/app-base-repository.git'
ref: 'null-safety'
dev_dependencies:
flutter_test:
sdk: flutter
crypto: 2.1.4
\ No newline at end of file
import 'dart:io';
import 'package:dio/dio.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:base_repository/base_repository.dart';
import 'package:xiaoxiong_repository/repository/price_repository.dart';
void main() {
DSDioUtil.getInstance().init(
baseUrl: 'http://zy_xiaoxiong.test.xiaomanxiong.cn/v4/',
inject: LoggerInterceptor());
test('查询好价列表', () async {
PriceRepository repository = PriceRepository.get();
await repository.qryProductList().then((val) {
print(val.code);
}).catchError((err) {
print(err);
});
});
}
class LoggerInterceptor extends InterceptorsWrapper {
@override
void onRequest(RequestOptions options,RequestInterceptorHandler handler,) {
var headers = {
'device-id': '697553255C7D2BC108E891EBBAED3E52',
'device-type': '111',
"token": '6F2B5A4565FECD5CCFAC6BC399131F1A',
'user-id': '1514061',
'os-name': 'android',
'os-version': 'REL',
'app-version': '3.1.0',
'timestamp': '1608539293',
// 'check-sign': 'FrWR0rfNs3s9VaLZ'
};
options.headers.addAll(headers);
options.contentType = ContentType.parse('application/json').toString();
handler.next(options);
}
@override
void onResponse(Response e, ResponseInterceptorHandler handler) {
handler.next(e);
}
@override
void onError(DioError e,ErrorInterceptorHandler handler) {
handler.next(e);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment