mirror of
https://github.com/YMFE/yapi.git
synced 2024-12-15 05:10:47 +08:00
Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev
This commit is contained in:
commit
207d6d202f
@ -3,7 +3,7 @@ import React, { Component } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
import { connect } from 'react-redux'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { Icon, Layout, Menu, Dropdown, message, Tooltip } from 'antd'
|
||||
import { Icon, Layout, Menu, Dropdown, message, Tooltip, Avatar } from 'antd'
|
||||
import { checkLoginState, logoutActions, loginTypeAction} from '../../reducer/modules/user'
|
||||
import { changeMenuItem } from '../../reducer/modules/menu'
|
||||
import { withRouter } from 'react-router';
|
||||
@ -59,8 +59,9 @@ const ToolUser = (props)=> (
|
||||
/>
|
||||
}>
|
||||
<a className="dropdown-link">
|
||||
|
||||
<img style={{width:24,height:24}} src={`/api/user/avatar?uid=${props.uid}`} /><span className="name">{props.user}</span>
|
||||
<Avatar src={`/api/user/avatar?uid=${props.uid}`} />
|
||||
{/*<img style={{width:24,height:24}} src={`/api/user/avatar?uid=${props.uid}`} />*/}
|
||||
<span className="name">{props.user}</span>
|
||||
|
||||
</a>
|
||||
</Dropdown>
|
||||
|
@ -72,6 +72,7 @@ $color-black-light : #404040;
|
||||
.nav-toolbar {
|
||||
font-size: .15rem;
|
||||
float: left;
|
||||
|
||||
}
|
||||
|
||||
.user-toolbar{
|
||||
@ -92,6 +93,9 @@ $color-black-light : #404040;
|
||||
.dropdown-link {
|
||||
color: #999;
|
||||
transition: color .4s;
|
||||
.ant-avatar-image{
|
||||
margin-bottom: -10px;
|
||||
}
|
||||
}
|
||||
&:hover{
|
||||
.dropdown-link {
|
||||
|
@ -86,7 +86,7 @@ class NewsTimeline extends Component {
|
||||
getMore(){
|
||||
const that = this;
|
||||
this.setState({loading: true});
|
||||
this.props.fetchNewsData(21, this.props.curpage, 8).then(function () {
|
||||
this.props.fetchNewsData(21,'project', this.props.curpage, 8).then(function () {
|
||||
that.setState({loading: false});
|
||||
if(that.props.newsData.total + 1 === that.props.curpage){
|
||||
that.setState({bidden: "logbidden"})
|
||||
@ -95,7 +95,7 @@ class NewsTimeline extends Component {
|
||||
}
|
||||
|
||||
componentWillMount() {
|
||||
this.props.fetchNewsData(21, this.props.curpage, 8)
|
||||
this.props.fetchNewsData(21,'project', this.props.curpage, 8)
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Row, Col, Input, Button, Select, message, Upload, Icon } from 'antd'
|
||||
import { Row, Col, Input, Button, Select, message, Upload, Icon ,Avatar} from 'antd'
|
||||
import axios from 'axios';
|
||||
import {formatTime} from '../../common.js'
|
||||
import PropTypes from 'prop-types'
|
||||
@ -211,7 +211,7 @@ class Profile extends Component {
|
||||
|
||||
return <div className="user-profile">
|
||||
<Row className="user-item" type="flex" justify="start">
|
||||
<Col span={24}><Avatar uid={userinfo.uid}>点击上传头像</Avatar></Col>
|
||||
<Col span={24}><AvatarUpload uid={userinfo.uid}>点击上传头像</AvatarUpload></Col>
|
||||
<Col span={4}>用户id</Col>
|
||||
<Col span={12}>
|
||||
{userinfo.uid}
|
||||
@ -260,7 +260,7 @@ class Profile extends Component {
|
||||
|
||||
|
||||
|
||||
class Avatar extends Component {
|
||||
class AvatarUpload extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
@ -297,7 +297,7 @@ class Avatar extends Component {
|
||||
onChange={this.handleChange.bind(this)} >
|
||||
{
|
||||
imageUrl ?
|
||||
<img src={imageUrl} alt="" className="avatar" /> :
|
||||
<Avatar size="large" src={imageUrl} />:
|
||||
<Icon type="plus" className="avatar-uploader-trigger" />
|
||||
}
|
||||
</Upload>
|
||||
|
@ -115,19 +115,23 @@
|
||||
.avatar-uploader,
|
||||
.avatar-uploader-trigger,
|
||||
.avatar {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
// width: 100px;
|
||||
// height: 100px;
|
||||
overflow: hidden;
|
||||
border-radius: 50px;
|
||||
|
||||
img{
|
||||
height: auto;
|
||||
}
|
||||
// border-radius: 50px;
|
||||
}
|
||||
.avatar-uploader {
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
}
|
||||
.ant-avatar-lg{
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
border-radius: 50px;
|
||||
}
|
||||
.ant-upload-list{
|
||||
display: none;
|
||||
}
|
||||
.avatar-uploader-trigger {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
|
@ -38,9 +38,10 @@ export default (state = initialState, action) => {
|
||||
import axios from 'axios';
|
||||
import variable from '../../constants/variable';
|
||||
|
||||
export function fetchNewsData (typeid,page,limit) {
|
||||
export function fetchNewsData (typeid,type,page,limit) {
|
||||
const param = {
|
||||
typeid: typeid,
|
||||
type: type,
|
||||
page: page,
|
||||
limit: limit?limit:variable.PAGE_LIMIT
|
||||
}
|
||||
|
@ -79,6 +79,9 @@ class baseController {
|
||||
return this.$user.role;
|
||||
}
|
||||
|
||||
getUsername() {
|
||||
return this.$user.username;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {*} id type对应的id
|
||||
|
@ -60,7 +60,7 @@ class followController extends baseController {
|
||||
|
||||
/**
|
||||
* 取消关注
|
||||
* @interface /follow/list
|
||||
* @interface /follow/del
|
||||
* @method POST
|
||||
* @category follow
|
||||
* @foldnumber 10
|
||||
@ -86,8 +86,8 @@ class followController extends baseController {
|
||||
|
||||
/**
|
||||
* 添加关注
|
||||
* @interface /follow/list
|
||||
* @method POST
|
||||
* @interface /follow/add
|
||||
* @method GET
|
||||
* @category follow
|
||||
* @foldnumber 10
|
||||
* @param {Number} uid 用户id
|
||||
@ -104,7 +104,8 @@ class followController extends baseController {
|
||||
uid: 'number',
|
||||
projectid: 'number',
|
||||
projectname: 'string',
|
||||
icon: 'string'
|
||||
icon: 'string',
|
||||
color: 'string'
|
||||
});
|
||||
|
||||
if (!params.uid) {
|
||||
@ -126,17 +127,22 @@ class followController extends baseController {
|
||||
if (!params.icon) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目图标标志不能为空');
|
||||
}
|
||||
if (!params.color) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, '项目颜色不能为空');
|
||||
}
|
||||
|
||||
let data = {
|
||||
uid: params.uid,
|
||||
projectid: params.projectid,
|
||||
projectname: params.projectname,
|
||||
icon: params.icon
|
||||
icon: params.icon,
|
||||
color: params.color
|
||||
|
||||
};
|
||||
|
||||
try {
|
||||
let result = await this.Model.save(data);
|
||||
result = yapi.commons.fieldSelect(result, ['_id', 'uid', 'projectid', 'projectname', 'icon']);
|
||||
result = yapi.commons.fieldSelect(result, ['_id', 'uid', 'projectid', 'projectname', 'icon', 'color']);
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
|
@ -32,7 +32,7 @@ class logController extends baseController {
|
||||
* @method GET
|
||||
* @category log
|
||||
* @foldnumber 10
|
||||
* @param {Number} uid 用户id, 不能为空
|
||||
* @param {Number} typeid 动态类型id, 不能为空
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 分页大小
|
||||
* @returns {Object}
|
||||
@ -42,15 +42,17 @@ class logController extends baseController {
|
||||
async list(ctx) {
|
||||
let typeid = ctx.request.query.typeid,
|
||||
page = ctx.request.query.page || 1,
|
||||
limit = ctx.request.query.limit || 10;
|
||||
|
||||
limit = ctx.request.query.limit || 10,
|
||||
type = ctx.request.query.type;
|
||||
if (!typeid) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, 'typeid不能为空');
|
||||
}
|
||||
|
||||
if(!type) {
|
||||
return ctx.body = yapi.commons.resReturn(null, 400, 'type不能为空');
|
||||
}
|
||||
try {
|
||||
let result = await this.Model.listWithPaging(typeid, page, limit);
|
||||
let count = await this.Model.listCount(typeid);
|
||||
let result = await this.Model.listWithPaging(typeid,type, page, limit);
|
||||
let count = await this.Model.listCount(typeid,type);
|
||||
|
||||
ctx.body = yapi.commons.resReturn({
|
||||
total: Math.ceil(count / limit),
|
||||
|
@ -5,6 +5,7 @@ import interfaceModel from '../models/interface.js';
|
||||
import groupModel from '../models/group';
|
||||
import commons from '../utils/commons.js';
|
||||
import userModel from '../models/user.js';
|
||||
import logModel from '../models/log.js';
|
||||
import Mock from 'mockjs';
|
||||
const send = require('koa-send');
|
||||
|
||||
@ -14,6 +15,7 @@ class projectController extends baseController {
|
||||
super(ctx);
|
||||
this.Model = yapi.getInst(projectModel);
|
||||
this.groupModel = yapi.getInst(groupModel);
|
||||
this.logModel = yapi.getInst(logModel);
|
||||
}
|
||||
|
||||
handleBasepath(basepath) {
|
||||
@ -119,6 +121,14 @@ class projectController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await this.Model.save(data);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}添加了项目${params.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -162,6 +172,14 @@ class projectController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await this.Model.addMember(params.id, userdata);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}添加了项目成员${userdata.username}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -199,6 +217,19 @@ class projectController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await this.Model.delMember(params.id, params.member_uid);
|
||||
let username = this.getUsername();
|
||||
let project = await this.Model.get(params.id);
|
||||
for(let i in project.members){
|
||||
if(i.uid === params.member_uid){
|
||||
await this.logModel.save({
|
||||
content: `用户${username}删除了项目${project.name}中的成员${i.username}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
}
|
||||
}
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -365,6 +396,21 @@ class projectController extends baseController {
|
||||
|
||||
try {
|
||||
let result = await groupInst.changeMemberRole(params.id, params.member_uid, params.role);
|
||||
|
||||
let username = this.getUsername();
|
||||
let project = await this.Model.get(params.id);
|
||||
for(let i in project.members){
|
||||
if(i.uid === params.member_uid){
|
||||
await this.logModel.save({
|
||||
content: `用户${username}修改了项目${project.name}中成员${i.username}的角色为${params.role}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
@ -456,6 +502,16 @@ class projectController extends baseController {
|
||||
if (params.env) data.env = params.env;
|
||||
|
||||
let result = await this.Model.up(id, data);
|
||||
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}更新了项目${params.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: id
|
||||
});
|
||||
|
||||
ctx.body = yapi.commons.resReturn(result);
|
||||
} catch (e) {
|
||||
ctx.body = yapi.commons.resReturn(null, 402, e.message);
|
||||
|
@ -10,7 +10,8 @@ class followModel extends baseModel {
|
||||
uid: { type: Number, required: true },
|
||||
projectid: { type: Number, required: true },
|
||||
projectname: { type: String, required: true },
|
||||
icon: String
|
||||
icon: String,
|
||||
color: String
|
||||
};
|
||||
}
|
||||
|
||||
@ -26,7 +27,8 @@ class followModel extends baseModel {
|
||||
uid: data.uid,
|
||||
projectid: data.projectid,
|
||||
projectname: data.projectname,
|
||||
icon: data.icon
|
||||
icon: data.icon,
|
||||
color: data.color
|
||||
};
|
||||
let follow = new this.model(saveData);
|
||||
return follow.save();
|
||||
|
@ -22,6 +22,9 @@ class logModel extends baseModel {
|
||||
* @param {String} content log内容
|
||||
* @param {Enum} type log类型, ['user', 'group', 'interface', 'project', 'other']
|
||||
* @param {Number} uid 用户id
|
||||
* @param {String} username 用户名
|
||||
* @param {Number} typeid 类型id
|
||||
* @param {Number} add_time 时间
|
||||
*/
|
||||
save(data) {
|
||||
let saveData = {
|
||||
@ -43,26 +46,28 @@ class logModel extends baseModel {
|
||||
});
|
||||
}
|
||||
|
||||
list(typeid) {
|
||||
list(typeid,type) {
|
||||
return this.model.find({
|
||||
typeid: typeid
|
||||
typeid: typeid,
|
||||
type: type
|
||||
})
|
||||
.exec();
|
||||
}
|
||||
|
||||
|
||||
listWithPaging(typeid, page, limit) {
|
||||
listWithPaging(typeid,type, page, limit) {
|
||||
page = parseInt(page);
|
||||
limit = parseInt(limit);
|
||||
|
||||
return this.model.find({
|
||||
typeid: typeid
|
||||
type: type
|
||||
}).skip((page - 1) * limit).limit(limit).exec();
|
||||
}
|
||||
|
||||
listCount(typeid) {
|
||||
listCount(typeid,type) {
|
||||
return this.model.count({
|
||||
typeid: typeid
|
||||
typeid: typeid,
|
||||
type: type
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -214,7 +214,11 @@ var baseController = function () {
|
||||
value: function getRole() {
|
||||
return this.$user.role;
|
||||
}
|
||||
|
||||
}, {
|
||||
key: 'getUsername',
|
||||
value: function getUsername() {
|
||||
return this.$user.username;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {*} id type对应的id
|
||||
|
@ -143,7 +143,7 @@ var followController = function (_baseController) {
|
||||
|
||||
/**
|
||||
* 取消关注
|
||||
* @interface /follow/list
|
||||
* @interface /follow/del
|
||||
* @method POST
|
||||
* @category follow
|
||||
* @foldnumber 10
|
||||
@ -205,8 +205,8 @@ var followController = function (_baseController) {
|
||||
|
||||
/**
|
||||
* 添加关注
|
||||
* @interface /follow/list
|
||||
* @method POST
|
||||
* @interface /follow/add
|
||||
* @method GET
|
||||
* @category follow
|
||||
* @foldnumber 10
|
||||
* @param {Number} uid 用户id
|
||||
@ -232,7 +232,8 @@ var followController = function (_baseController) {
|
||||
uid: 'number',
|
||||
projectid: 'number',
|
||||
projectname: 'string',
|
||||
icon: 'string'
|
||||
icon: 'string',
|
||||
color: 'string'
|
||||
});
|
||||
|
||||
if (params.uid) {
|
||||
@ -281,36 +282,46 @@ var followController = function (_baseController) {
|
||||
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目图标标志不能为空'));
|
||||
|
||||
case 15:
|
||||
if (params.color) {
|
||||
_context3.next = 17;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context3.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, '项目颜色不能为空'));
|
||||
|
||||
case 17:
|
||||
data = {
|
||||
uid: params.uid,
|
||||
projectid: params.projectid,
|
||||
projectname: params.projectname,
|
||||
icon: params.icon
|
||||
icon: params.icon,
|
||||
color: params.color
|
||||
|
||||
};
|
||||
_context3.prev = 16;
|
||||
_context3.next = 19;
|
||||
_context3.prev = 18;
|
||||
_context3.next = 21;
|
||||
return this.Model.save(data);
|
||||
|
||||
case 19:
|
||||
case 21:
|
||||
result = _context3.sent;
|
||||
|
||||
result = _yapi2.default.commons.fieldSelect(result, ['_id', 'uid', 'projectid', 'projectname', 'icon']);
|
||||
result = _yapi2.default.commons.fieldSelect(result, ['_id', 'uid', 'projectid', 'projectname', 'icon', 'color']);
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context3.next = 27;
|
||||
_context3.next = 29;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
_context3.prev = 24;
|
||||
_context3.t0 = _context3['catch'](16);
|
||||
case 26:
|
||||
_context3.prev = 26;
|
||||
_context3.t0 = _context3['catch'](18);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t0.message);
|
||||
|
||||
case 27:
|
||||
case 29:
|
||||
case 'end':
|
||||
return _context3.stop();
|
||||
}
|
||||
}
|
||||
}, _callee3, this, [[16, 24]]);
|
||||
}, _callee3, this, [[18, 26]]);
|
||||
}));
|
||||
|
||||
function add(_x3) {
|
||||
|
@ -80,7 +80,7 @@ var logController = function (_baseController) {
|
||||
* @method GET
|
||||
* @category log
|
||||
* @foldnumber 10
|
||||
* @param {Number} uid 用户id, 不能为空
|
||||
* @param {Number} typeid 动态类型id, 不能为空
|
||||
* @param {Number} [page] 分页页码
|
||||
* @param {Number} [limit] 分页大小
|
||||
* @returns {Object}
|
||||
@ -91,12 +91,12 @@ var logController = function (_baseController) {
|
||||
key: 'list',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var typeid, page, limit, result, count;
|
||||
var typeid, page, limit, type, result, count;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
typeid = ctx.request.query.typeid, page = ctx.request.query.page || 1, limit = ctx.request.query.limit || 10;
|
||||
typeid = ctx.request.query.typeid, page = ctx.request.query.page || 1, limit = ctx.request.query.limit || 10, type = ctx.request.query.type;
|
||||
|
||||
if (typeid) {
|
||||
_context.next = 3;
|
||||
@ -106,16 +106,24 @@ var logController = function (_baseController) {
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, 'typeid不能为空'));
|
||||
|
||||
case 3:
|
||||
_context.prev = 3;
|
||||
_context.next = 6;
|
||||
return this.Model.listWithPaging(typeid, page, limit);
|
||||
if (type) {
|
||||
_context.next = 5;
|
||||
break;
|
||||
}
|
||||
|
||||
case 6:
|
||||
return _context.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 400, 'type不能为空'));
|
||||
|
||||
case 5:
|
||||
_context.prev = 5;
|
||||
_context.next = 8;
|
||||
return this.Model.listWithPaging(typeid, type, page, limit);
|
||||
|
||||
case 8:
|
||||
result = _context.sent;
|
||||
_context.next = 9;
|
||||
return this.Model.listCount(typeid);
|
||||
_context.next = 11;
|
||||
return this.Model.listCount(typeid, type);
|
||||
|
||||
case 9:
|
||||
case 11:
|
||||
count = _context.sent;
|
||||
|
||||
|
||||
@ -123,21 +131,21 @@ var logController = function (_baseController) {
|
||||
total: Math.ceil(count / limit),
|
||||
list: result
|
||||
});
|
||||
_context.next = 16;
|
||||
_context.next = 18;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context.prev = 13;
|
||||
_context.t0 = _context['catch'](3);
|
||||
case 15:
|
||||
_context.prev = 15;
|
||||
_context.t0 = _context['catch'](5);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t0.message);
|
||||
|
||||
case 16:
|
||||
case 18:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[3, 13]]);
|
||||
}, _callee, this, [[5, 15]]);
|
||||
}));
|
||||
|
||||
function list(_x) {
|
||||
|
@ -60,6 +60,10 @@ var _user = require('../models/user.js');
|
||||
|
||||
var _user2 = _interopRequireDefault(_user);
|
||||
|
||||
var _log = require('../models/log.js');
|
||||
|
||||
var _log2 = _interopRequireDefault(_log);
|
||||
|
||||
var _mockjs = require('mockjs');
|
||||
|
||||
var _mockjs2 = _interopRequireDefault(_mockjs);
|
||||
@ -78,6 +82,7 @@ var projectController = function (_baseController) {
|
||||
|
||||
_this.Model = _yapi2.default.getInst(_project2.default);
|
||||
_this.groupModel = _yapi2.default.getInst(_group2.default);
|
||||
_this.logModel = _yapi2.default.getInst(_log2.default);
|
||||
return _this;
|
||||
}
|
||||
|
||||
@ -124,7 +129,7 @@ var projectController = function (_baseController) {
|
||||
key: 'add',
|
||||
value: function () {
|
||||
var _ref = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee(ctx) {
|
||||
var params, checkRepeat, checkRepeatDomain, data, result;
|
||||
var params, checkRepeat, checkRepeatDomain, data, result, username;
|
||||
return _regenerator2.default.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
@ -244,23 +249,33 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 32:
|
||||
result = _context.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 39;
|
||||
break;
|
||||
username = this.getUsername();
|
||||
_context.next = 36;
|
||||
return this.logModel.save({
|
||||
content: '\u7528\u6237' + username + '\u6DFB\u52A0\u4E86\u9879\u76EE' + params.name,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
});
|
||||
|
||||
case 36:
|
||||
_context.prev = 36;
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 42;
|
||||
break;
|
||||
|
||||
case 39:
|
||||
_context.prev = 39;
|
||||
_context.t1 = _context['catch'](29);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t1.message);
|
||||
|
||||
case 39:
|
||||
case 42:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[29, 36]]);
|
||||
}, _callee, this, [[29, 39]]);
|
||||
}));
|
||||
|
||||
function add(_x) {
|
||||
@ -285,7 +300,7 @@ var projectController = function (_baseController) {
|
||||
key: 'addMember',
|
||||
value: function () {
|
||||
var _ref2 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee2(ctx) {
|
||||
var params, check, userdata, result;
|
||||
var params, check, userdata, result, username;
|
||||
return _regenerator2.default.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
@ -356,23 +371,33 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 23:
|
||||
result = _context2.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context2.next = 30;
|
||||
break;
|
||||
username = this.getUsername();
|
||||
_context2.next = 27;
|
||||
return this.logModel.save({
|
||||
content: '\u7528\u6237' + username + '\u6DFB\u52A0\u4E86\u9879\u76EE\u6210\u5458' + userdata.username,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
|
||||
case 27:
|
||||
_context2.prev = 27;
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context2.next = 33;
|
||||
break;
|
||||
|
||||
case 30:
|
||||
_context2.prev = 30;
|
||||
_context2.t1 = _context2['catch'](20);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context2.t1.message);
|
||||
|
||||
case 30:
|
||||
case 33:
|
||||
case 'end':
|
||||
return _context2.stop();
|
||||
}
|
||||
}
|
||||
}, _callee2, this, [[20, 27]]);
|
||||
}, _callee2, this, [[20, 30]]);
|
||||
}));
|
||||
|
||||
function addMember(_x2) {
|
||||
@ -397,7 +422,7 @@ var projectController = function (_baseController) {
|
||||
key: 'delMember',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var params, check, result;
|
||||
var params, check, result, username, project, i;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
switch (_context3.prev = _context3.next) {
|
||||
@ -454,23 +479,57 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 18:
|
||||
result = _context3.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context3.next = 25;
|
||||
break;
|
||||
username = this.getUsername();
|
||||
_context3.next = 22;
|
||||
return this.Model.get(params.id);
|
||||
|
||||
case 22:
|
||||
_context3.prev = 22;
|
||||
_context3.t1 = _context3['catch'](15);
|
||||
project = _context3.sent;
|
||||
_context3.t1 = _regenerator2.default.keys(project.members);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t1.message);
|
||||
case 24:
|
||||
if ((_context3.t2 = _context3.t1()).done) {
|
||||
_context3.next = 31;
|
||||
break;
|
||||
}
|
||||
|
||||
case 25:
|
||||
i = _context3.t2.value;
|
||||
|
||||
if (!(i.uid === params.member_uid)) {
|
||||
_context3.next = 29;
|
||||
break;
|
||||
}
|
||||
|
||||
_context3.next = 29;
|
||||
return this.logModel.save({
|
||||
content: '\u7528\u6237' + username + '\u5220\u9664\u4E86\u9879\u76EE' + project.name + '\u4E2D\u7684\u6210\u5458' + i.username,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
|
||||
case 29:
|
||||
_context3.next = 24;
|
||||
break;
|
||||
|
||||
case 31:
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context3.next = 37;
|
||||
break;
|
||||
|
||||
case 34:
|
||||
_context3.prev = 34;
|
||||
_context3.t3 = _context3['catch'](15);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t3.message);
|
||||
|
||||
case 37:
|
||||
case 'end':
|
||||
return _context3.stop();
|
||||
}
|
||||
}
|
||||
}, _callee3, this, [[15, 22]]);
|
||||
}, _callee3, this, [[15, 34]]);
|
||||
}));
|
||||
|
||||
function delMember(_x3) {
|
||||
@ -832,7 +891,7 @@ var projectController = function (_baseController) {
|
||||
key: 'changeMemberRole',
|
||||
value: function () {
|
||||
var _ref9 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee9(ctx) {
|
||||
var params, groupInst, check, result;
|
||||
var params, groupInst, check, result, username, project, i;
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
switch (_context9.prev = _context9.next) {
|
||||
@ -893,23 +952,58 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 20:
|
||||
result = _context9.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context9.next = 27;
|
||||
break;
|
||||
username = this.getUsername();
|
||||
_context9.next = 24;
|
||||
return this.Model.get(params.id);
|
||||
|
||||
case 24:
|
||||
_context9.prev = 24;
|
||||
_context9.t1 = _context9['catch'](17);
|
||||
project = _context9.sent;
|
||||
_context9.t1 = _regenerator2.default.keys(project.members);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t1.message);
|
||||
case 26:
|
||||
if ((_context9.t2 = _context9.t1()).done) {
|
||||
_context9.next = 33;
|
||||
break;
|
||||
}
|
||||
|
||||
case 27:
|
||||
i = _context9.t2.value;
|
||||
|
||||
if (!(i.uid === params.member_uid)) {
|
||||
_context9.next = 31;
|
||||
break;
|
||||
}
|
||||
|
||||
_context9.next = 31;
|
||||
return this.logModel.save({
|
||||
content: '\u7528\u6237' + username + '\u4FEE\u6539\u4E86\u9879\u76EE' + project.name + '\u4E2D\u6210\u5458' + i.username + '\u7684\u89D2\u8272\u4E3A' + params.role,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.id
|
||||
});
|
||||
|
||||
case 31:
|
||||
_context9.next = 26;
|
||||
break;
|
||||
|
||||
case 33:
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context9.next = 39;
|
||||
break;
|
||||
|
||||
case 36:
|
||||
_context9.prev = 36;
|
||||
_context9.t3 = _context9['catch'](17);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t3.message);
|
||||
|
||||
case 39:
|
||||
case 'end':
|
||||
return _context9.stop();
|
||||
}
|
||||
}
|
||||
}, _callee9, this, [[17, 24]]);
|
||||
}, _callee9, this, [[17, 36]]);
|
||||
}));
|
||||
|
||||
function changeMemberRole(_x10) {
|
||||
@ -941,7 +1035,7 @@ var projectController = function (_baseController) {
|
||||
key: 'up',
|
||||
value: function () {
|
||||
var _ref10 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee10(ctx) {
|
||||
var _id2, params, projectData, checkRepeat, checkRepeatDomain, data, result;
|
||||
var _id2, params, projectData, checkRepeat, checkRepeatDomain, data, result, username;
|
||||
|
||||
return _regenerator2.default.wrap(function _callee10$(_context10) {
|
||||
while (1) {
|
||||
@ -1071,23 +1165,34 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 41:
|
||||
result = _context10.sent;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 48;
|
||||
break;
|
||||
username = this.getUsername();
|
||||
_context10.next = 45;
|
||||
return this.logModel.save({
|
||||
content: '\u7528\u6237' + username + '\u66F4\u65B0\u4E86\u9879\u76EE' + params.name,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: _id2
|
||||
});
|
||||
|
||||
case 45:
|
||||
_context10.prev = 45;
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 51;
|
||||
break;
|
||||
|
||||
case 48:
|
||||
_context10.prev = 48;
|
||||
_context10.t1 = _context10['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context10.t1.message);
|
||||
|
||||
case 48:
|
||||
case 51:
|
||||
case 'end':
|
||||
return _context10.stop();
|
||||
}
|
||||
}
|
||||
}, _callee10, this, [[0, 45]]);
|
||||
}, _callee10, this, [[0, 48]]);
|
||||
}));
|
||||
|
||||
function up(_x11) {
|
||||
|
@ -46,7 +46,8 @@ var followModel = function (_baseModel) {
|
||||
uid: { type: Number, required: true },
|
||||
projectid: { type: Number, required: true },
|
||||
projectname: { type: String, required: true },
|
||||
icon: String
|
||||
icon: String,
|
||||
color: String
|
||||
};
|
||||
}
|
||||
|
||||
@ -65,7 +66,8 @@ var followModel = function (_baseModel) {
|
||||
uid: data.uid,
|
||||
projectid: data.projectid,
|
||||
projectname: data.projectname,
|
||||
icon: data.icon
|
||||
icon: data.icon,
|
||||
color: data.color
|
||||
};
|
||||
var follow = new this.model(saveData);
|
||||
return follow.save();
|
||||
|
@ -62,6 +62,9 @@ var logModel = function (_baseModel) {
|
||||
* @param {String} content log内容
|
||||
* @param {Enum} type log类型, ['user', 'group', 'interface', 'project', 'other']
|
||||
* @param {Number} uid 用户id
|
||||
* @param {String} username 用户名
|
||||
* @param {Number} typeid 类型id
|
||||
* @param {Number} add_time 时间
|
||||
*/
|
||||
|
||||
}, {
|
||||
@ -88,26 +91,28 @@ var logModel = function (_baseModel) {
|
||||
}
|
||||
}, {
|
||||
key: 'list',
|
||||
value: function list(typeid) {
|
||||
value: function list(typeid, type) {
|
||||
return this.model.find({
|
||||
typeid: typeid
|
||||
typeid: typeid,
|
||||
type: type
|
||||
}).exec();
|
||||
}
|
||||
}, {
|
||||
key: 'listWithPaging',
|
||||
value: function listWithPaging(typeid, page, limit) {
|
||||
value: function listWithPaging(typeid, type, page, limit) {
|
||||
page = parseInt(page);
|
||||
limit = parseInt(limit);
|
||||
|
||||
return this.model.find({
|
||||
typeid: typeid
|
||||
type: type
|
||||
}).skip((page - 1) * limit).limit(limit).exec();
|
||||
}
|
||||
}, {
|
||||
key: 'listCount',
|
||||
value: function listCount(typeid) {
|
||||
value: function listCount(typeid, type) {
|
||||
return this.model.count({
|
||||
typeid: typeid
|
||||
typeid: typeid,
|
||||
type: type
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
Loading…
Reference in New Issue
Block a user