diff --git a/README.md b/README.md
index 1734106..cd692af 100644
--- a/README.md
+++ b/README.md
@@ -15,11 +15,11 @@
安装依赖包 `pip install -r requirements.txt`
-修改数据库连接 `server\settings_dev.py`
+
运行服务 `python manage.py runserver 8000`
diff --git a/client/src/api/file.js b/client/src/api/file.js
index e380b10..dd9e644 100644
--- a/client/src/api/file.js
+++ b/client/src/api/file.js
@@ -1,3 +1,3 @@
-export function uploadUrl(){
- return process.env.VUE_APP_BASE_API + '/upload/'
-}
\ No newline at end of file
+export function uploadUrl() {
+ return process.env.VUE_APP_BASE_API + '/upload/'
+}
diff --git a/client/src/api/org.js b/client/src/api/org.js
index a931a3f..2880ec4 100644
--- a/client/src/api/org.js
+++ b/client/src/api/org.js
@@ -10,7 +10,7 @@ export function getOrgList(query) {
return request({
url: '/system/organization/',
method: 'get',
- params:query
+ params: query
})
}
export function createOrg(data) {
@@ -32,4 +32,4 @@ export function deleteOrg(id) {
url: `/system/organization/${id}/`,
method: 'delete'
})
-}
\ No newline at end of file
+}
diff --git a/client/src/api/position.js b/client/src/api/position.js
index 92b5548..2ea116f 100644
--- a/client/src/api/position.js
+++ b/client/src/api/position.js
@@ -1,6 +1,5 @@
import request from '@/utils/request'
-
export function getPositionAll() {
return request({
url: '/system/position/',
diff --git a/client/src/api/user.js b/client/src/api/user.js
index 2352e0d..2712ba4 100644
--- a/client/src/api/user.js
+++ b/client/src/api/user.js
@@ -15,7 +15,6 @@ export function logout() {
})
}
-
export function getInfo() {
return request({
url: '/system/user/info/',
@@ -23,8 +22,6 @@ export function getInfo() {
})
}
-
-
export function getUserList(query) {
return request({
url: '/system/user/',
diff --git a/client/src/main.js b/client/src/main.js
index 1f6594b..c404257 100644
--- a/client/src/main.js
+++ b/client/src/main.js
@@ -14,7 +14,6 @@ import router from './router'
import '@/icons' // icon
import '@/permission' // permission control
-
/**
* If you don't want to use mock-server
* you want to use MockJs for mock api
@@ -31,7 +30,7 @@ if (process.env.NODE_ENV === 'production') {
// set ElementUI lang to EN
// Vue.use(ElementUI, { locale })
// 如果想要中文版 element-ui,按如下方式声明
-Vue.use(ElementUI, { size: 'medium' });
+Vue.use(ElementUI, { size: 'medium' })
Vue.config.productionTip = false
diff --git a/client/src/router/index.js b/client/src/router/index.js
index 690af7b..804a435 100644
--- a/client/src/router/index.js
+++ b/client/src/router/index.js
@@ -97,7 +97,17 @@ export const asyncRoutes = [
name: 'Dict',
component: () => import('@/views/system/dict'),
meta: { title: '数据字典', icon: 'example', perms: ['dict_manage'] }
- }
+ },
+ {
+ path: 'external-link',
+ component: Layout,
+ children: [
+ {
+ path: process.env.VUE_APP_BASE_API + '/docs/',
+ meta: { title: '接口文档', icon: 'link', perms: ['docs'] }
+ }
+ ]
+ },
]
},
{
diff --git a/client/src/store/modules/user.js b/client/src/store/modules/user.js
index 3dba2c2..d75d478 100644
--- a/client/src/store/modules/user.js
+++ b/client/src/store/modules/user.js
@@ -41,7 +41,6 @@ const actions = {
commit('SET_TOKEN', data.access)
setToken(data.access)
resolve()
-
}).catch(error => {
reject(error)
})
@@ -64,7 +63,7 @@ const actions = {
if (!perms || perms.length <= 0) {
reject('没有任何权限!')
}
-
+
commit('SET_PERMS', perms)
commit('SET_NAME', name)
commit('SET_AVATAR', avatar)
diff --git a/client/src/utils/auth.js b/client/src/utils/auth.js
index 4a1c963..392db62 100644
--- a/client/src/utils/auth.js
+++ b/client/src/utils/auth.js
@@ -22,4 +22,4 @@ export function removeToken() {
// method: 'post',
// data
// })
-// }
\ No newline at end of file
+// }
diff --git a/client/src/utils/index.js b/client/src/utils/index.js
index 5b55a3e..cfdf23c 100644
--- a/client/src/utils/index.js
+++ b/client/src/utils/index.js
@@ -244,7 +244,7 @@ export function getTime(type) {
export function debounce(func, wait, immediate) {
let timeout, args, context, timestamp, result
- const later = function () {
+ const later = function() {
// 据上一次触发时间间隔
const last = +new Date() - timestamp
@@ -261,7 +261,7 @@ export function debounce(func, wait, immediate) {
}
}
- return function (...args) {
+ return function(...args) {
context = this
timestamp = +new Date()
const callNow = immediate && !timeout
@@ -346,37 +346,36 @@ export function removeClass(ele, cls) {
}
}
-
export function genTree(data) {
- let result = []
+ const result = []
if (!Array.isArray(data)) {
return result
}
data.forEach(item => {
- delete item.children;
- });
- let map = {};
+ delete item.children
+ })
+ const map = {}
data.forEach(item => {
item.label = item.name
item.value = item.id
- map[item.id] = item;
- });
+ map[item.id] = item
+ })
data.forEach(item => {
- let parent = map[item.pid];
+ const parent = map[item.pid]
if (parent) {
- (parent.children || (parent.children = [])).push(item);
+ (parent.children || (parent.children = [])).push(item)
} else {
- result.push(item);
+ result.push(item)
}
- });
- return result;
+ })
+ return result
}
const arrChange = arr => arr.map(item => {
- const res = {};
- for (let key in item) {
- let _key = key === 'name' ? 'label' : key;
- res[_key] = Array.isArray(item[key]) ? arrChange(item[key]) : item[key];
+ const res = {}
+ for (const key in item) {
+ const _key = key === 'name' ? 'label' : key
+ res[_key] = Array.isArray(item[key]) ? arrChange(item[key]) : item[key]
}
return res
-});
\ No newline at end of file
+})
diff --git a/client/src/utils/permission.js b/client/src/utils/permission.js
index 20b6aea..217bdeb 100644
--- a/client/src/utils/permission.js
+++ b/client/src/utils/permission.js
@@ -9,7 +9,7 @@ export default function checkPermission(value) {
if (value && value instanceof Array && value.length > 0) {
const perms = store.getters && store.getters.perms
const permissionperms = value
- if(perms.includes('admin')){
+ if (perms.includes('admin')) {
return true
} // 如果是超管,都可以操作
const hasPermission = perms.some(perm => {
diff --git a/client/src/views/login/index.vue b/client/src/views/login/index.vue
index 5be3575..2568652 100644
--- a/client/src/views/login/index.vue
+++ b/client/src/views/login/index.vue
@@ -78,8 +78,8 @@ export default {
password: ''
},
loginRules: {
- username: [{ required: true, trigger: 'blur', message: "请输入账户" }],
- password: [{ required: true, trigger: 'blur', validator: validatePassword, message: "请输入密码" }]
+ username: [{ required: true, trigger: 'blur', message: '请输入账户' }],
+ password: [{ required: true, trigger: 'blur', validator: validatePassword, message: '请输入密码' }]
},
loading: false,
passwordType: 'password',
diff --git a/client/src/views/system/position.vue b/client/src/views/system/position.vue
index 1955166..4ffd926 100644
--- a/client/src/views/system/position.vue
+++ b/client/src/views/system/position.vue
@@ -8,20 +8,20 @@
class="filter-item"
@keyup.native="handleFilter"
/>
- 新增
+ 新增
-
+
{{ scope.row.name }}
@@ -35,28 +35,28 @@
+ @click="handleEdit(scope)"
+ />
+ @click="handleDelete(scope)"
+ />
@@ -76,125 +76,125 @@ import {
createPosition,
deletePosition,
updatePosition
-} from "@/api/position";
-import { genTree, deepClone } from "@/utils";
-import checkPermission from "@/utils/permission";
+} from '@/api/position'
+import { genTree, deepClone } from '@/utils'
+import checkPermission from '@/utils/permission'
const defaultM = {
- id: "",
- name: ""
-};
+ id: '',
+ name: ''
+}
export default {
data() {
return {
position: {
- id: "",
- name: ""
+ id: '',
+ name: ''
},
- search: "",
+ search: '',
tableData: [],
positionList: [],
listLoading: true,
dialogVisible: false,
- dialogType: "new",
+ dialogType: 'new',
rule1: {
- name: [{ required: true, message: "请输入名称", trigger: "blur" }]
+ name: [{ required: true, message: '请输入名称', trigger: 'blur' }]
}
- };
+ }
},
computed: {},
created() {
- this.getList();
+ this.getList()
},
methods: {
checkPermission,
getList() {
- this.listLoading = true;
+ this.listLoading = true
getPositionAll().then(response => {
- this.positionList = response.data;
- this.tableData = response.data;
- this.listLoading = false;
- });
+ this.positionList = response.data
+ this.tableData = response.data
+ this.listLoading = false
+ })
},
resetFilter() {
- this.getList();
+ this.getList()
},
handleFilter() {
const newData = this.positionList.filter(
data =>
!this.search ||
data.name.toLowerCase().includes(this.search.toLowerCase())
- );
- this.tableData = genTree(newData);
+ )
+ this.tableData = genTree(newData)
},
handleAdd() {
- this.position = Object.assign({}, defaultM);
- this.dialogType = "new";
- this.dialogVisible = true;
+ this.position = Object.assign({}, defaultM)
+ this.dialogType = 'new'
+ this.dialogVisible = true
this.$nextTick(() => {
- this.$refs["Form"].clearValidate();
- });
+ this.$refs['Form'].clearValidate()
+ })
},
handleEdit(scope) {
- this.position = Object.assign({}, scope.row); // copy obj
- this.dialogType = "edit";
- this.dialogVisible = true;
+ this.position = Object.assign({}, scope.row) // copy obj
+ this.dialogType = 'edit'
+ this.dialogVisible = true
this.$nextTick(() => {
- this.$refs["Form"].clearValidate();
- });
+ this.$refs['Form'].clearValidate()
+ })
},
handleDelete(scope) {
- this.$confirm("确认删除?", "警告", {
- confirmButtonText: "确认",
- cancelButtonText: "取消",
- type: "error"
+ this.$confirm('确认删除?', '警告', {
+ confirmButtonText: '确认',
+ cancelButtonText: '取消',
+ type: 'error'
})
- .then(async () => {
- await deletePosition(scope.row.id);
- this.getList();
+ .then(async() => {
+ await deletePosition(scope.row.id)
+ this.getList()
this.$message({
- type: "success",
- message: "成功删除!"
- });
+ type: 'success',
+ message: '成功删除!'
+ })
})
.catch(err => {
- console.error(err);
- });
+ console.error(err)
+ })
},
async confirm(form) {
this.$refs[form].validate(valid => {
if (valid) {
- const isEdit = this.dialogType === "edit";
+ const isEdit = this.dialogType === 'edit'
if (isEdit) {
updatePosition(this.position.id, this.position).then(() => {
- this.getList();
- this.dialogVisible = false;
+ this.getList()
+ this.dialogVisible = false
this.$notify({
- title: "成功",
- message: "编辑成功",
- type: "success",
+ title: '成功',
+ message: '编辑成功',
+ type: 'success',
duration: 2000
- });
- });
+ })
+ })
} else {
createPosition(this.position).then(res => {
// this.position = res.data
// this.tableData.unshift(this.position)
- this.getList();
- this.dialogVisible = false;
+ this.getList()
+ this.dialogVisible = false
this.$notify({
- title: "成功",
- message: "新增成功",
- type: "success",
+ title: '成功',
+ message: '新增成功',
+ type: 'success',
duration: 2000
- });
- });
+ })
+ })
}
} else {
- return false;
+ return false
}
- });
+ })
}
}
-};
+}
diff --git a/client/src/views/system/user.vue b/client/src/views/system/user.vue
index 90c0d7b..3da65e2 100644
--- a/client/src/views/system/user.vue
+++ b/client/src/views/system/user.vue
@@ -1,7 +1,8 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/认证主流程.png b/docs/认证主流程.png
new file mode 100644
index 0000000..8e366bf
Binary files /dev/null and b/docs/认证主流程.png differ
diff --git a/server/Dockerfile b/server/Dockerfile
new file mode 100644
index 0000000..db45a67
--- /dev/null
+++ b/server/Dockerfile
@@ -0,0 +1,18 @@
+# 从仓库拉取 带有 python 3.7 的 Linux 环境
+FROM python:3.6.8
+
+# 设置 python 环境变量
+ENV PYTHONUNBUFFERED 1
+
+
+# 创建 code 文件夹并将其设置为工作目录
+RUN mkdir /cnas_server
+WORKDIR /cnas_server
+# 更新 pip
+RUN pip install pip -U -i https://pypi.tuna.tsinghua.edu.cn/simple
+# 将 requirements.txt 复制到容器的 code 目录
+ADD requirements.txt /cnas_server/
+# 安装库
+RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
+# 将当前目录复制到容器的 code 目录
+ADD . /cnas_server/
\ No newline at end of file
diff --git a/server/docker-compose.yml b/server/docker-compose.yml
new file mode 100644
index 0000000..e455b25
--- /dev/null
+++ b/server/docker-compose.yml
@@ -0,0 +1,10 @@
+version: "3"
+services:
+ app:
+ restart: always
+ build: . # '点'代表当前目录
+ command: "python3 manage.py runserver 0.0.0.0:8000"
+ volumes:
+ - .:/cnas_server
+ ports:
+ - "8000:8000"
\ No newline at end of file
diff --git a/specification.md b/specification.md
index d4acd17..a52cb31 100644
--- a/specification.md
+++ b/specification.md
@@ -45,9 +45,11 @@
2.Model,Serializer,权限映射, 字段名一律小写, 单词之间用下划线连接
-3.ViewSet和View必须写注释,可用'''注释
+3.模块、类和函数请使用docstring格式注释
4.业务模块全部放于apps文件夹下
+5.遵循restful设计
+