Commit 6e929801 authored by Achilles's avatar Achilles

提交公告。

parent 2d300a22
......@@ -24,3 +24,14 @@
-(void) setClientError: (NSString*) error;
@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 @@
}
@end
#pragma Paging
@implementation Paging
@synthesize page = _page;
@synthesize pageSize = _pageSize;
@synthesize pageCount = _pageCount;
@synthesize recordCount = _recordCount;
@end
......@@ -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
// 发布日期大于等于
@property (nonatomic, strong) NSString *publishTimeBegin;
// 是否已读
@property (nonatomic, assign) BOOL read;
@property (nonatomic, assign) NSUInteger pageNumber;
@property (nonatomic, assign) NSUInteger pageSize;
@end
......@@ -28,30 +30,47 @@
@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 *publisher;
// 发布时间
@property (nonatomic, strong) NSString *publishTime;
// 优先级
@property (nonatomic, strong) NSString *priority;
// 内容
@property (nonatomic, strong) NSString *content;
// 优先级
@property (nonatomic, strong) NSNumber *priority;
// 状态
@property (nonatomic, strong) NSNumber *state;
// 附件
@property (nonatomic, strong) NSString *attachment;
// 是否已读
@property (nonatomic, assign) BOOL readed;
-(NSString*) getAttachmentUrl;
@end
// 返回数据
@interface NoticeListResponseData : BeeActiveObject
@property (nonatomic, strong) Paging *paging;
@property (nonatomic, strong) NSArray *records; //Notice
@end
// 请求响应
@interface NoticeListResponse : VankeResponse
@property (nonatomic, strong) NSArray *data;
@property (nonatomic, strong) NoticeListResponseData *data;
-(int) total;
-(NSInteger) total;
@end
\ No newline at end of file
......@@ -9,10 +9,13 @@
#import "VankeNoticeListAPI.h"
#import "VankeConfig.h"
#import "VankeUtil.h"
#import "VankeCommonModel.h"
@implementation VankeNoticeListAPI
@synthesize publishTimeBegin;
@synthesize read;
@synthesize pageNumber;
@synthesize pageSize;
-(void) route:(BeeMessage *)msg {
if (self.sending)
......@@ -21,39 +24,20 @@
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)
{
NSLog(@"response: %@", self.responseString);
// 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;
self.serverResp = [NoticeListResponse objectFromDictionary: self.responseJSONDictionary];
if ( nil == self.serverResp )
{
self.failed = YES;
......@@ -66,10 +50,11 @@
}
-(BOOL) checkToQuery {
// if ([VankeUtil isBlankString:self.publishTimeBegin]) {
// [self setClientError: @"发布日期不能为空"];
// return NO;
// }
User *curUser = [[VankeCommonModel sharedInstance] currentUser];
if (nil == curUser) {
[self setClientError: @"尚未登录"];
return NO;
}
return YES;
}
......@@ -80,12 +65,19 @@
@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 publisher;
@synthesize publishTime;
@synthesize priority;
@synthesize content;
@synthesize priority;
@synthesize state;
@synthesize attachment;
-(NSString*) getAttachmentUrl {
......@@ -98,16 +90,25 @@
@end
#pragma NoticeListResponseData
@implementation NoticeListResponseData
@synthesize paging;
@synthesize records;
CONVERT_PROPERTY_CLASS(records, Notice)
@end
#pragma NoticeListResponse
@implementation NoticeListResponse
@synthesize data;
CONVERT_PROPERTY_CLASS(data, Notice)
-(int) total {
return nil == data ? 0 :[data count];
-(NSInteger) total {
return nil == data ? 0 :data.records.count;
}
@end
......@@ -39,16 +39,6 @@
@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
......
......@@ -81,18 +81,6 @@
@end
#pragma Paging
@implementation Paging
@synthesize page = _page;
@synthesize pageSize = _pageSize;
@synthesize pageCount = _pageCount;
@synthesize recordCount = _recordCount;
@end
#pragma SubjectItem
@implementation SubjectItem
......
......@@ -24,7 +24,7 @@
return;
}
NSString *url = [NSString stringWithFormat:@"/user/login/%@", self.userName];
NSString *url = [NSString stringWithFormat:@"/wanke/user/login/%@", self.userName];
NSString *encryptPwd = [VankeUtil md5: self.password];
NSDictionary *dict = [NSDictionary dictionaryWithObjectsAndKeys:
self.authenticode, @"authenticode",
......
......@@ -10,13 +10,10 @@
@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
......@@ -14,9 +14,8 @@
@implementation VankeNoticeListModel
@synthesize publishTimeBegin = _publishTimeBegin;
@synthesize notices = _notices;
@synthesize readed = _readed;
@synthesize read = _read;
- (void)load
{
......@@ -27,32 +26,9 @@
- (void)unload
{
self.publishTimeBegin = 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
- (void)firstPage
......@@ -68,10 +44,6 @@
}
}
-(void) loadFromServer {
}
- (void)gotoPage:(NSUInteger)page {
[VankeNoticeListAPI cancel];
......@@ -80,7 +52,9 @@
@weakify(api);
@weakify(self);
api.publishTimeBegin = self.publishTimeBegin;
api.read = self.read;
api.pageNumber = page - 1;
api.pageSize = PER_PAGE;
api.whenUpdate = ^
{
......@@ -96,30 +70,28 @@
if ( api.succeed )
{
NoticeListResponse *resp = (NoticeListResponse*) api.serverResp;
if ( nil == resp || nil == resp.data )
{
api.failed = YES;
}
else
{
NSMutableArray *notices = (NSMutableArray*) self.notices;
if ( page <= 1 )
{
[self.notices removeAllObjects];
[self.notices addObjectsFromArray:resp.data];
[notices removeAllObjects];
[notices addObjectsFromArray:resp.data.records];
}
else
{
[self.notices addObjectsFromArray:resp.data];
[self.notices unique:^NSComparisonResult(id left, id right) {
return [((Notice *)left).noticeId compare:((Notice *)right).noticeId];
[notices addObjectsFromArray:resp.data.records];
[notices unique:^NSComparisonResult(id left, id right) {
return [((Notice *)left).uuid compare:((Notice *)right).uuid];
}];
}
self.more = (self.notices.count >= [resp total]) ? NO : YES;
self.loaded = YES;
[self saveCache];
}
}
......
......@@ -30,19 +30,22 @@ DEF_OUTLET( BeeUILabel, lblPublishTime )
$(self.lblTitle).DATA(obj.title);
[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(@"medium");
$(self.imgPriority).REMOVE_CLASS(@"high");
if ([priority eq:@"低"]) {
int v = [priority intValue];
if (v == 0) {
$(self.imgPriority).ADD_CLASS(@"low");
} else if ([priority eq:@"中"]) {
} else if (v == 1) {
$(self.imgPriority).ADD_CLASS(@"medium");
} else if ([priority eq:@"高"]) {
} else if (v == 2) {
$(self.imgPriority).ADD_CLASS(@"high");
}
$(self.lblPriority).DATA(priority);
......
......@@ -66,11 +66,11 @@ ON_CREATE_VIEWS( signal )
[self.segment addTitle:@"未读" tag: SEGMENT_UNREAD];
[self.segment addTitle:@"已读" tag: SEGMENT_READED];
self.segment.tintColor = [UIColor whiteColor];
NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],NSForegroundColorAttributeName, nil];
[self.segment setTitleTextAttributes:dic forState:UIControlStateSelected];
NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],NSForegroundColorAttributeName, nil];
[self.segment setTitleTextAttributes:dic2 forState:UIControlStateNormal];
// self.segment.tintColor = [UIColor whiteColor];
// NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],NSForegroundColorAttributeName, nil];
// [self.segment setTitleTextAttributes:dic forState:UIControlStateSelected];
// NSDictionary *dic2 = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor],NSForegroundColorAttributeName, nil];
// [self.segment setTitleTextAttributes:dic2 forState:UIControlStateNormal];
self.segment.selectedTag = SEGMENT_UNREAD;
self.list.headerClass = [PullLoader class];
......@@ -127,8 +127,6 @@ ON_CREATE_VIEWS( signal )
{
[self.model nextPage];
};
self.model.publishTimeBegin = @"";
}
ON_DELETE_VIEWS( signal )
......@@ -184,7 +182,7 @@ ON_SIGNAL3( BeeUINavigationBar, RIGHT_TOUCHED, signal )
ON_SIGNAL3( VankeNoticeListBoard_iPhone, segment, signal )
{
NSLog(@"Seg.selectedSegmentTag:%d",self.segment.selectedTag);
_model.readed = (_segment.selectedTag == 1);
_model.read = (_segment.selectedTag == 1);
[_model firstPage];
}
......
......@@ -8,7 +8,7 @@
<linear orientation="v" class="segment-wrapper">
<image class="bg" />
<segment id="segment" />
</linear/>
</linear>
</linear>
<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