Commit 6e929801 authored by Achilles's avatar Achilles

提交公告。

parent 2d300a22
...@@ -24,3 +24,14 @@ ...@@ -24,3 +24,14 @@
-(void) setClientError: (NSString*) error; -(void) setClientError: (NSString*) error;
@end @end
// 分页信息
@interface Paging : BeeActiveObject
@property (nonatomic, strong) NSNumber *page;
@property (nonatomic, strong) NSNumber *pageSize;
@property (nonatomic, strong) NSNumber *pageCount;
@property (nonatomic, strong) NSNumber *recordCount;
@end
...@@ -64,3 +64,14 @@ ...@@ -64,3 +64,14 @@
} }
@end @end
#pragma Paging
@implementation Paging
@synthesize page = _page;
@synthesize pageSize = _pageSize;
@synthesize pageCount = _pageCount;
@synthesize recordCount = _recordCount;
@end
...@@ -15,12 +15,14 @@ ...@@ -15,12 +15,14 @@
/* /*
* 查询项目列表 * 查询项目列表
* http://.../wanke-server/rest/project/queryprojectsby?classificationEquals={classificationEquals}&nameLike={nameLike}&salesDateEquals={salesDateEquals}& passengerDateEquals={passengerDateEquals}&trafficDateEquals={trafficDateEquals} *http://.../wanke-server/rest/affiche/download/{user_uuid}?read={read}&page_number={pageNumber}&page_size={pageSize}
*/ */
@interface VankeNoticeListAPI : VankeBaseAPI @interface VankeNoticeListAPI : VankeBaseAPI
// 发布日期大于等于 // 是否已读
@property (nonatomic, strong) NSString *publishTimeBegin; @property (nonatomic, assign) BOOL read;
@property (nonatomic, assign) NSUInteger pageNumber;
@property (nonatomic, assign) NSUInteger pageSize;
@end @end
...@@ -28,30 +30,47 @@ ...@@ -28,30 +30,47 @@
@interface Notice : BeeActiveObject @interface Notice : BeeActiveObject
// 标识 // 标识
@property (nonatomic, strong) NSString *noticeId; @property (nonatomic, strong) NSString *uuid;
// 版本
@property (nonatomic, strong) NSNumber *version;
// 发布时间
@property (nonatomic, strong) NSString *create_time;
// 发布人
@property (nonatomic, strong) NSString *create_id;
// 发布人
@property (nonatomic, strong) NSString *create_operName;
@property (nonatomic, strong) NSString *lastModify_time;
@property (nonatomic, strong) NSString *lastModify_id;
@property (nonatomic, strong) NSString *lastModify_operName;
@property (nonatomic, strong) NSString *enterprise;
// 标题 // 标题
@property (nonatomic, strong) NSString *title; @property (nonatomic, strong) NSString *title;
// 发布人
@property (nonatomic, strong) NSString *publisher;
// 发布时间
@property (nonatomic, strong) NSString *publishTime;
// 优先级
@property (nonatomic, strong) NSString *priority;
// 内容 // 内容
@property (nonatomic, strong) NSString *content; @property (nonatomic, strong) NSString *content;
// 优先级
@property (nonatomic, strong) NSNumber *priority;
// 状态
@property (nonatomic, strong) NSNumber *state;
// 附件 // 附件
@property (nonatomic, strong) NSString *attachment; @property (nonatomic, strong) NSString *attachment;
// 是否已读
@property (nonatomic, assign) BOOL readed;
-(NSString*) getAttachmentUrl; -(NSString*) getAttachmentUrl;
@end @end
// 返回数据
@interface NoticeListResponseData : BeeActiveObject
@property (nonatomic, strong) Paging *paging;
@property (nonatomic, strong) NSArray *records; //Notice
@end
// 请求响应
@interface NoticeListResponse : VankeResponse @interface NoticeListResponse : VankeResponse
@property (nonatomic, strong) NSArray *data; @property (nonatomic, strong) NoticeListResponseData *data;
-(int) total; -(NSInteger) total;
@end @end
\ No newline at end of file
...@@ -9,10 +9,13 @@ ...@@ -9,10 +9,13 @@
#import "VankeNoticeListAPI.h" #import "VankeNoticeListAPI.h"
#import "VankeConfig.h" #import "VankeConfig.h"
#import "VankeUtil.h" #import "VankeUtil.h"
#import "VankeCommonModel.h"
@implementation VankeNoticeListAPI @implementation VankeNoticeListAPI
@synthesize publishTimeBegin; @synthesize read;
@synthesize pageNumber;
@synthesize pageSize;
-(void) route:(BeeMessage *)msg { -(void) route:(BeeMessage *)msg {
if (self.sending) if (self.sending)
...@@ -21,39 +24,20 @@ ...@@ -21,39 +24,20 @@
return; return;
} }
[self http_get:@"/project/queryprojectsby"].PARAM(@"publishTimeBegin", self.publishTimeBegin).TIMEOUT(10); User *curUser = [[VankeCommonModel sharedInstance] currentUser];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
self.read? @"true": @"false", @"read",
[NSString stringWithFormat:@"%lu", self.pageNumber], @"page_number",
[NSString stringWithFormat:@"%lu", self.pageSize], @"page_size",
nil];
NSString *url = [NSString stringWithFormat:@"/affiche/download/%@", curUser.code];
[self http_post:url].BODY(dict).TIMEOUT(10);
} }
else if (self.succeed) else if (self.succeed)
{ {
NSLog(@"response: %@", self.responseString); NSLog(@"response: %@", self.responseString);
// self.serverResp = [NoticeListResponse objectFromDictionary: self.responseJSONDictionary]; self.serverResp = [NoticeListResponse objectFromDictionary: self.responseJSONDictionary];
NoticeListResponse *resp = [[NoticeListResponse alloc] init];
NSMutableArray *ary = [[NSMutableArray alloc] initWithCapacity:10];
for (int i = 0; i < 10; ++i) {
Notice *obj = [[Notice alloc]init];
obj.noticeId = [NSString stringWithFormat:@"%d", i];
obj.title = [NSString stringWithFormat:@"重要通知%d", i];
obj.publishTime = @"2015-11-15";
obj.publisher = @"张三";
if (i % 3 == 0) {
obj.priority = @"低";
} else if (i % 3 == 1) {
obj.priority = @"中";
} else if (i % 3 == 2) {
obj.priority = @"高";
}
obj.content = @"销售录入对账单...";
obj.attachment = @"a.png";
[ary addObject:obj];
}
resp.data = ary;
self.serverResp = resp;
if ( nil == self.serverResp ) if ( nil == self.serverResp )
{ {
self.failed = YES; self.failed = YES;
...@@ -66,10 +50,11 @@ ...@@ -66,10 +50,11 @@
} }
-(BOOL) checkToQuery { -(BOOL) checkToQuery {
// if ([VankeUtil isBlankString:self.publishTimeBegin]) { User *curUser = [[VankeCommonModel sharedInstance] currentUser];
// [self setClientError: @"发布日期不能为空"]; if (nil == curUser) {
// return NO; [self setClientError: @"尚未登录"];
// } return NO;
}
return YES; return YES;
} }
...@@ -80,12 +65,19 @@ ...@@ -80,12 +65,19 @@
@implementation Notice @implementation Notice
@synthesize noticeId; @synthesize uuid;
@synthesize version;
@synthesize create_time;
@synthesize create_id;
@synthesize create_operName;
@synthesize lastModify_id;
@synthesize lastModify_time;
@synthesize lastModify_operName;
@synthesize enterprise;
@synthesize title; @synthesize title;
@synthesize publisher;
@synthesize publishTime;
@synthesize priority;
@synthesize content; @synthesize content;
@synthesize priority;
@synthesize state;
@synthesize attachment; @synthesize attachment;
-(NSString*) getAttachmentUrl { -(NSString*) getAttachmentUrl {
...@@ -98,16 +90,25 @@ ...@@ -98,16 +90,25 @@
@end @end
#pragma NoticeListResponseData
@implementation NoticeListResponseData
@synthesize paging;
@synthesize records;
CONVERT_PROPERTY_CLASS(records, Notice)
@end
#pragma NoticeListResponse #pragma NoticeListResponse
@implementation NoticeListResponse @implementation NoticeListResponse
@synthesize data; @synthesize data;
CONVERT_PROPERTY_CLASS(data, Notice) -(NSInteger) total {
return nil == data ? 0 :data.records.count;
-(int) total {
return nil == data ? 0 :[data count];
} }
@end @end
...@@ -39,16 +39,6 @@ ...@@ -39,16 +39,6 @@
@end @end
// 分页信息
@interface Paging : BeeActiveObject
@property (nonatomic, strong) NSNumber *page;
@property (nonatomic, strong) NSNumber *pageSize;
@property (nonatomic, strong) NSNumber *pageCount;
@property (nonatomic, strong) NSNumber *recordCount;
@end
// 对账单科目 // 对账单科目
@interface SubjectItem : BeeActiveObject @interface SubjectItem : BeeActiveObject
......
...@@ -81,18 +81,6 @@ ...@@ -81,18 +81,6 @@
@end @end
#pragma Paging
@implementation Paging
@synthesize page = _page;
@synthesize pageSize = _pageSize;
@synthesize pageCount = _pageCount;
@synthesize recordCount = _recordCount;
@end
#pragma SubjectItem #pragma SubjectItem
@implementation SubjectItem @implementation SubjectItem
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
return; return;
} }
NSString *url = [NSString stringWithFormat:@"/user/login/%@", self.userName]; NSString *url = [NSString stringWithFormat:@"/wanke/user/login/%@", self.userName];
NSString *encryptPwd = [VankeUtil md5: self.password]; NSString *encryptPwd = [VankeUtil md5: self.password];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys: NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
self.authenticode, @"authenticode", self.authenticode, @"authenticode",
......
...@@ -10,13 +10,10 @@ ...@@ -10,13 +10,10 @@
@interface VankeNoticeListModel : BeeStreamViewModel @interface VankeNoticeListModel : BeeStreamViewModel
// 发布时间大于
@property (nonatomic, strong) NSString *publishTimeBegin;
// 是否已读 // 是否已读
@property (nonatomic, assign) BOOL readed; @property (nonatomic, assign) BOOL read;
// 公告列表 // 公告列表
@property (nonatomic, strong) NSMutableArray *notices; @property (nonatomic, strong) NSArray *notices;
@end @end
...@@ -14,9 +14,8 @@ ...@@ -14,9 +14,8 @@
@implementation VankeNoticeListModel @implementation VankeNoticeListModel
@synthesize publishTimeBegin = _publishTimeBegin;
@synthesize notices = _notices; @synthesize notices = _notices;
@synthesize readed = _readed; @synthesize read = _read;
- (void)load - (void)load
{ {
...@@ -27,32 +26,9 @@ ...@@ -27,32 +26,9 @@
- (void)unload - (void)unload
{ {
self.publishTimeBegin = nil;
self.notices = nil; self.notices = nil;
} }
#pragma mark - cache
- (void)loadCache
{
[self.notices removeAllObjects];
[self.notices addUniqueObjectsFromArray:[Notice readObjectForKey:self.publishTimeBegin]
compare:^NSComparisonResult(id left, id right) {
return [((Notice*)left).noticeId compare:((Notice*)right).noticeId];
}];
}
- (void)saveCache
{
[Notice saveObject:self.notices forKey:self.publishTimeBegin];
}
- (void)clearCache
{
[self.notices removeAllObjects];
[Notice removeObjectForKey:self.publishTimeBegin];
}
#pragma mark - paging query #pragma mark - paging query
- (void)firstPage - (void)firstPage
...@@ -68,10 +44,6 @@ ...@@ -68,10 +44,6 @@
} }
} }
-(void) loadFromServer {
}
- (void)gotoPage:(NSUInteger)page { - (void)gotoPage:(NSUInteger)page {
[VankeNoticeListAPI cancel]; [VankeNoticeListAPI cancel];
...@@ -80,7 +52,9 @@ ...@@ -80,7 +52,9 @@
@weakify(api); @weakify(api);
@weakify(self); @weakify(self);
api.publishTimeBegin = self.publishTimeBegin; api.read = self.read;
api.pageNumber = page - 1;
api.pageSize = PER_PAGE;
api.whenUpdate = ^ api.whenUpdate = ^
{ {
...@@ -96,30 +70,28 @@ ...@@ -96,30 +70,28 @@
if ( api.succeed ) if ( api.succeed )
{ {
NoticeListResponse *resp = (NoticeListResponse*) api.serverResp; NoticeListResponse *resp = (NoticeListResponse*) api.serverResp;
if ( nil == resp || nil == resp.data ) if ( nil == resp || nil == resp.data )
{ {
api.failed = YES; api.failed = YES;
} }
else else
{ {
NSMutableArray *notices = (NSMutableArray*) self.notices;
if ( page <= 1 ) if ( page <= 1 )
{ {
[self.notices removeAllObjects]; [notices removeAllObjects];
[self.notices addObjectsFromArray:resp.data]; [notices addObjectsFromArray:resp.data.records];
} }
else else
{ {
[self.notices addObjectsFromArray:resp.data]; [notices addObjectsFromArray:resp.data.records];
[self.notices unique:^NSComparisonResult(id left, id right) { [notices unique:^NSComparisonResult(id left, id right) {
return [((Notice *)left).noticeId compare:((Notice *)right).noticeId]; return [((Notice *)left).uuid compare:((Notice *)right).uuid];
}]; }];
} }
self.more = (self.notices.count >= [resp total]) ? NO : YES; self.more = (self.notices.count >= [resp total]) ? NO : YES;
self.loaded = YES; self.loaded = YES;
[self saveCache];
} }
} }
......
...@@ -30,19 +30,22 @@ DEF_OUTLET( BeeUILabel, lblPublishTime ) ...@@ -30,19 +30,22 @@ DEF_OUTLET( BeeUILabel, lblPublishTime )
$(self.lblTitle).DATA(obj.title); $(self.lblTitle).DATA(obj.title);
[self setPriority:obj.priority]; [self setPriority:obj.priority];
$(self.lblPublisher).DATA([NSString stringWithFormat:@"发布人: %@", obj.publisher]);
$(self.lblPublishTime).DATA([NSString stringWithFormat:@"发布时间: %@", obj.publishTime]); $(self.lblPublisher).DATA([NSString stringWithFormat:@"发布人: %@", obj.create_operName]);
$(self.lblPublishTime).DATA([NSString stringWithFormat:@"发布时间: %@", obj.create_time]);
} }
-(void) setPriority: (NSString*) priority { -(void) setPriority: (NSNumber*) priority {
$(self.imgPriority).REMOVE_CLASS(@"low"); $(self.imgPriority).REMOVE_CLASS(@"low");
$(self.imgPriority).REMOVE_CLASS(@"medium"); $(self.imgPriority).REMOVE_CLASS(@"medium");
$(self.imgPriority).REMOVE_CLASS(@"high"); $(self.imgPriority).REMOVE_CLASS(@"high");
if ([priority eq:@"低"]) {
int v = [priority intValue];
if (v == 0) {
$(self.imgPriority).ADD_CLASS(@"low"); $(self.imgPriority).ADD_CLASS(@"low");
} else if ([priority eq:@"中"]) { } else if (v == 1) {
$(self.imgPriority).ADD_CLASS(@"medium"); $(self.imgPriority).ADD_CLASS(@"medium");
} else if ([priority eq:@"高"]) { } else if (v == 2) {
$(self.imgPriority).ADD_CLASS(@"high"); $(self.imgPriority).ADD_CLASS(@"high");
} }
$(self.lblPriority).DATA(priority); $(self.lblPriority).DATA(priority);
......
...@@ -66,11 +66,11 @@ ON_CREATE_VIEWS( signal ) ...@@ -66,11 +66,11 @@ ON_CREATE_VIEWS( signal )
[self.segment addTitle:@"未读" tag: SEGMENT_UNREAD]; [self.segment addTitle:@"未读" tag: SEGMENT_UNREAD];
[self.segment addTitle:@"已读" tag: SEGMENT_READED]; [self.segment addTitle:@"已读" tag: SEGMENT_READED];
self.segment.tintColor = [UIColor whiteColor]; // self.segment.tintColor = [UIColor whiteColor];
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],NSForegroundColorAttributeName, nil]; // NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],NSForegroundColorAttributeName, nil];
[self.segment setTitleTextAttributes:dic forState:UIControlStateSelected]; // [self.segment setTitleTextAttributes:dic forState:UIControlStateSelected];
NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],NSForegroundColorAttributeName, nil]; // NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],NSForegroundColorAttributeName, nil];
[self.segment setTitleTextAttributes:dic2 forState:UIControlStateNormal]; // [self.segment setTitleTextAttributes:dic2 forState:UIControlStateNormal];
self.segment.selectedTag = SEGMENT_UNREAD; self.segment.selectedTag = SEGMENT_UNREAD;
self.list.headerClass = [PullLoader class]; self.list.headerClass = [PullLoader class];
...@@ -127,8 +127,6 @@ ON_CREATE_VIEWS( signal ) ...@@ -127,8 +127,6 @@ ON_CREATE_VIEWS( signal )
{ {
[self.model nextPage]; [self.model nextPage];
}; };
self.model.publishTimeBegin = @"";
} }
ON_DELETE_VIEWS( signal ) ON_DELETE_VIEWS( signal )
...@@ -184,7 +182,7 @@ ON_SIGNAL3( BeeUINavigationBar, RIGHT_TOUCHED, signal ) ...@@ -184,7 +182,7 @@ ON_SIGNAL3( BeeUINavigationBar, RIGHT_TOUCHED, signal )
ON_SIGNAL3( VankeNoticeListBoard_iPhone, segment, signal ) ON_SIGNAL3( VankeNoticeListBoard_iPhone, segment, signal )
{ {
NSLog(@"Seg.selectedSegmentTag:%d",self.segment.selectedTag); NSLog(@"Seg.selectedSegmentTag:%d",self.segment.selectedTag);
_model.readed = (_segment.selectedTag == 1); _model.read = (_segment.selectedTag == 1);
[_model firstPage]; [_model firstPage];
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<linear orientation="v" class="segment-wrapper"> <linear orientation="v" class="segment-wrapper">
<image class="bg" /> <image class="bg" />
<segment id="segment" /> <segment id="segment" />
</linear/> </linear>
</linear> </linear>
<style type="text/css"> <style type="text/css">
......
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