针对后台文档管理指定用户功能优化

This commit is contained in:
doramart 2020-02-03 15:37:57 +08:00
parent b0966ffee6
commit 2062b50e77
5 changed files with 60 additions and 10 deletions

View File

@ -2,7 +2,7 @@
* @Author: doramart
* @Date: 2019-06-20 18:55:40
* @Last Modified by: doramart
* @Last Modified time: 2020-01-22 10:33:02
* @Last Modified time: 2020-02-03 13:19:53
*/
const Controller = require('egg').Controller;
const {
@ -389,10 +389,24 @@ class AdminUserController extends Controller {
})
}
let adminUserInfo = await ctx.service.adminUser.item(ctx, {
query: {
_id: ctx.session.adminUserInfo._id
},
populate: [{
path: 'group',
select: 'power _id enable name'
}, {
path: 'targetEditor',
select: 'userName _id'
}],
files: 'enable password _id email userName logo'
})
let renderData = {
noticeCounts,
loginState: true,
userInfo: ctx.session.adminUserInfo
userInfo: adminUserInfo
};
ctx.helper.renderSuccess(ctx, {

View File

@ -213,8 +213,6 @@ let ContentController = {
// 文章推荐
async updateContentToTop(ctx, app) {
try {
let fields = ctx.request.body || {};
@ -239,8 +237,6 @@ let ContentController = {
// 文章置顶
async roofPlacement(ctx, app) {
try {
let fields = ctx.request.body || {};
@ -300,7 +296,6 @@ let ContentController = {
async update(ctx, app) {
try {
let fields = ctx.request.body || {};
@ -361,6 +356,42 @@ let ContentController = {
},
async updateContentEditor(ctx, app) {
try {
let fields = ctx.request.body || {};
const formObj = {
targetEditor: fields.targetUser,
}
let oldUser = await ctx.service.user.item(ctx, {
query: {
_id: fields.targetUser
}
});
if (_.isEmpty(oldUser)) {
throw new Error(ctx.__('validate_error_params'));
}
let adminUserInfo = ctx.session.adminUserInfo;
await ctx.service.adminUser.update(ctx, adminUserInfo._id, formObj);
ctx.helper.renderSuccess(ctx);
} catch (err) {
ctx.helper.renderFail(ctx, {
message: err
});
}
},
async removes(ctx, app) {
try {

View File

@ -58,6 +58,11 @@ exports.doraContent = {
method: 'post',
controllerName: 'redictContentToUsers',
details: '分配用户',
}, {
url: 'content/updateContentEditor',
method: 'post',
controllerName: 'updateContentEditor',
details: '绑定编辑',
}],
fontApi: [{
url: 'content/getMyFavoriteContents',

View File

@ -1,6 +1,6 @@
{
"name": "egg-dora-content",
"version": "1.0.6",
"version": "1.0.7",
"description": "content",
"eggPlugin": {
"name": "doraContent"

View File

@ -11,10 +11,10 @@
"egg": "^2.3.0",
"egg-dora-middlestage": "^1.0.0",
"egg-dora-uploadfile": "^1.0.0",
"egg-dora-validate": "^1.0.1",
"egg-mongoose": "^3.2.0",
"egg-redis": "^2.4.0",
"egg-scripts": "^2.11.0",
"egg-dora-validate": "^1.0.1",
"egg-view-nunjucks": "^2.2.0",
"iconv-lite": "^0.5.0",
"jsonwebtoken": "^8.5.1",
@ -95,4 +95,4 @@
"@utils": "app/utils"
},
"license": "MIT"
}
}