Commit 7631019b authored by Davve's avatar Davve

完成账号管理开发

parent 5b5e54a5
......@@ -12,26 +12,29 @@ class AccountList(APIView):
limit = request.GET.get('limit', 10)
filter = self.handle_filter(request.GET.get('filter', ""))
try:
data = self.rpc['venus/community/pick/get'](offset=page, limit=limit, filters=filter).unwrap()
data = self.rpc['venus/community/account/get'](offset=page, limit=limit, filters=filter).unwrap()
except Exception as e:
# raise e
pass
data = {
'total': 100,
'data': [
{'id': 1, 'nickname': '鹿晗1', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin1'},
{'id': 2, 'nickname': '鹿晗2', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin2'},
{'id': 3, 'nickname': '鹿晗3', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin3'},
{'id': 4, 'nickname': '鹿晗4', 'password': '21233423', 'email': 'www.baidu.com', 'username': 'admin4'},
]
}
data = {
'total': 1,
'data': [
{
'id': 1,
'username': 'hahah',
'nickname': '哈哈',
'phone': '123124312423',
'email': 'www.baid.com',
'password': '2412412'
}
]
}
return data
def post(self, request):
ids = request.POST.get('ids', '').split()
type = request.POST.get('type', '')
try:
self.rpc['venus/community/account/offline_account'](type=type, ids=ids).unwrap()
self.rpc['venus/community/account/update'](type=type, ids=ids).unwrap()
except Exception as e:
raise e
return {
......@@ -39,7 +42,64 @@ class AccountList(APIView):
}
class AccountUpdateOrCreateView(APIView):
def get(self, request):
id = request.GET.get('id')
try:
data = self.rpc['venus/community/account/detail'](id=id).unwrap()
except Exception as e:
# raise e
data = {
'id': 1,
'username': 'hahah',
'nickname': '哈哈',
'phone': '123124312423',
'email': 'www.baid.com',
'password': '2412412'
}
return {'data': data}
def post(self, request):
id = request.POST.get('id')
data = {
'username': request.POST.get('username'),
'email': request.POST.get('email'),
'password': request.POST.get('password'),
'phone': request.POST.get('phone'),
'nickname': request.POST.get('nickname'),
}
try:
self.rpc['venus/community/account/create'](id=id, data=data).unwrap()
except Exception as e:
raise e
return {
'message': '创建成功'
}
class LoginView(APIView):
def get(self, request):
map = {
'admin': {
'roles': ['admin'],
'token': 'admin',
'introduction': '我是超级管理员',
'avatar': 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
'name': 'Super Admin'
},
'editor': {
'roles': ['editor'],
'token': 'editor',
'introduction': '我是编辑',
'avatar': 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
'name': 'Normal Editor'
}
}
token = request.GET.get('token')
return {
'data': map['admin']
}
def post(self, request):
username = request.POST.get('username')
password = request.POST.get('password')
......@@ -69,25 +129,3 @@ class LogoutView(APIView):
pass
class AccountUpdateOrCreateView(APIView):
def get(self, request):
map = {
'admin': {
'roles': ['admin'],
'token': 'admin',
'introduction': '我是超级管理员',
'avatar': 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
'name': 'Super Admin'
},
'editor': {
'roles': ['editor'],
'token': 'editor',
'introduction': '我是编辑',
'avatar': 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
'name': 'Normal Editor'
}
}
token = request.GET.get('token')
return {
'data': map['admin']
}
\ No newline at end of file
......@@ -8,21 +8,29 @@ from utils.base import APIView
class GroupListView(APIView):
def get(self, request):
offset = request.GET.get('page', 1)
count = request.GET.get('limit', 10)
offset = int(request.GET.get('page', 0))
count = int(request.GET.get('limit', 10))
filters = self.handle_filter(request.GET.get('filter', ""))
try:
data = self.rpc['venus/community/group/list'](filters=filters, offset=offset, count=count).unwrap()
except Exception as e:
# raise e
data = {
'total': 200,
'data': [
{'id': 1, 'description': '测试1', 'name': '测试2', "star_name":"鹿晗", "user_nums":23,"topic_num": 12,'push_time': '2018-08-09','create_time':'2019-08-07', 'creator_id':22, 'creator': 'hi', 'is_online':1, 'is_recommend':1},
{'id': 2, 'description': '测试1', 'name': '测试2', "star_name":"鹿晗","user_nums":23,"topic_num": 12,'push_time': '2018-08-09', 'create_time': '2019-08-07',
'creator_id': 22, 'creator_id':22, 'creator': 'hi', 'is_online':1, 'is_recommend':1},
{'id': 3, 'description': '测试1', 'name': '测试2', "star_name":"鹿晗","user_nums":23,"topic_num": 12,'push_time': '2018-08-09', 'create_time': '2019-08-07',
'creator_id': 22, 'creator_id':22, 'creator': 'hi', 'is_online':1, 'is_recommend':1},
]
}
return data
\ No newline at end of file
raise e
return data
def post(self, request):
ids = request.POST.get('ids', '').split()
type = request.POST.get('type')
filters = {}
if type == 'offline':
filters['is_online'] = False
elif type == 'recommend':
filters['recommend'] = True
else:
filters['is_online'] = True
try:
self.rpc['venus/community/group/batch/update'](filters=filters, ids=ids).unwrap()
except Exception as e:
raise e
return {
"message": "更新成功"
}
\ No newline at end of file
......@@ -20,13 +20,15 @@ urlpatterns = [
url(r'account/logout', LogoutView.as_view()),
url(r'account/list', AccountList.as_view()),
url(r'account/update', AccountList.as_view()),
url(r'account/get', AccountUpdateOrCreateView.as_view()),
url(r'account/get', LoginView.as_view()),
url(r'account/detail', AccountUpdateOrCreateView.as_view()),
url(r'account/create', AccountUpdateOrCreateView.as_view()),
# user相关
url(r'user/list$', UserListView.as_view()),
# group相关
url(r'group/list$', GroupListView.as_view()),
url(r'group/update$', GroupListView.as_view()),
# topic相关
url(r'topic/list$', TopicListView.as_view()),
......
## sun
vu 前端代码本地调试
brew install npm
npm install
npm run dev
\ No newline at end of file
Django==2.1
Django==1.11
Jinja2==2.9.6
git+ssh://git@git.wanmeizhensuo.com/system/kafka-python.git@master
......
......@@ -9,7 +9,6 @@ export function fetchList(query) {
}
export function OffLineOrOnLine(data) {
console.log(data)
return request({
url: '/api/account/update',
method: 'post',
......@@ -17,3 +16,19 @@ export function OffLineOrOnLine(data) {
})
}
export function CreateAccount(data) {
return request({
url: '/api/account/create',
method: 'post',
data
})
}
export function fetchAccountDetail(id) {
return request({
url: '/api/account/detail',
method: 'get',
param: { id }
})
}
......@@ -11,7 +11,7 @@ export function fetchList(query) {
export function OffLineOrOnLine(data) {
return request({
url: '/api/group/update_or_create',
url: '/api/group/update',
method: 'post',
data
})
......
......@@ -3,65 +3,66 @@
<el-form ref="postForm" :model="postForm" :rules="rules" class="form-container">
<sticky :class-name="'sub-navbar '+postForm.status">
<el-button v-loading="loading" style="margin-left: 10px;" type="success" @click="submitForm">发布
</el-button>
<el-button v-loading="loading" type="warning" @click="draftForm">草稿</el-button>
<el-button v-loading="loading" style="margin-left: 10px;" type="success" @click="submitForm">保存</el-button>
</sticky>
<div class="createPost-main-container">
<el-row>
<el-col :span="24">
<el-form-item style="margin-bottom: 40px;" prop="title">
<MDinput v-model="postForm.title" :maxlength="100" name="name" required>
标题
<el-form-item style="margin-bottom: 40px;" prop="username">
<MDinput v-model="postForm.username" :maxlength="100" name="username" required>
账号
</MDinput>
</el-form-item>
<div class="postInfo-container">
<el-row>
<el-col :span="8">
<el-form-item label-width="45px" label="作者:" class="postInfo-container-item">
<el-select v-model="postForm.author" :remote-method="getRemoteUserList" filterable remote placeholder="搜索用户">
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item" :value="item"/>
</el-select>
</el-form-item>
</el-col>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item style="margin-bottom: 40px;" prop="password">
<MDinput v-model="postForm.password" :maxlength="100" name="password" required>
密码
</MDinput>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="10">
<el-form-item label-width="80px" label="发布时间:" class="postInfo-container-item">
<el-date-picker v-model="postForm.display_time" type="datetime" format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期时间"/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item style="margin-bottom: 40px;" prop="email">
<MDinput v-model="postForm.email" :maxlength="100" name="email" required>
邮箱
</MDinput>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="24">
<el-form-item style="margin-bottom: 40px;" prop="nickname">
<MDinput v-model="postForm.nickname" :maxlength="100" name="nickname" required>
姓名
</MDinput>
</el-form-item>
<el-col :span="6">
<el-form-item label-width="60px" label="重要性:" class="postInfo-container-item">
<el-rate
v-model="postForm.importance"
:max="3"
:colors="['#99A9BF', '#F7BA2A', '#FF9900']"
:low-threshold="1"
:high-threshold="3"
style="margin-top:8px;"/>
</el-form-item>
</el-col>
</el-row>
</div>
</el-col>
</el-row>
<el-row>
<el-form-item style="margin-bottom: 40px;" label-width="45px" label="摘要:">
<el-input :rows="1" v-model="postForm.content_short" type="textarea" class="article-textarea" autosize placeholder="请输入内容"/>
<span v-show="contentShortLength" class="word-counter">{{ contentShortLength }}</span>
</el-form-item>
<el-col :span="24">
<el-form-item style="margin-bottom: 40px;" prop="phone">
<MDinput v-model="postForm.phone" :maxlength="100" name="phone" required>
电话
</MDinput>
</el-form-item>
<div class="editor-container">
<Tinymce ref="editor" :height="400" v-model="postForm.content" />
</div>
</el-col>
</el-row>
<div style="margin-bottom: 20px;">
<Upload v-model="postForm.image_uri" />
</div>
</div>
</el-form>
......@@ -69,31 +70,24 @@
</template>
<script>
import Tinymce from '@/components/Tinymce'
import Upload from '@/components/Upload/singleImage3'
import MDinput from '@/components/MDinput'
import Sticky from '@/components/Sticky' // 粘性header组件
import { validateURL } from '@/utils/validate'
import { fetchArticle } from '@/api/article'
import { CreateAccount, fetchAccountDetail, } from '@/api/account'
import { userSearch } from '@/api/remoteSearch'
const defaultForm = {
status: 'draft',
title: '', // 文章题目
content: '', // 文章内容
content_short: '', // 文章摘要
source_uri: '', // 文章外链
image_uri: '', // 文章图片
display_time: undefined, // 前台展示时间
id: undefined,
platforms: ['a-platform'],
comment_disabled: false,
importance: 0
username: '',
password: '',
email: '',
phone: '',
nickname: ''
}
export default {
name: 'GroupDetail',
components: { Tinymce, MDinput, Upload, Sticky},
components: {MDinput, Sticky},
props: {
isEdit: {
type: Boolean,
......@@ -112,40 +106,17 @@ export default {
callback()
}
}
const validateSourceUri = (rule, value, callback) => {
if (value) {
if (validateURL(value)) {
callback()
} else {
this.$message({
message: '外链url填写不正确',
type: 'error'
})
callback(new Error('外链url填写不正确'))
}
} else {
callback()
}
}
return {
postForm: Object.assign({}, defaultForm),
loading: false,
userListOptions: [],
rules: {
image_uri: [{ validator: validateRequire }],
title: [{ validator: validateRequire }],
content: [{ validator: validateRequire }],
source_uri: [{ validator: validateSourceUri, trigger: 'blur' }]
username: [{ validator: validateRequire}],
nickname: [{ validator: validateRequire}],
email: [{ validator: validateRequire}],
password: [{ validator: validateRequire}],
phone: [{ validator: validateRequire}],
},
tempRoute: {}
}
},
computed: {
contentShortLength() {
return this.postForm.content_short.length
},
lang() {
return this.$store.getters.language
}
},
created() {
......@@ -156,42 +127,42 @@ export default {
this.postForm = Object.assign({}, defaultForm)
}
// Why need to make a copy of this.$route here?
// Because if you enter this page and quickly switch tag, may be in the execution of the setTagsViewTitle function, this.$route is no longer pointing to the current page
// https://github.com/PanJiaChen/vue-element-admin/issues/1221
this.tempRoute = Object.assign({}, this.$route)
},
methods: {
fetchData(id) {
fetchArticle(id).then(response => {
this.postForm = response.data
// Just for test
this.postForm.title += ` Article Id:${this.postForm.id}`
this.postForm.content_short += ` Article Id:${this.postForm.id}`
fetchAccountDetail(id).then(response => {
console.log(response.data.data)
this.postForm = response.data.data.data
// Set tagsview title
this.setTagsViewTitle()
}).catch(err => {
console.log(err)
})
},
setTagsViewTitle() {
const title = this.lang === 'zh' ? '编辑文章' : 'Edit Article'
const route = Object.assign({}, this.tempRoute, { title: `${title}-${this.postForm.id}` })
this.$store.dispatch('updateVisitedView', route)
},
submitForm() {
this.postForm.display_time = parseInt(this.display_time / 1000)
console.log(this.postForm)
this.$refs.postForm.validate(valid => {
if (valid) {
this.loading = true
this.$notify({
title: '成功',
message: '发布文章成功',
type: 'success',
duration: 2000
})
CreateAccount(this.postForm).then(response => {
this.$notify({
title: '成功',
message: response.data.data.message,
type: 'success',
duration: 2000
})
setTimeout(() => {
this.$router.push('/account/list')
}, 1000)
}).catch(err => {
this.$notify({
title: '失败',
message: '操作失败',
type: 'danger',
duration: 2000
})
});
this.postForm.status = 'published'
this.loading = false
} else {
......@@ -200,22 +171,6 @@ export default {
}
})
},
draftForm() {
if (this.postForm.content.length === 0 || this.postForm.title.length === 0) {
this.$message({
message: '请填写必要的标题和内容',
type: 'warning'
})
return
}
this.$message({
message: '保存成功',
type: 'success',
showClose: true,
duration: 1000
})
this.postForm.status = 'draft'
},
getRemoteUserList(query) {
userSearch(query).then(response => {
if (!response.data.items) return
......
......@@ -14,7 +14,7 @@
<el-table-column type="selection" width="55" align="center"></el-table-column>
<el-table-column align="center" label="账号ID" width="180">
<template slot-scope="scope">
<router-link :to="'/pick/edit/'+scope.row.id" class="link-type">
<router-link :to="'/account/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.id }}</span>
</router-link>
</template>
......@@ -126,7 +126,7 @@ export default {
this.getList()
},
handleCreate() {
this.$router.push('/pick/create')
this.$router.push('/account/create')
},
handleOfflineOrOnline(val){
const length = this.multipleSelection.length;
......
......@@ -27,22 +27,22 @@
</template>
</el-table-column>
<el-table-column width="180px" align="center" label="小组名称">
<el-table-column width="190px" align="center" label="小组名称">
<template slot-scope="scope">
<span>{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column width="204px" align="center" label="小组简介">
<el-table-column width="300px" align="center" label="小组简介">
<template slot-scope="scope">
<span>{{ scope.row.description }}</span>
<span>{{ scope.row.desc }}</span>
</template>
</el-table-column>
<el-table-column width="120px" align="center" label="明星名称">
<template slot-scope="scope">
<span>{{ scope.row.star_name }}</span>
<span>{{ scope.row.star.name }}</span>
</template>
</el-table-column>
......@@ -58,9 +58,9 @@
</template>
</el-table-column>
<el-table-column width="100px" align="center" label="组长">
<el-table-column width="140px" align="center" label="组长">
<template slot-scope="scope">
<span>{{ scope.row.creator }}</span>
<span>{{ scope.row.creator.name }}</span>
</template>
</el-table-column>
......@@ -116,7 +116,7 @@ export default {
multipleSelection: [],
del_list: [],
listQuery: {
page: 1,
page: 0,
limit: 10,
filter: {
value: '',
......@@ -135,7 +135,7 @@ export default {
],
SearchTypeOptions:[
{'key': 'id', 'display_name': '小组ID'},
{'key': 'title', 'display_name': '小组名称'},
{'key': 'name', 'display_name': '小组名称'},
{'key': 'star_name', 'display_name': '明星名称'},
]
}
......@@ -179,12 +179,11 @@ export default {
}
OffLineOrOnLine({type:val, ids:str}).then(response => {
this.multipleSelection = [];
response.data.data.message
this.$message.success(response.data.data.message);
})
},
handleFilter() {
this.listQuery.page = 1
this.listQuery.page = 0
this.getList()
},
handleCreate() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment