Skip to content

Commit

Permalink
Merge pull request #71 from TaleLin/develop
Browse files Browse the repository at this point in the history
feat & fix: 更改文件名命名, getInformation 接口返回完整头像链接
  • Loading branch information
vanoneang authored Apr 17, 2020
2 parents 14240fd + 73c284b commit 10ec44d
Show file tree
Hide file tree
Showing 50 changed files with 80 additions and 74 deletions.
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Lin-CMS 是林间有风团队经过大量项目实践所提炼出的一套**内

lin-mizar(核心库) :0.3.2

lin-cms-koa(当前示例工程):0.3.1
lin-cms-koa(当前示例工程):0.3.3

### 文档地址

Expand All @@ -61,7 +61,12 @@ QQ 群号:643205479

## 版本日志

最新版本 `0.3.2`
最新版本 `0.3.3`

### 0.3.3

1. `F` `GET /cms/user/information` 返回完整的头像链接
2. `F` 文件名重命名为用 `-` 连接,并且使用单数

### 0.3.2

Expand Down
4 changes: 2 additions & 2 deletions app/api/cms/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import {
DispatchPermissionValidator,
DispatchPermissionsValidator,
RemovePermissionsValidator
} from '../../validators/admin';
} from '../../validator/admin';
import {
PositiveIdValidator,
PaginateValidator
} from '../../validators/common';
} from '../../validator/common';

import { adminRequired } from '../../middleware/jwt';
import { AdminDao } from '../../dao/admin';
Expand Down
2 changes: 1 addition & 1 deletion app/api/cms/file.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LinRouter, ParametersException } from 'lin-mizar';

import { loginRequired } from '../../middleware/jwt';
import { LocalUploader } from '../../extensions/file/local-uploader';
import { LocalUploader } from '../../extension/file/local-uploader';

const file = new LinRouter({
prefix: '/cms/file'
Expand Down
4 changes: 2 additions & 2 deletions app/api/cms/log.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { LinRouter, NotFound } from 'lin-mizar';
import { LogFindValidator } from '../../validators/log';
import { PaginateValidator } from '../../validators/common';
import { LogFindValidator } from '../../validator/log';
import { PaginateValidator } from '../../validator/common';

import { groupRequired } from '../../middleware/jwt';
import { LogDao } from '../../dao/log';
Expand Down
4 changes: 2 additions & 2 deletions app/api/cms/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import {
LoginValidator,
UpdateInfoValidator,
ChangePasswordValidator
} from '../../validators/user';
} from '../../validator/user';

import {
adminRequired,
loginRequired,
refreshTokenRequiredWithUnifyException
} from '../../middleware/jwt';
import { UserIdentityModel } from '../../models/user';
import { UserIdentityModel } from '../../model/user';
import { logger } from '../../middleware/logger';
import { UserDao } from '../../dao/user';

Expand Down
8 changes: 4 additions & 4 deletions app/api/v1/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { groupRequired } from '../../middleware/jwt';
import {
BookSearchValidator,
CreateOrUpdateBookValidator
} from '../../validators/book';
import { PositiveIdValidator } from '../../validators/common';
} from '../../validator/book';
import { PositiveIdValidator } from '../../validator/common';

import { getSafeParamId } from '../../libs/util';
import { BookNotFound } from '../../libs/err-code';
import { getSafeParamId } from '../../lib/util';
import { BookNotFound } from '../../lib/err-code';
import { BookDao } from '../../dao/book';

// book 的红图实例
Expand Down
2 changes: 1 addition & 1 deletion app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cors from '@koa/cors';
import mount from 'koa-mount';
import serve from 'koa-static';
import { config, json, logging, success, jwt, Loader } from 'lin-mizar';
import { PermissionModel } from './models/permission';
import { PermissionModel } from './model/permission';

