mirror of
https://github.com/YMFE/yapi.git
synced 2025-03-01 14:05:44 +08:00
fix: 预览页完善
This commit is contained in:
parent
031f8c899c
commit
4e7f5959d2
@ -127,7 +127,7 @@ class TimeTree extends Component {
|
||||
}
|
||||
return (
|
||||
<section className="news-timeline">
|
||||
{data ? <Timeline pending={pending}>{data}</Timeline> : data}
|
||||
{data ? <Timeline pending={pending}>{data}</Timeline> : "还没有任何动态"}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import { connect } from 'react-redux'
|
||||
import PropTypes from 'prop-types'
|
||||
import { Table } from 'antd'
|
||||
const mockEditor = require('./mockEditor.js')
|
||||
// import { formatTime } from '../../../../common.js';
|
||||
import { formatTime } from '../../../../common.js';
|
||||
|
||||
// import { Card } from 'antd'
|
||||
// import { getMockUrl } from '../../reducer/modules/news.js'
|
||||
@ -15,51 +15,134 @@ const mockEditor = require('./mockEditor.js')
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
class View extends Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
static propTypes = {
|
||||
viewData: PropTypes.object
|
||||
curData: PropTypes.object
|
||||
}
|
||||
|
||||
req_body_form(req_body_type,req_body_form){
|
||||
if(req_body_type === 'json'){
|
||||
mockEditor({
|
||||
container: 'vreq_body_json',
|
||||
data: req_body_form,
|
||||
readOnly:true,
|
||||
onChange: function () {}
|
||||
})
|
||||
return <div className="colBody">
|
||||
<span className="colKey">请求Body:</span>
|
||||
<div id="vreq_body_json" style={{ minHeight: "300px" }}></div>
|
||||
</div>
|
||||
|
||||
componentDidMount() {
|
||||
let that = this;
|
||||
mockEditor({
|
||||
container: 'vreq_body_json',
|
||||
data: that.props.req_body_form,
|
||||
onChange: function () {}
|
||||
})
|
||||
mockEditor({
|
||||
container: 'vres_body_json',
|
||||
data: that.props.res_body,
|
||||
onChange: function () {}
|
||||
})
|
||||
mockEditor({
|
||||
container: 'vreq_query_json',
|
||||
data: that.props.req_query,
|
||||
onChange: function () {}
|
||||
})
|
||||
}else if(req_body_type === 'form'){
|
||||
|
||||
const columns = [{
|
||||
title: '参数名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name'
|
||||
}, {
|
||||
title: '参数值',
|
||||
dataIndex: 'value',
|
||||
key: 'value'
|
||||
}, {
|
||||
title: '备注',
|
||||
dataIndex: 'required',
|
||||
key: 'required',
|
||||
width: '45%'
|
||||
}];
|
||||
|
||||
const dataSource = [];
|
||||
if(req_body_form&&req_body_form.length){
|
||||
req_body_form.map((item,i)=>{
|
||||
dataSource.push({
|
||||
key: i,
|
||||
name: item.name,
|
||||
value: item.desc,
|
||||
required: item.required?"必须":"非必须"
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">请求Body:</span>
|
||||
<Table bordered size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />
|
||||
</div>
|
||||
|
||||
}else if(req_body_type === 'file'){
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">请求Body:</span>
|
||||
<div style={{ minHeight: "300px" }}>file</div>
|
||||
</div>
|
||||
|
||||
}else if(req_body_type === 'raw'){
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">请求Body:</span>
|
||||
<div style={{ minHeight: "300px" }}>raw</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
res_body(res_body_type,res_body){
|
||||
if(res_body_type === 'json'){
|
||||
return <div className="colBody">
|
||||
<span className="colKey">返回Body:</span>
|
||||
<div id="vres_body_json" style={{ minHeight: "300px" }}></div>
|
||||
</div>
|
||||
|
||||
}else if(res_body_type === 'form'){
|
||||
|
||||
const columns = [{
|
||||
title: '参数名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name'
|
||||
}, {
|
||||
title: '参数值',
|
||||
dataIndex: 'value',
|
||||
key: 'value'
|
||||
}, {
|
||||
title: '备注',
|
||||
dataIndex: 'required',
|
||||
key: 'required',
|
||||
width: '45%'
|
||||
}];
|
||||
|
||||
const dataSource = [];
|
||||
if(res_body&&res_body.length){
|
||||
res_body.map((item,i)=>{
|
||||
dataSource.push({
|
||||
key: i,
|
||||
name: item.name,
|
||||
value: item.desc,
|
||||
required: item.required?"必须":"非必须"
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">返回Body:</span>
|
||||
<Table bordered size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />
|
||||
</div>
|
||||
|
||||
}else if(res_body_type === 'file'){
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">返回Body:</span>
|
||||
<div>{res_body}</div>
|
||||
</div>
|
||||
|
||||
}else if(res_body_type === 'raw'){
|
||||
|
||||
return <div className="colBody">
|
||||
<span className="colKey">返回Body:</span>
|
||||
<div>{res_body}</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
render () {
|
||||
|
||||
const dataSource = [{
|
||||
key: 1,
|
||||
name: '1',
|
||||
value: '胡彦斌',
|
||||
desc: 32
|
||||
}, {
|
||||
key: 2,
|
||||
name: '2',
|
||||
value: '胡彦斌',
|
||||
desc: 32
|
||||
}];
|
||||
|
||||
req_query(query){
|
||||
const columns = [{
|
||||
title: '参数名称',
|
||||
dataIndex: 'name',
|
||||
@ -70,117 +153,127 @@ class View extends Component {
|
||||
key: 'value'
|
||||
}, {
|
||||
title: '备注',
|
||||
dataIndex: 'desc',
|
||||
key: 'desc',
|
||||
dataIndex: 'required',
|
||||
key: 'required',
|
||||
width: '45%'
|
||||
}];
|
||||
|
||||
const dataSource = [];
|
||||
if(query&&query.length){
|
||||
query.map((item,i)=>{
|
||||
dataSource.push({
|
||||
key: i,
|
||||
name: item.name,
|
||||
value: item.desc,
|
||||
required: item.required?"必须":"非必须"
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
return <Table bordered size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />;
|
||||
}
|
||||
componentDidUpdate(){
|
||||
if(this.props.curData.req_body_type === "json"){
|
||||
mockEditor({
|
||||
container: 'vreq_body_json',
|
||||
data: this.props.curData.req_body_form,
|
||||
readOnly:true,
|
||||
onChange: function () {}
|
||||
})
|
||||
}
|
||||
if(this.props.curData.res_body_type === "json"){
|
||||
mockEditor({
|
||||
container: 'vres_body_json',
|
||||
data: this.props.curData.res_body,
|
||||
readOnly:true,
|
||||
onChange: function () {}
|
||||
})
|
||||
}
|
||||
}
|
||||
render () {
|
||||
|
||||
const dataSource = [];
|
||||
if(this.props.curData.req_headers&&this.props.curData.req_headers.length){
|
||||
this.props.curData.req_headers.map((item,i)=>{
|
||||
dataSource.push({
|
||||
key: i,
|
||||
name: item.name,
|
||||
required: item.required?"必须":"非必须",
|
||||
value: item.value
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
const columns = [{
|
||||
title: '参数名称',
|
||||
dataIndex: 'name',
|
||||
key: 'name'
|
||||
}, {
|
||||
title: '参数值',
|
||||
dataIndex: 'value',
|
||||
key: 'value'
|
||||
}, {
|
||||
title: '备注',
|
||||
dataIndex: 'required',
|
||||
key: 'required',
|
||||
width: '45%'
|
||||
}];
|
||||
|
||||
return <div className="caseContainer">
|
||||
{/*<Card title={`接口名:${this.props.viewData.casename}`}></Card>*/}
|
||||
<div className="colName">
|
||||
<span className="colKey">接口名:</span>
|
||||
<span className="colValue">{this.props.viewData.title}</span>
|
||||
<span className="colValue">{this.props.curData.title}</span>
|
||||
</div>
|
||||
<div className="colMethod">
|
||||
<span className="colKey">请求方法:</span>
|
||||
<span className="colValue">{this.props.curData.method}</span>
|
||||
</div>
|
||||
<div className="colPath">
|
||||
<span className="colKey">接口路径:</span>
|
||||
<span className="colValue">{this.props.viewData.path}</span>
|
||||
<span className="colValue">{this.props.curData.path}</span>
|
||||
</div>
|
||||
<div className="colstatus">
|
||||
<span className="colKey">状态:</span>
|
||||
<span className="colValue">{this.props.viewData.status}</span>
|
||||
<span className="colValue">{this.props.curData.status}</span>
|
||||
</div>
|
||||
<div className="colMock">
|
||||
<span className="colKey">Mock地址:</span>
|
||||
<span className="colValue">{this.props.viewData.mockUrl}</span>
|
||||
<div className="colAddTime">
|
||||
<span className="colKey">创建时间:</span>
|
||||
<span className="colValue">{formatTime(this.props.curData.add_time)}</span>
|
||||
</div>
|
||||
<div className="colUpTime">
|
||||
<span className="colKey">更新时间:</span>
|
||||
<span className="colValue">{formatTime(this.props.curData.up_time)}</span>
|
||||
</div>
|
||||
<div className="colDesc">
|
||||
<span className="colKey">接口描述:</span>
|
||||
<span className="colValue">{this.props.viewData.desc}</span>
|
||||
<span className="colValue">{this.props.curData.desc}</span>
|
||||
</div>
|
||||
<div className="colHeader">
|
||||
<span className="colKey">请求Headers:</span>
|
||||
<Table size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />
|
||||
<Table bordered size="small" pagination = {false} columns= {columns} dataSource = {dataSource} />
|
||||
</div>
|
||||
<div className="colQuery">
|
||||
<span className="colKey">Query:</span>
|
||||
<div span={18} offset={4} id="vreq_query_json" style={{ minHeight: "150px" }}></div>
|
||||
{this.req_query(this.props.curData.req_query)}
|
||||
</div>
|
||||
<div className="colBody">
|
||||
<span className="colKey">请求Body:</span>
|
||||
<div span={18} offset={4} id="vreq_body_json" style={{ minHeight: "300px" }}></div>
|
||||
<div className="colreqBodyType">
|
||||
<span className="colKey">请求Body类型:</span>
|
||||
<span className="colValue">{this.props.curData.req_body_type}</span>
|
||||
</div>
|
||||
<div className="colBody">
|
||||
<span className="colKey">响应Body:</span>
|
||||
<div span={18} offset={4} id="vres_body_json" style={{ minHeight: "300px" }}></div>
|
||||
{this.req_body_form("form",this.props.curData.req_body_form)}
|
||||
<div className="colreqBodyType">
|
||||
<span className="colKey">返回Body类型:</span>
|
||||
<span className="colValue">{this.props.curData.req_body_type}</span>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{this.res_body("json",this.props.curData.res_body)}
|
||||
{/*{this.res_body("file",[{
|
||||
name: "key",
|
||||
desc: "123",
|
||||
required: 0
|
||||
}])}*/}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
let data = {
|
||||
title: '',
|
||||
path: '',
|
||||
status: 'undone',
|
||||
method: 'get',
|
||||
req_query: [{
|
||||
name: '',
|
||||
desc: '',
|
||||
required: "1"
|
||||
}],
|
||||
req_body_type: 'form',
|
||||
req_headers: [{
|
||||
name: '',
|
||||
value: '', required: "1"
|
||||
}],
|
||||
req_body_form: [{
|
||||
name: '',
|
||||
type: '',
|
||||
required: ''
|
||||
}],
|
||||
res_body_type: 'json',
|
||||
res_body: '{a:123}',
|
||||
desc: 'FP的好处是没有OO的复杂仪式感,是沿着数据结构+算法的思路进行抽象和结构化。如果顶层设计做好,代码复用度极高,代码量少。比如要生成一颗树我用迭归算法直接生成',
|
||||
res_body_mock: '',
|
||||
mockUrl: "this.props.mockUrl"
|
||||
}
|
||||
// {
|
||||
// casename:"caename",
|
||||
// uid: 107,
|
||||
// col_id: 211,
|
||||
// index: 0,
|
||||
// project_id: 112,
|
||||
// add_time: new Date().getTime(),
|
||||
// up_time: new Date().getTime(),
|
||||
// env: "测试环境",
|
||||
// domain: "域名",
|
||||
// path: "路径",
|
||||
// method: "GET",
|
||||
// req_query: [{
|
||||
// name: "String",
|
||||
// value: "String",
|
||||
// required: "1"
|
||||
// }],
|
||||
// req_headers: [{
|
||||
// name: "String",
|
||||
// value: "String",
|
||||
// required: "1"
|
||||
// }],
|
||||
// req_body_type: "json",
|
||||
// res_body_form: [{
|
||||
// name: "String",
|
||||
// value: "String",
|
||||
// required: "1"
|
||||
// }],
|
||||
// res_body_other: "String"
|
||||
// }
|
||||
View.defaultProps = {
|
||||
viewData: data
|
||||
}
|
||||
|
||||
export default View
|
||||
|
@ -13,12 +13,27 @@
|
||||
.colKey{
|
||||
font-weight: bolder;
|
||||
margin-right: 16px;
|
||||
padding-bottom: 16px;
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
.colName,.colPath,.colstatus,.colMock{
|
||||
.colreqBodyType{
|
||||
margin: 0px;
|
||||
.colKey{
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
}
|
||||
.ace_print-margin{
|
||||
display: none;
|
||||
}
|
||||
.colName,.colPath,.colstatus,.colAddTime,.colUpTime,.colMethod{
|
||||
width: 50%;
|
||||
float: left;
|
||||
padding: 8px 16px;
|
||||
|
||||
.colKey{
|
||||
padding-bottom: 0px;
|
||||
}
|
||||
}
|
||||
.colDesc{
|
||||
line-height: 1.5em;
|
||||
|
@ -8,22 +8,6 @@ class logController extends baseController {
|
||||
super(ctx);
|
||||
this.Model = yapi.getInst(logModel);
|
||||
this.groupModel = yapi.getInst(groupModel);
|
||||
try{
|
||||
// var res = this.Model.save({
|
||||
// uid: 107,
|
||||
// typeid: 21,
|
||||
// type: 'project',
|
||||
// username: '小明明宝宝',
|
||||
// content: '小明应该修改了的项目宝宝',
|
||||
// time: yapi.commons.time()
|
||||
// });
|
||||
// var res = this.Model.del(107);
|
||||
// ctx.body = yapi.commons.resReturn(null, 200,res);
|
||||
}catch(err){
|
||||
// ctx.body = yapi.commons.resReturn(null, 402, err.message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -99,7 +99,7 @@ class projectController extends baseController {
|
||||
try {
|
||||
let result = await this.Model.save(data);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}添加了项目${params.name}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
@ -150,7 +150,7 @@ class projectController extends baseController {
|
||||
try {
|
||||
let result = await this.Model.addMember(params.id, userdata);
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}添加了项目成员${userdata.username}`,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
@ -196,17 +196,14 @@ class projectController extends baseController {
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
let member = await yapi.getInst(userModel).findById(params.member_uid);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}删除了项目${project.name}中的成员${member.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);
|
||||
@ -375,18 +372,14 @@ class projectController extends baseController {
|
||||
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let member = await yapi.getInst(userModel).findByUids(params.member_uid);
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}修改了项目${project.name}中成员${member.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);
|
||||
@ -460,14 +453,13 @@ class projectController extends baseController {
|
||||
let result = await this.Model.up(id, data);
|
||||
|
||||
let username = this.getUsername();
|
||||
await this.logModel.save({
|
||||
content: `用户${username}更新了项目${params.name}`,
|
||||
yapi.commons.saveLog({
|
||||
content: `用户${username}更新了项目${projectData.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);
|
||||
|
@ -2,6 +2,7 @@ import fs from 'fs-extra';
|
||||
import path from 'path';
|
||||
import yapi from '../yapi.js';
|
||||
import sha1 from 'sha1';
|
||||
import logModel from '../models/log.js';
|
||||
|
||||
exports.resReturn = (data, num, errmsg) => {
|
||||
num = num || 0;
|
||||
@ -222,4 +223,23 @@ exports.handleParams = (params, keys) => {
|
||||
}
|
||||
|
||||
return params;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
exports.saveLog = (logData) => {
|
||||
try {
|
||||
let logInst = yapi.getInst(logModel);
|
||||
let data = {
|
||||
content: logData.content,
|
||||
type: logData.type,
|
||||
uid: logData.uid,
|
||||
username: logData.username,
|
||||
typeid: logData.typeid
|
||||
};
|
||||
logInst.save(data).then(
|
||||
|
||||
);
|
||||
} catch(e) {
|
||||
yapi.commons.log(e, 'error'); // eslint-disable-line
|
||||
}
|
||||
};
|
||||
|
@ -56,21 +56,6 @@ var logController = function (_baseController) {
|
||||
|
||||
_this.Model = _yapi2.default.getInst(_log2.default);
|
||||
_this.groupModel = _yapi2.default.getInst(_group2.default);
|
||||
try {
|
||||
// var res = this.Model.save({
|
||||
// uid: 107,
|
||||
// typeid: 21,
|
||||
// type: 'project',
|
||||
// username: '小明明宝宝',
|
||||
// content: '小明应该修改了的项目宝宝',
|
||||
// time: yapi.commons.time()
|
||||
// });
|
||||
// var res = this.Model.del(107);
|
||||
// ctx.body = yapi.commons.resReturn(null, 200,res);
|
||||
} catch (err) {
|
||||
// ctx.body = yapi.commons.resReturn(null, 402, err.message);
|
||||
}
|
||||
|
||||
return _this;
|
||||
}
|
||||
|
||||
|
@ -214,32 +214,30 @@ var projectController = function (_baseController) {
|
||||
case 23:
|
||||
result = _context.sent;
|
||||
username = this.getUsername();
|
||||
_context.next = 27;
|
||||
return this.logModel.save({
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237' + username + '\u6DFB\u52A0\u4E86\u9879\u76EE' + params.name,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: params.group_id
|
||||
});
|
||||
|
||||
case 27:
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context.next = 33;
|
||||
_context.next = 32;
|
||||
break;
|
||||
|
||||
case 30:
|
||||
_context.prev = 30;
|
||||
case 29:
|
||||
_context.prev = 29;
|
||||
_context.t1 = _context['catch'](20);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context.t1.message);
|
||||
|
||||
case 33:
|
||||
case 32:
|
||||
case 'end':
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[20, 30]]);
|
||||
}, _callee, this, [[20, 29]]);
|
||||
}));
|
||||
|
||||
function add(_x) {
|
||||
@ -336,32 +334,30 @@ var projectController = function (_baseController) {
|
||||
case 23:
|
||||
result = _context2.sent;
|
||||
username = this.getUsername();
|
||||
_context2.next = 27;
|
||||
return this.logModel.save({
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
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:
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context2.next = 33;
|
||||
_context2.next = 32;
|
||||
break;
|
||||
|
||||
case 30:
|
||||
_context2.prev = 30;
|
||||
case 29:
|
||||
_context2.prev = 29;
|
||||
_context2.t1 = _context2['catch'](20);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context2.t1.message);
|
||||
|
||||
case 33:
|
||||
case 32:
|
||||
case 'end':
|
||||
return _context2.stop();
|
||||
}
|
||||
}
|
||||
}, _callee2, this, [[20, 30]]);
|
||||
}, _callee2, this, [[20, 29]]);
|
||||
}));
|
||||
|
||||
function addMember(_x2) {
|
||||
@ -386,7 +382,7 @@ var projectController = function (_baseController) {
|
||||
key: 'delMember',
|
||||
value: function () {
|
||||
var _ref3 = (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee3(ctx) {
|
||||
var params, check, result, username, project, i;
|
||||
var params, check, result, username, project, member;
|
||||
return _regenerator2.default.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
switch (_context3.prev = _context3.next) {
|
||||
@ -449,51 +445,35 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 22:
|
||||
project = _context3.sent;
|
||||
_context3.t1 = _regenerator2.default.keys(project.members);
|
||||
_context3.next = 25;
|
||||
return _yapi2.default.getInst(_user2.default).findById(params.member_uid);
|
||||
|
||||
case 24:
|
||||
if ((_context3.t2 = _context3.t1()).done) {
|
||||
_context3.next = 31;
|
||||
break;
|
||||
}
|
||||
case 25:
|
||||
member = _context3.sent;
|
||||
|
||||
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,
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237' + username + '\u5220\u9664\u4E86\u9879\u76EE' + project.name + '\u4E2D\u7684\u6210\u5458' + member.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;
|
||||
_context3.next = 33;
|
||||
break;
|
||||
|
||||
case 34:
|
||||
_context3.prev = 34;
|
||||
_context3.t3 = _context3['catch'](15);
|
||||
case 30:
|
||||
_context3.prev = 30;
|
||||
_context3.t1 = _context3['catch'](15);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t3.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context3.t1.message);
|
||||
|
||||
case 37:
|
||||
case 33:
|
||||
case 'end':
|
||||
return _context3.stop();
|
||||
}
|
||||
}
|
||||
}, _callee3, this, [[15, 34]]);
|
||||
}, _callee3, this, [[15, 30]]);
|
||||
}));
|
||||
|
||||
function delMember(_x3) {
|
||||
@ -854,7 +834,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, username, project, i;
|
||||
var params, groupInst, check, result, username, project, member;
|
||||
return _regenerator2.default.wrap(function _callee9$(_context9) {
|
||||
while (1) {
|
||||
switch (_context9.prev = _context9.next) {
|
||||
@ -921,52 +901,35 @@ var projectController = function (_baseController) {
|
||||
|
||||
case 24:
|
||||
project = _context9.sent;
|
||||
_context9.t1 = _regenerator2.default.keys(project.members);
|
||||
_context9.next = 27;
|
||||
return _yapi2.default.getInst(_user2.default).findByUids(params.member_uid);
|
||||
|
||||
case 26:
|
||||
if ((_context9.t2 = _context9.t1()).done) {
|
||||
_context9.next = 33;
|
||||
break;
|
||||
}
|
||||
case 27:
|
||||
member = _context9.sent;
|
||||
|
||||
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,
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237' + username + '\u4FEE\u6539\u4E86\u9879\u76EE' + project.name + '\u4E2D\u6210\u5458' + member.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;
|
||||
_context9.next = 35;
|
||||
break;
|
||||
|
||||
case 36:
|
||||
_context9.prev = 36;
|
||||
_context9.t3 = _context9['catch'](17);
|
||||
case 32:
|
||||
_context9.prev = 32;
|
||||
_context9.t1 = _context9['catch'](17);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t3.message);
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context9.t1.message);
|
||||
|
||||
case 39:
|
||||
case 35:
|
||||
case 'end':
|
||||
return _context9.stop();
|
||||
}
|
||||
}
|
||||
}, _callee9, this, [[17, 36]]);
|
||||
}, _callee9, this, [[17, 32]]);
|
||||
}));
|
||||
|
||||
function changeMemberRole(_x10) {
|
||||
@ -1093,33 +1056,30 @@ var projectController = function (_baseController) {
|
||||
case 31:
|
||||
result = _context10.sent;
|
||||
username = this.getUsername();
|
||||
_context10.next = 35;
|
||||
return this.logModel.save({
|
||||
content: '\u7528\u6237' + username + '\u66F4\u65B0\u4E86\u9879\u76EE' + params.name,
|
||||
|
||||
_yapi2.default.commons.saveLog({
|
||||
content: '\u7528\u6237' + username + '\u66F4\u65B0\u4E86\u9879\u76EE' + projectData.name,
|
||||
type: 'project',
|
||||
uid: this.getUid(),
|
||||
username: username,
|
||||
typeid: _id2
|
||||
});
|
||||
|
||||
case 35:
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(result);
|
||||
_context10.next = 41;
|
||||
_context10.next = 40;
|
||||
break;
|
||||
|
||||
case 38:
|
||||
_context10.prev = 38;
|
||||
case 37:
|
||||
_context10.prev = 37;
|
||||
_context10.t1 = _context10['catch'](0);
|
||||
|
||||
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context10.t1.message);
|
||||
|
||||
case 41:
|
||||
case 40:
|
||||
case 'end':
|
||||
return _context10.stop();
|
||||
}
|
||||
}
|
||||
}, _callee10, this, [[0, 38]]);
|
||||
}, _callee10, this, [[0, 37]]);
|
||||
}));
|
||||
|
||||
function up(_x11) {
|
||||
|
@ -24,6 +24,10 @@ var _sha = require('sha1');
|
||||
|
||||
var _sha2 = _interopRequireDefault(_sha);
|
||||
|
||||
var _log = require('../models/log.js');
|
||||
|
||||
var _log2 = _interopRequireDefault(_log);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.resReturn = function (data, num, errmsg) {
|
||||
@ -247,4 +251,20 @@ exports.handleParams = function (params, keys) {
|
||||
}
|
||||
|
||||
return params;
|
||||
};
|
||||
|
||||
exports.saveLog = function (logData) {
|
||||
try {
|
||||
var logInst = _yapi2.default.getInst(_log2.default);
|
||||
var data = {
|
||||
content: logData.content,
|
||||
type: logData.type,
|
||||
uid: logData.uid,
|
||||
username: logData.username,
|
||||
typeid: logData.typeid
|
||||
};
|
||||
logInst.save(data).then();
|
||||
} catch (e) {
|
||||
_yapi2.default.commons.log(e, 'error'); // eslint-disable-line
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue
Block a user