|
@@ -9,23 +9,41 @@ class NoticeController extends Controller {
|
|
|
|
|
|
//我发布的通知
|
|
|
async listForPage() {
|
|
|
- const { ctx } = this;
|
|
|
+ const { ctx ,service} = this;
|
|
|
const user = ctx.user;
|
|
|
if (user.role._id != this.app.config.defaultAdminRoleId) {
|
|
|
- ctx.query.userid = ctx.user._id;
|
|
|
- }else{
|
|
|
+ ctx.query.userid = ctx.user._id; //不是admin的情况
|
|
|
+ if(ctx.query.status == 1){ //不是admin情况选择 我发布的通知
|
|
|
+ delete ctx.query.status;
|
|
|
+ ctx.query.sort = { createTime: -1 };
|
|
|
+ if (!ctx.query.searchtitle) {
|
|
|
+ delete ctx.query.searchtitle;
|
|
|
+ }else{
|
|
|
+ ctx.query.title = ctx.query.searchtitle;
|
|
|
+ ctx.query.title ={$regex: ctx.query.searchtitle}
|
|
|
+ delete ctx.query.searchtitle;
|
|
|
+ }
|
|
|
+ this.ctx.logger.info(ctx.query);
|
|
|
+ const result0 = await this.tag().listForPage(ctx.query);
|
|
|
+ ctx.success(result0);
|
|
|
+ }else{ //不是admin情况下选择 发布给我的通知
|
|
|
+ const result1 = await service.noticeService.pcListForPage(ctx.query,user);
|
|
|
+ ctx.success(result1);
|
|
|
+ }
|
|
|
+ }else{ //是admin情况下只能看 所有通知
|
|
|
delete ctx.query.userid;
|
|
|
+ delete ctx.query.status;
|
|
|
+ ctx.query.sort = { createTime: -1 };
|
|
|
+ if (!ctx.query.searchtitle) {
|
|
|
+ delete ctx.query.searchtitle;
|
|
|
+ }else{
|
|
|
+ ctx.query.title = ctx.query.searchtitle;
|
|
|
+ ctx.query.title ={$regex: ctx.query.searchtitle}
|
|
|
+ delete ctx.query.searchtitle;
|
|
|
+ }
|
|
|
+ const result2 = await this.tag().listForPage(ctx.query);
|
|
|
+ ctx.success(result2);
|
|
|
}
|
|
|
- ctx.query.sort = { createTime: -1 };
|
|
|
- if (!ctx.query.searchtitle) {
|
|
|
- delete ctx.query.searchtitle;
|
|
|
- }else{
|
|
|
- ctx.query.title = ctx.query.searchtitle;
|
|
|
- ctx.query.title ={$regex: ctx.query.searchtitle}
|
|
|
- delete ctx.query.searchtitle;
|
|
|
- }
|
|
|
- const result = await this.tag().listForPage(ctx.query);
|
|
|
- ctx.success(result);
|
|
|
}
|
|
|
|
|
|
//PC端发给我的通知
|