/**
* 首页
Expand Down
2 changes: 1 addition & 1 deletion app/config/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ module.exports = {
// // determine a plugin work or not
// enable: true,
// // path of the plugin
// path: "app/plugins/poem",
// path: "app/plugin/poem",
// // other config
// limit: 2
// },
Expand Down
12 changes: 6 additions & 6 deletions app/dao/admin.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { NotFound, Forbidden } from 'lin-mizar';
import { PermissionModel } from '../models/permission';
import { UserModel, UserIdentityModel } from '../models/user';
import { GroupModel } from '../models/group';
import { PermissionModel } from '../model/permission';
import { UserModel, UserIdentityModel } from '../model/user';
import { GroupModel } from '../model/group';

import { GroupPermissionModel } from '../models/group-permission';
import { UserGroupModel } from '../models/user-group';
import { GroupPermissionModel } from '../model/group-permission';
import { UserGroupModel } from '../model/user-group';

import sequelize from '../libs/db';
import sequelize from '../lib/db';
import { Op } from 'sequelize';
import { has, set, get } from 'lodash';

Expand Down
2 changes: 1 addition & 1 deletion app/dao/book.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NotFound, Forbidden } from 'lin-mizar';
import { Book } from '../models/book';
import { Book } from '../model/book';
import Sequelize from 'sequelize';

class BookDao {
Expand Down
4 changes: 2 additions & 2 deletions app/dao/log.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Sequelize from 'sequelize';
import { LogModel } from '../models/log';
import { LogModel } from '../model/log';
import { set } from 'lodash';
import sequelize from '../libs/db';
import sequelize from '../lib/db';

class LogDao {
async getLogs (v) {
Expand Down
17 changes: 9 additions & 8 deletions app/dao/user.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { RepeatException, generate, NotFound, Forbidden } from 'lin-mizar';
import { UserModel, UserIdentityModel, identityType } from '../models/user';
import { UserGroupModel } from '../models/user-group';
import { GroupPermissionModel } from '../models/group-permission';
import { PermissionModel } from '../models/permission';
import { GroupModel } from '../models/group';

import sequelize from '../libs/db';
import { RepeatException, generate, NotFound, Forbidden, config } from 'lin-mizar';
import { UserModel, UserIdentityModel, identityType } from '../model/user';
import { UserGroupModel } from '../model/user-group';
import { GroupPermissionModel } from '../model/group-permission';
import { PermissionModel } from '../model/permission';
import { GroupModel } from '../model/group';

import sequelize from '../lib/db';
import { Op } from 'sequelize';
import { set, has, uniq } from 'lodash';

Expand Down Expand Up @@ -108,6 +108,7 @@ class UserDao {
}
}
});

set(user, 'groups', groups);
return user;
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Uploader, config } from 'lin-mizar';
import { FileModel } from '../../models/file';
import { FileModel } from '../../model/file';
import fs from 'fs';
import path from 'path';

Expand Down Expand Up @@ -53,7 +53,7 @@ class LocalUploader extends Uploader {
arr.push({
id: saved.id,
key: file.fieldname,
path: exist.path,
path: saved.path,
url: `${siteDomain}/assets/${saved.path}`,
type: saved.type,
name: file.name,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 5 additions & 5 deletions app/middleware/jwt.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import {
TokenType,
routeMetaInfo
} from 'lin-mizar';
import { UserGroupModel } from '../models/user-group';
import { GroupModel } from '../models/group';
import { GroupPermissionModel } from '../models/group-permission';
import { PermissionModel } from '../models/permission';
import { UserModel } from '../models/user';
import { UserGroupModel } from '../model/user-group';
import { GroupModel } from '../model/group';
import { GroupPermissionModel } from '../model/group-permission';
import { PermissionModel } from '../model/permission';
import { UserModel } from '../model/user';
import { Op } from 'sequelize';
import { uniq } from 'lodash';

Expand Down
2 changes: 1 addition & 1 deletion app/middleware/logger.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { get } from 'lodash';
import { routeMetaInfo, assert } from 'lin-mizar';
import { LogModel } from '../models/log';
import { LogModel } from '../model/log';

const REG_XP = /(?<=\{)[^}]*(?=\})/g;

Expand Down
2 changes: 1 addition & 1 deletion app/models/book.js → app/model/book.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InfoCrudMixin } from 'lin-mizar';
import { merge } from 'lodash';
import { Sequelize, Model } from 'sequelize';
import sequelize from '../libs/db';
import sequelize from '../lib/db';

class Book extends Model {
toJSON () {
Expand Down
2 changes: 1 addition & 1 deletion app/models/file.js → app/model/file.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Model, Sequelize } from 'sequelize';
import sequelize from '../libs/db';
import sequelize from '../lib/db';

class File extends Model {
static async createRecord (args, commit) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Model, Sequelize } from 'sequelize';
import sequelize from '../libs/db';
import sequelize from '../lib/db';

class GroupPermission extends Model {}

Expand Down
2 changes: 1 addition & 1 deletion app/models/group.js → app/model/group.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sequelize from '../libs/db';
import sequelize from '../lib/db';
import { Model, Sequelize } from 'sequelize';
import { has, get } from 'lodash';

Expand Down
2 changes: 1 addition & 1 deletion app/models/log.js → app/model/log.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sequelize from '../libs/db';
import sequelize from '../lib/db';
import { Model, Sequelize } from 'sequelize';

class Log extends Model {
Expand Down
2 changes: 1 addition & 1 deletion app/models/permission.js → app/model/permission.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import sequelize from '../libs/db';
import sequelize from '../lib/db';
import { Model, Sequelize, Op } from 'sequelize';
import { routeMetaInfo } from 'lin-mizar';
import { GroupPermissionModel } from './group-permission';
Expand Down
2 changes: 1 addition & 1 deletion app/models/user-group.js → app/model/user-group.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Model, Sequelize } from 'sequelize';
import sequelize from '../libs/db';
import sequelize from '../lib/db';

class UserGroup extends Model {}

Expand Down
6 changes: 3 additions & 3 deletions app/models/user.js → app/model/user.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NotFound, verify, AuthFailed, generate, Failed } from 'lin-mizar';
import { NotFound, verify, AuthFailed, generate, Failed, config } from 'lin-mizar';

import sequelize from '../libs/db';
import sequelize from '../lib/db';
import { Model, Sequelize } from 'sequelize';
import { get, has, unset } from 'lodash';

Expand Down Expand Up @@ -118,7 +118,7 @@ class User extends Model {
username: this.username,
nickname: this.nickname,
email: this.email,
avatar: this.avatar
avatar: `${config.getItem('siteDomain', 'http://localhost')}/assets/${this.avatar}`
};
if (has(this, 'groups')) {
return { ...origin, groups: get(this, 'groups', []) };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Router from 'koa-router';
import { PoemListValidator, PoemSearchValidator } from './validators';
import { PoemListValidator, PoemSearchValidator } from './validator';
import { Poem } from './model';

const api = new Router({ prefix: '/poem' });
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InfoCrudMixin } from 'lin-mizar';
import { merge } from 'lodash';
import { Sequelize, Model } from 'sequelize';
import sequelize from '../../../libs/db';
import sequelize from '../../../lib/db';

const { config } = require('lin-mizar/lin/config');

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/starter.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function applyConfig () {
config.getConfigFromFile(`app/config/${file}`);
}
// 加载其它配置文件
config.getConfigFromFile('app/extensions/file/config.js');
config.getConfigFromFile('app/extension/file/config.js');
}

const run = async () => {
Expand Down
2 changes: 1 addition & 1 deletion app/validators/admin.js → app/validator/admin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Rule, LinValidator } from 'lin-mizar';
import { isOptional } from '../libs/util';
import { isOptional } from '../lib/util';
import { PaginateValidator, PositiveIdValidator } from './common';
import validator from 'validator';

Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion app/validators/log.js → app/validator/log.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Rule, checkDateFormat } from 'lin-mizar';
import { PaginateValidator } from './common';
import { isOptional } from '../libs/util';
import { isOptional } from '../lib/util';

class LogFindValidator extends PaginateValidator {
constructor () {
Expand Down
2 changes: 1 addition & 1 deletion app/validators/user.js → app/validator/user.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LinValidator, Rule } from 'lin-mizar';
import { isOptional } from '../libs/util';
import { isOptional } from '../lib/util';
import validator from 'validator';

class RegisterValidator extends LinValidator {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lin-cms-koa",
"version": "0.3.0",
"version": "0.3.3",
"description": "simple and practical CMS implememted by koa",
"main": "app/starter.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion tests/api/cms/test1.test.js → test/api/cms/test1.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../../helper/initial';
import request from 'supertest';
import { createApp } from '../../../app/app';
import sequelize from '../../../app/libs/db';
import sequelize from '../../../app/lib/db';

describe('test1.test.js', () => {
// 必须,app示例
Expand Down
2 changes: 1 addition & 1 deletion tests/api/cms/user1.test.js → test/api/cms/user1.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../../helper/initial';
import request from 'supertest';
import { createApp } from '../../../app/app';
import sequelize from '../../../app/libs/db';
import sequelize from '../../../app/lib/db';
import { saveTokens } from '../../helper/token';

describe('user1.test.js', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/api/cms/user2.test.js → test/api/cms/user2.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import '../../helper/initial';
import request from 'supertest';
import { createApp } from '../../../app/app';
import sequelize from '../../../app/libs/db';
import sequelize from '../../../app/lib/db';
import { getToken } from '../../helper/token';

describe('user2.test.js', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import '../initial';
import sequelize from '../../../app/libs/db';
import { Book } from '../../../app/models/book';
import sequelize from '../../../app/lib/db';
import { Book } from '../../../app/model/book';

const run = async () => {
await Book.bulkCreate([
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require('@babel/register');

require('./fake_book');
require('./fake-book');
Loading

0 comments on commit 10ec44d

Please sign in to comment.