docs: 文档更新

This commit is contained in:
wenbo.dong 2017-08-22 17:42:50 +08:00
parent bde62b3ed4
commit eca7ba2b9b
4 changed files with 260 additions and 133 deletions

View File

@ -460,26 +460,6 @@ class projectController extends baseController {
* @returns {Object}
* @example ./api/project/up.json
*/
async upSet(ctx){
let id = ctx.request.body.id;
let data = {};
data.color = ctx.request.body.color;
data.icon = ctx.request.body.icon;
if(!id){
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
}
try{
let result = await this.Model.up(id, data);
ctx.body = yapi.commons.resReturn(result);
}catch(e){
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
try{
this.followModel.updateById(this.getUid(),id,data).then();
}catch(e){
yapi.commons.log(e, 'error'); // eslint-disable-line
}
}
async up(ctx) {
try {
let id = ctx.request.body.id;
@ -546,7 +526,7 @@ class projectController extends baseController {
// }catch(e){
// yapi.commons.log(e, 'error'); // eslint-disable-line
// }
let username = this.getUsername();
yapi.commons.saveLog({
content: `用户${username}更新了项目${projectData.name}`,
@ -563,6 +543,38 @@ class projectController extends baseController {
}
}
/**
* 修改项目头像
* @interface /project/upset
* @method POST
* @category project
* @foldnumber 10
* @param {Number} id
* @param {String} color
* @param {String} icon
* @return {Object}
*/
async upSet(ctx){
let id = ctx.request.body.id;
let data = {};
data.color = ctx.request.body.color;
data.icon = ctx.request.body.icon;
if(!id){
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
}
try{
let result = await this.Model.up(id, data);
ctx.body = yapi.commons.resReturn(result);
}catch(e){
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
try{
this.followModel.updateById(this.getUid(),id,data).then();
}catch(e){
yapi.commons.log(e, 'error'); // eslint-disable-line
}
}
/**
* 模糊搜索项目名称或者组名称
* @interface /project/search

View File

@ -1052,76 +1052,15 @@ var projectController = function (_baseController) {
*/
}, {
key: 'upSet',
key: 'up',
value: function () {
var _ref10 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee10(ctx) {
var id, data, result;
var id, params, projectData, checkRepeat, data, result, username;
return _regenerator2.default.wrap(function _callee10$(_context10) {
while (1) {
switch (_context10.prev = _context10.next) {
case 0:
id = ctx.request.body.id;
data = {};
data.color = ctx.request.body.color;
data.icon = ctx.request.body.icon;
if (id) {
_context10.next = 6;
break;
}
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
case 6:
_context10.prev = 6;
_context10.next = 9;
return this.Model.up(id, data);
case 9:
result = _context10.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context10.next = 16;
break;
case 13:
_context10.prev = 13;
_context10.t0 = _context10['catch'](6);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context10.t0.message);
case 16:
try {
this.followModel.updateById(this.getUid(), id, data).then();
} catch (e) {
_yapi2.default.commons.log(e, 'error'); // eslint-disable-line
}
case 17:
case 'end':
return _context10.stop();
}
}
}, _callee10, this, [[6, 13]]);
}));
function upSet(_x11) {
return _ref10.apply(this, arguments);
}
return upSet;
}()
}, {
key: 'up',
value: function () {
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
var id, params, projectData, checkRepeat, data, result, username;
return _regenerator2.default.wrap(function _callee11$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
_context11.prev = 0;
_context10.prev = 0;
id = ctx.request.body.id;
params = ctx.request.body;
@ -1136,39 +1075,39 @@ var projectController = function (_baseController) {
});
if (id) {
_context11.next = 7;
_context10.next = 7;
break;
}
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
case 7:
_context11.next = 9;
_context10.next = 9;
return this.checkAuth(id, 'project', 'edit');
case 9:
_context11.t0 = _context11.sent;
_context10.t0 = _context10.sent;
if (!(_context11.t0 !== true)) {
_context11.next = 12;
if (!(_context10.t0 !== true)) {
_context10.next = 12;
break;
}
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '没有权限'));
case 12:
_context11.next = 14;
_context10.next = 14;
return this.Model.get(id);
case 14:
projectData = _context11.sent;
projectData = _context10.sent;
if (!((params.basepath = this.handleBasepath(params.basepath)) === false)) {
_context11.next = 17;
_context10.next = 17;
break;
}
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, 'basepath格式有误'));
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, 'basepath格式有误'));
case 17:
@ -1177,22 +1116,22 @@ var projectController = function (_baseController) {
}
if (!params.name) {
_context11.next = 24;
_context10.next = 24;
break;
}
_context11.next = 21;
_context10.next = 21;
return this.Model.checkNameRepeat(params.name);
case 21:
checkRepeat = _context11.sent;
checkRepeat = _context10.sent;
if (!(checkRepeat > 0)) {
_context11.next = 24;
_context10.next = 24;
break;
}
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的项目名'));
return _context10.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 401, '已存在的项目名'));
case 24:
data = {
@ -1208,11 +1147,11 @@ var projectController = function (_baseController) {
if (params.env) data.env = params.env;
if (params.color) data.color = params.color;
if (params.icon) data.icon = params.icon;
_context11.next = 33;
_context10.next = 33;
return this.Model.up(id, data);
case 33:
result = _context11.sent;
result = _context10.sent;
// try{
// let data = {};
@ -1242,28 +1181,102 @@ var projectController = function (_baseController) {
color: params.color
});
ctx.body = _yapi2.default.commons.resReturn(result);
_context11.next = 42;
_context10.next = 42;
break;
case 39:
_context11.prev = 39;
_context11.t1 = _context11['catch'](0);
_context10.prev = 39;
_context10.t1 = _context10['catch'](0);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context11.t1.message);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context10.t1.message);
case 42:
case 'end':
return _context10.stop();
}
}
}, _callee10, this, [[0, 39]]);
}));
function up(_x11) {
return _ref10.apply(this, arguments);
}
return up;
}()
/**
* 修改项目头像
* @interface /project/upset
* @method POST
* @category project
* @foldnumber 10
* @param {Number} id
* @param {String} color
* @param {String} icon
* @return {Object}
*/
}, {
key: 'upSet',
value: function () {
var _ref11 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee11(ctx) {
var id, data, result;
return _regenerator2.default.wrap(function _callee11$(_context11) {
while (1) {
switch (_context11.prev = _context11.next) {
case 0:
id = ctx.request.body.id;
data = {};
data.color = ctx.request.body.color;
data.icon = ctx.request.body.icon;
if (id) {
_context11.next = 6;
break;
}
return _context11.abrupt('return', ctx.body = _yapi2.default.commons.resReturn(null, 405, '项目id不能为空'));
case 6:
_context11.prev = 6;
_context11.next = 9;
return this.Model.up(id, data);
case 9:
result = _context11.sent;
ctx.body = _yapi2.default.commons.resReturn(result);
_context11.next = 16;
break;
case 13:
_context11.prev = 13;
_context11.t0 = _context11['catch'](6);
ctx.body = _yapi2.default.commons.resReturn(null, 402, _context11.t0.message);
case 16:
try {
this.followModel.updateById(this.getUid(), id, data).then();
} catch (e) {
_yapi2.default.commons.log(e, 'error'); // eslint-disable-line
}
case 17:
case 'end':
return _context11.stop();
}
}
}, _callee11, this, [[0, 39]]);
}, _callee11, this, [[6, 13]]);
}));
function up(_x12) {
function upSet(_x12) {
return _ref11.apply(this, arguments);
}
return up;
return upSet;
}()
/**

View File

@ -220,6 +220,10 @@
<a href="#-project-up">/project/up</a>
</li>
<li >
<a href="#-project-upset">/project/upset</a>
</li>
<li >
<a href="#-project-search">/project/search</a>
</li>
@ -2915,6 +2919,92 @@
<span class="token punctuation">}</span></code></pre>
</div>
<div class="con-list-item">
<blockquote class="api">
<h3 id="-project-upset" class="page-header subject">
/project/upset
<span class="ui-badge">POST</span>
<a class="hashlink" href="#-project-upset">#</a>
</h3>
</blockquote>
<p>
<small class="text-muted">描述:</small>
修改项目头像
</p>
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#545" target="_blank">./server/controllers/project.js:545</a>
</p>
<p>
<small class="text-muted">参数:</small>
</p>
<div class="docs-table">
<table class="yo-table yo-table-border">
<colgroup>
<col class="c1">
<col class="c2">
<col class="c3">
<col class="c4">
</colgroup>
<thead>
<tr class="active">
<th>参数名</th>
<th>类型</th>
<th>描述</th>
<th>必选</th>
<th>支持版本</th>
</tr>
</thead>
<tr>
<td>id</td>
<td>Number</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>color</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
<tr>
<td>icon</td>
<td>String</td>
<td></td>
<td>
<i class="yo-ico glyphicon glyphicon-ok text-success"></i>
</td>
<td></td>
</tr>
</table>
</div>
</div>
<div class="con-list-item">
@ -2935,7 +3025,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#565" target="_blank">./server/controllers/project.js:565</a>
<a href="./static/server/controllers/project.js.html#577" target="_blank">./server/controllers/project.js:577</a>
</p>
@ -3030,7 +3120,7 @@
<p>
<small class="text-muted">源码位置:</small>
<a href="./static/server/controllers/project.js.html#619" target="_blank">./server/controllers/project.js:619</a>
<a href="./static/server/controllers/project.js.html#631" target="_blank">./server/controllers/project.js:631</a>
</p>

View File

@ -487,26 +487,6 @@ class projectController extends baseController {
* @returns {Object}
* @example ./api/project/up.json
*/
async upSet(ctx){
let id = ctx.request.body.id;
let data = {};
data.color = ctx.request.body.color;
data.icon = ctx.request.body.icon;
if(!id){
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
}
try{
let result = await this.Model.up(id, data);
ctx.body = yapi.commons.resReturn(result);
}catch(e){
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
try{
this.followModel.updateById(this.getUid(),id,data).then();
}catch(e){
yapi.commons.log(e, 'error'); // eslint-disable-line
}
}
async up(ctx) {
try {
let id = ctx.request.body.id;
@ -573,7 +553,7 @@ class projectController extends baseController {
// }catch(e){
// yapi.commons.log(e, 'error'); // eslint-disable-line
// }
let username = this.getUsername();
yapi.commons.saveLog({
content: `用户${username}更新了项目${projectData.name}`,
@ -590,6 +570,38 @@ class projectController extends baseController {
}
}
/**
* 修改项目头像
* @interface /project/upset
* @method POST
* @category project
* @foldnumber 10
* @param {Number} id
* @param {String} color
* @param {String} icon
* @return {Object}
*/
async upSet(ctx){
let id = ctx.request.body.id;
let data = {};
data.color = ctx.request.body.color;
data.icon = ctx.request.body.icon;
if(!id){
return ctx.body = yapi.commons.resReturn(null, 405, '项目id不能为空');
}
try{
let result = await this.Model.up(id, data);
ctx.body = yapi.commons.resReturn(result);
}catch(e){
ctx.body = yapi.commons.resReturn(null, 402, e.message);
}
try{
this.followModel.updateById(this.getUid(),id,data).then();
}catch(e){
yapi.commons.log(e, 'error'); // eslint-disable-line
}
}
/**
* 模糊搜索项目名称或者组名称
* @interface /project/search