Просмотр исходного кода

feat: 更新weapp标段控制器,新增标段管理接口,调整用户权限验证逻辑

caipin 1 месяц назад
Родитель
Сommit
f215f49bb1

+ 4 - 4
app/controller/weapp_attention_controller.js

@@ -11,7 +11,7 @@ module.exports = app => {
                     ctx.body = { code: 0, msg: '参数错误:请提供标段ID数组', data: null };
                     return;
                 }
-                const result = await ctx.service.weappAttention.followSections(tenderIds, ctx.projectAccount.id);
+                const result = await ctx.service.weappAttention.followSections(tenderIds, ctx.session.sessionUser.id);
                 if (result) {
                     ctx.body = { code: 0, msg: '关注成功', data: null };
                 } else {
@@ -31,7 +31,7 @@ module.exports = app => {
                     ctx.body = { code: 0, msg: '参数错误:请提供关注ID', data: null };
                     return;
                 }
-                const result = await ctx.service.weappAttention.unfollowSections(attentionIds, ctx.projectAccount.id);
+                const result = await ctx.service.weappAttention.unfollowSections(attentionIds, ctx.session.sessionUser.id);
                 if (result) {
                     ctx.body = { code: 0, msg: '取消关注成功', data: null };
                 } else {
@@ -46,7 +46,7 @@ module.exports = app => {
         async followedList() {
             const { ctx } = this;
             try {
-                const result = await ctx.service.weappAttention.getFollowedSections(ctx.projectAccount.id);
+                const result = await ctx.service.weappAttention.getFollowedSections(ctx.session.sessionUser.id);
                 ctx.body = { code: 0, msg: '', data: result };
             } catch (error) {
                 ctx.body = { code: -1, msg: error.toString(), data: null };
@@ -62,7 +62,7 @@ module.exports = app => {
                     ctx.body = { code: 0, msg: '参数错误:请提供标段ID', data: null };
                     return;
                 }
-                const isFollowing = await ctx.service.weappAttention.isFollowingSection(ctx.projectAccount.id, tenderId);
+                const isFollowing = await ctx.service.weappAttention.isFollowingSection(ctx.session.sessionUser.id, tenderId);
                 ctx.body = { code: 0, msg: '', data: { following: isFollowing } };
             } catch (error) {
                 ctx.body = { code: -1, msg: error.toString(), data: null };

+ 34 - 0
app/controller/weapp_tender_controller.js

@@ -0,0 +1,34 @@
+'use strict';
+
+module.exports = app => {
+    class WeappTenderController extends app.BaseController {
+        async listManage(ctx) {
+            try {
+                const projectId = ctx.query.projectId;
+                if (!projectId) {
+                    ctx.body = { err: 1, msg: '缺少projectId参数', data: null };
+                    return;
+                }
+                const accountInfo = await this.ctx.service.projectAccount.getDataById(ctx.session.sessionUser.id);
+                const userPermission = accountInfo !== undefined && accountInfo.permission !== '' ? JSON.parse(accountInfo.permission) : null;
+                if (userPermission !== null && userPermission.tender !== undefined && userPermission.tender.indexOf('1') !== -1) {
+                    const subProject = await this.ctx.service.subProject.getDataById(projectId);
+                    const tenderList = await this.ctx.service.tender.getList('manage', userPermission, ctx.session.sessionUser.is_admin, '', subProject);
+                    const categoryData = await this.ctx.service.category.getAllCategory(subProject);
+                    const renderData = {
+                        categoryData: categoryData,
+                        tenderList: tenderList
+                    }
+                    ctx.body = { err: 0, msg: '', data: renderData };
+                } else {
+                    ctx.body = { err: 1, msg: '您没有管理权限', data: null };
+                }
+            } catch (err) {
+                this.log(err);
+                ctx.body = { err: 1, msg: err.toString(), data: null };
+            }
+        }
+    }
+
+    return WeappTenderController;
+};

+ 1 - 0
app/router.js

@@ -1248,4 +1248,5 @@ module.exports = app => {
     app.get('/wx/weapp/attention/list', weappAuth, 'weappAttentionController.followedList');
     app.get('/wx/weapp/attention/check', weappAuth, 'weappAttentionController.checkFollowing');
     app.get('/wx/weapp/tender/info', weappAuth, 'weappSubpController.tenderInfoDetail');
+    app.get('/wx/weapp/tender/list/manage', weappAuth, 'weappTenderController.listManage');
 };