Commit 932a0316 authored by Davve's avatar Davve

完成帖子创建编辑后端逻辑

parent ba219b88
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# __author__ = "chenwei" # __author__ = "chenwei"
# Date: 2018/11/16 # Date: 2018/11/16
from django.conf import settings
from utils.base import APIView from utils.base import APIView
...@@ -95,7 +96,7 @@ class LoginView(APIView): ...@@ -95,7 +96,7 @@ class LoginView(APIView):
username = request.POST.get('username') username = request.POST.get('username')
password = request.POST.get('password') password = request.POST.get('password')
if username == 'admin' and password == '123123': if username == settings.USERNAME and password == settings.PASSWORD:
data = { data = {
'id': 1, 'id': 1,
'roles': ['admin'], 'roles': ['admin'],
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import datetime import datetime
from utils.base import APIView from utils.base import APIView
from utils.time_utils import utc_to_datetime, datetime_toString, unix_time_to_datetime, analysis_time from utils.time_utils import utc_to_datetime, unix_time_to_datetime, analysis_time
class PushListView(APIView): class PushListView(APIView):
...@@ -31,10 +31,8 @@ class PushUpdateOrCreateView(APIView): ...@@ -31,10 +31,8 @@ class PushUpdateOrCreateView(APIView):
def post(self, request): def post(self, request):
id = request.POST.get('id', '') id = request.POST.get('id', '')
try: push_time = analysis_time(request.POST.get('push_time', 0))
push_time = unix_time_to_datetime(int(request.POST.get('push_time', 0)) / 1000)
except ValueError:
push_time = utc_to_datetime(request.POST.get('push_time', '')[:-5] + 'Z')
data = { data = {
'url': request.POST.get('url', ''), 'url': request.POST.get('url', ''),
'push_time': push_time, 'push_time': push_time,
......
...@@ -3,32 +3,126 @@ ...@@ -3,32 +3,126 @@
# __author__ = "chenwei" # __author__ = "chenwei"
# Date: 2018/11/15 # Date: 2018/11/15
import json
from utils.base import APIView from utils.base import APIView
from utils.time_utils import analysis_time
class TopicListView(APIView): class TopicListView(APIView):
def get(self, request): def get(self, request):
page = int(request.GET.get('page', 1)) page = int(request.GET.get('page', 0))
limit = int(request.GET.get('limit', 10)) limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', "")) filter = self.handle_filter(request.GET.get('filter', ""))
try: try:
data = self.rpc['venus/community/topic/get'](offset=page, limit=limit, filters=filter).unwrap() data = self.rpc['venus/sun/topic/list'](offset=page, limit=limit, filters=filter).unwrap()
except Exception as e: except Exception as e:
# raise e raise e
return data
class TopicUpdateOrCreateView(APIView):
def get(self, request):
id = request.GET.get('id')
try: # TODO 少返回了is_online
data = self.rpc['venus/sun/topic/get'](id=id).unwrap()
except Exception as e:
raise e
return {'data': data}
def post(self, request):
id = request.POST.get('id', '')
posting_time = analysis_time(request.POST.get('posting_time', 0))
topic_images = list(map(lambda x: x[:-2], json.loads(request.POST.get('topic_images', []))))
data = { data = {
'total': 200, 'topic_images': topic_images,
'data':[ 'topic_ids': json.loads(request.POST.get('topic_ids', '')),
{"id": "1", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59', 'video_url': request.POST.get('video_url', ''),
'reported_time': '2019-09-18 23:59:59', 'is_online': 1, 'is_reported': 0}, 'posting_time': posting_time,
{"id": "2", "content": '内容', 'newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59', 'content': request.POST.get('content', ''),
'reported_time': '2019-09-18 23:59:59', 'user_name': 'alex','is_online': 0, 'is_reported': 0}, 'content_level': request.POST.get('content_level', ''),
{"id": "3", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59', 'group_name': request.POST.get('group_name', ''),
'reported_time': '2019-09-18 23:59:59', 'is_online': 1, 'is_reported': 1}, 'user_id': request.POST.get('user_id', ''),
{"id": "4", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59', 'star_name': request.POST.get('star_name', ''),
'reported_time': '2019-09-18 23:59:59', 'is_online': 1, 'is_reported': 1}, 'tag_ids': json.loads(request.POST.get('tag_ids', [])),
{"id": "5", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59', }
'reported_time': '2019-09-18 23:59:59', 'is_online': 0, 'is_reported': 0}, try:
self.rpc['venus/sun/topic/edit'](id=id, data=data).unwrap()
except Exception as e:
raise e
return {
'message': '更新成功'
}
class ReplyUpdateOrCreateView(APIView):
def get(self, request):
id = request.GET.get('id')
page = int(request.GET.get('page', 0))
limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', ""))
filter.update({'id': id})
try:
data = self.rpc['venus/sun/topic/reply/list'](offset=page, limit=limit, filters=filter).unwrap()
except Exception as e:
data = [
{
'id': 1,
'reply_name': '真好',
'be_reply_name': '王二',
'create_time': '2018-09-10 23:23:23',
'reply_type': '贴主的评论',
'content': '内容真好',
},
] ]
return {
'total': 10,
'data': data
} }
return data
def post(self, request):
reply_ids = json.loads(request.POST.get('reply_ids', []))
try:
self.rpc['venus/sun/topic/reply/batch_delete'](data=reply_ids).unwrap()
except Exception as e:
raise e
return {
'message': '操作成功'
}
class ReplyCreate(APIView):
def post(self, request):
data = {
'topic_id': request.POST.get('topic_id'),
'reply_name': request.POST.get('reply_name'),
'be_reply_name': request.POST.get('be_reply_name'),
'content': request.POST.get('content'),
}
try:
data = self.rpc['venus/sun/topic/reply/create'](data=data).unwrap()
"""
data = {
'id': 1,
'reply_type': 1,
'create_time': '2108-09-92 12:12:12',
'reply_name': 'xxxxx',
'be_reply_name': 'xxxxxx',
'content': '测试测试',
}
"""
except Exception as e:
# raise e
data = {
'id': 6,
'reply_type': "贴住的评论",
'create_time': '2108-09-92 12:12:12',
'reply_name': 'xxxxx',
'be_reply_name': 'xxxxxx',
'content': '测试测试',
}
return {'data': data}
...@@ -38,6 +38,11 @@ urlpatterns = [ ...@@ -38,6 +38,11 @@ urlpatterns = [
# topic相关 # topic相关
url(r'topic/list$', TopicListView.as_view()), url(r'topic/list$', TopicListView.as_view()),
url(r'topic/detail', TopicUpdateOrCreateView.as_view()),
url(r'topic/creacte', TopicUpdateOrCreateView.as_view()),
url(r'topic/reply/list', ReplyUpdateOrCreateView.as_view()),
url(r'topic/reply/batch_delete', ReplyUpdateOrCreateView.as_view()),
url(r'topic/reply/create', ReplyCreate.as_view()),
# star相关 # star相关
url(r'star/list$', StarListView.as_view()), url(r'star/list$', StarListView.as_view()),
......
...@@ -138,3 +138,7 @@ QINIU_ACCESS_KEY = "UPCOYIJkZOMcdd9FDzpBqYjzWUh55fBpVi3AhWpL" ...@@ -138,3 +138,7 @@ QINIU_ACCESS_KEY = "UPCOYIJkZOMcdd9FDzpBqYjzWUh55fBpVi3AhWpL"
QINIU_SECRET_KEY = "z5YvpDDSam_JE345Z8J_f3TufzelOW2VOGNoBl9e" QINIU_SECRET_KEY = "z5YvpDDSam_JE345Z8J_f3TufzelOW2VOGNoBl9e"
QINIU_HOST = "http://wanmeizhensuo.qiniudn.com/" QINIU_HOST = "http://wanmeizhensuo.qiniudn.com/"
QINIU_SCOPE = 'wanmeizhensuo' QINIU_SCOPE = 'wanmeizhensuo'
# 超级管理员
USERNAME = 'admin'
PASSWORD = 'admin'
\ No newline at end of file
...@@ -2,7 +2,7 @@ import request from '@/utils/request' ...@@ -2,7 +2,7 @@ import request from '@/utils/request'
export function userSearch(name) { export function userSearch(name) {
return request({ return request({
url: '/search/user', url: '/api/search/user',
method: 'get', method: 'get',
params: { name } params: { name }
}) })
......
...@@ -19,13 +19,12 @@ export function OffLineOrOnLine(data) { ...@@ -19,13 +19,12 @@ export function OffLineOrOnLine(data) {
export function createRemark(data) { export function createRemark(data) {
return request({ return request({
url: '/api/topic/create_remark', url: '/api/topic/reply/create',
method: 'post', method: 'post',
data data
}) })
} }
export function fetchTopic(id) { export function fetchTopic(id) {
return request({ return request({
url: '/api/topic/detail', url: '/api/topic/detail',
...@@ -33,3 +32,27 @@ export function fetchTopic(id) { ...@@ -33,3 +32,27 @@ export function fetchTopic(id) {
params: { id } params: { id }
}) })
} }
export function createTopic(data) {
return request({
url: '/api/topic/create',
method: 'post',
data
})
}
export function fetchReply(query) {
return request({
url: '/api/topic/reply/list',
method: 'get',
params: query
})
}
export function DelReply(data) {
return request({
url: '/api/topic/reply/batch_delete',
method: 'post',
data
})
}
...@@ -24,7 +24,7 @@ export default { ...@@ -24,7 +24,7 @@ export default {
}, },
page: { page: {
type: Number, type: Number,
default: 1 default: 0
}, },
limit: { limit: {
type: Number, type: Number,
......
...@@ -31,9 +31,6 @@ Mock.mock(/\/article\/create/, 'post', articleAPI.createArticle) ...@@ -31,9 +31,6 @@ Mock.mock(/\/article\/create/, 'post', articleAPI.createArticle)
Mock.mock(/\/article\/update/, 'post', articleAPI.updateArticle) Mock.mock(/\/article\/update/, 'post', articleAPI.updateArticle)
// 搜索相关 // 搜索相关
Mock.mock(/\/search\/user/, 'get', remoteSearchAPI.searchUser)
// 账单相关
Mock.mock(/\/transaction\/list/, 'get', transactionAPI.getList) Mock.mock(/\/transaction\/list/, 'get', transactionAPI.getList)
export default Mock export default Mock
...@@ -55,7 +55,7 @@ export default { ...@@ -55,7 +55,7 @@ export default {
} }
} }
const validatePassword = (rule, value, callback) => { const validatePassword = (rule, value, callback) => {
if (value.length < 6) { if (value.length < 5) {
callback(new Error('The password can not be less than 6 digits')) callback(new Error('The password can not be less than 6 digits'))
} else { } else {
callback() callback()
...@@ -64,7 +64,7 @@ export default { ...@@ -64,7 +64,7 @@ export default {
return { return {
loginForm: { loginForm: {
username: 'admin', username: 'admin',
password: '123123' password: 'admin'
}, },
loginRules: { loginRules: {
username: [{ required: true, trigger: 'blur', validator: validateUsername }], username: [{ required: true, trigger: 'blur', validator: validateUsername }],
......
...@@ -241,6 +241,7 @@ ...@@ -241,6 +241,7 @@
this.postForm.region = Assembledata(this.temparray['region'], this.postForm.region); this.postForm.region = Assembledata(this.temparray['region'], this.postForm.region);
this.postForm.pick_group = Assembledata(this.temparray['pick_group'], this.postForm.pick_group); this.postForm.pick_group = Assembledata(this.temparray['pick_group'], this.postForm.pick_group);
}else{ }else{
this.postForm.region = this.postForm.region.join(',')
this.postForm.region = this.postForm.region.join(',') this.postForm.region = this.postForm.region.join(',')
this.postForm.pick_group = this.postForm.pick_group.join(',') this.postForm.pick_group = this.postForm.pick_group.join(',')
} }
......
...@@ -11,6 +11,14 @@ ...@@ -11,6 +11,14 @@
<el-select v-model="listQuery.filter.is_reported" :placeholder="'举报'" clearable class="filter-item" style="width: 100px"> <el-select v-model="listQuery.filter.is_reported" :placeholder="'举报'" clearable class="filter-item" style="width: 100px">
<el-option v-for="item in ReBooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/> <el-option v-for="item in ReBooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select> </el-select>
<el-select v-model="listQuery.filter.is_puppet" :placeholder="'马甲'" clearable class="filter-item" style="width: 100px">
<el-option v-for="item in ReBooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-select v-model="listQuery.filter.content_level" :placeholder="'帖子星级'" clearable class="filter-item" style="width: 100px">
<el-option v-for="item in ContentLevelTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button> <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleCreate">创建</el-button> <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleCreate">创建</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('offline')">下线</el-button> <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('offline')">下线</el-button>
...@@ -18,58 +26,64 @@ ...@@ -18,58 +26,64 @@
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('is_reported')">推荐</el-button> <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('is_reported')">推荐</el-button>
</div> </div>
<el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange"> <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"></el-table-column> <el-table-column type="selection" align="center"></el-table-column>
<el-table-column align="center" label="帖子ID " width="70"> <el-table-column align="center" label="帖子ID " >
<template slot-scope="scope"> <template slot-scope="scope">
<router-link :to="'/pick/edit/'+scope.row.id" class="link-type"> <router-link :to="'/topic/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.id }}</span> <span>{{ scope.row.id }}</span>
</router-link> </router-link>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="70px" align="center" label="用户"> <el-table-column align="center" label="用户">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.user_name }}</span> <span>{{ scope.row.user.name }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="204px" align="center" label="帖子详情"> <el-table-column align="center" label="帖子详情">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.content }}</span> <span>{{ scope.row.content }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="130px" align="center" label="最新回复"> <el-table-column align="center" label="最新回复">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.newly_reply }}</span> <span>{{ scope.row.newly_reply }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="80px" align="center" label="小组"> <el-table-column align="center" label="小组">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.group_name }}</span> <span>{{ scope.row.group.name }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="155px" align="center" label="更新时间"> <el-table-column align="center" label="更新时间">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.update_time }}</span> <span>{{ scope.row.update_time }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="155px" align="center" label="举报时间"> <el-table-column align="center" label="举报时间">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.reported_time? scope.row.reported_time: '无' }}</span> <span>{{ scope.row.reported_time? scope.row.reported_time: '无' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="70px" align="center" label="下线"> <el-table-column align="center" label="帖子星级">
<template slot-scope="scope">
<span>{{ scope.row.content_level }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="下线">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag :type="scope.row.is_online | isOnlineFilter">{{ scope.row.is_online==1 ? '是' : '否' }}</el-tag> <el-tag :type="scope.row.is_online | isOnlineFilter">{{ scope.row.is_online==1 ? '是' : '否' }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="70px" align="center" label="推荐"> <el-table-column align="center" label="推荐">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag :type="scope.row.is_reported | isOnlineFilter">{{ scope.row.is_reported==1 ? '是' : '否' }}</el-tag> <el-tag :type="scope.row.is_reported | isOnlineFilter">{{ scope.row.is_reported==1 ? '是' : '否' }}</el-tag>
</template> </template>
...@@ -77,7 +91,7 @@ ...@@ -77,7 +91,7 @@
</el-table> </el-table>
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" style="margin-left: 150px;" @pagination="getList" /> <pagination v-show="total>0" :total="total" :page="listQuery.page" :limit="listQuery.limit" style="margin-left: 150px;" @pagination="getList" />
</div> </div>
</template> </template>
...@@ -116,13 +130,15 @@ export default { ...@@ -116,13 +130,15 @@ export default {
multipleSelection: [], multipleSelection: [],
del_list: [], del_list: [],
listQuery: { listQuery: {
page: 1, page: 0,
limit: 10, limit: 10,
filter: { filter: {
value: '', value: '',
key: '', key: '',
is_online: '', is_online: '',
is_reported: '', complaints__isnull: '',
user__is_puppet: '',
content_level: ''
}, },
}, },
BooleanTypeOptions: [ BooleanTypeOptions: [
...@@ -135,9 +151,15 @@ export default { ...@@ -135,9 +151,15 @@ export default {
], ],
SearchTypeOptions:[ SearchTypeOptions:[
{'key': 'id', 'display_name': '帖子ID'}, {'key': 'id', 'display_name': '帖子ID'},
{'key': 'group__name', 'display_name': '小组名称'}, {'key': 'content', 'display_name': '帖子内容'},
{'key': 'content', 'display_name': '明星名称'}, ],
] ContentLevelTypeOptions:[
{'key': 1, 'display_name': '星级一'},
{'key': 2, 'display_name': '星级二'},
{'key': 3, 'display_name': '星级三'},
{'key': 4, 'display_name': '星级四'},
{'key': 5, 'display_name': '星级五'},
],
} }
}, },
created() { created() {
...@@ -147,6 +169,7 @@ export default { ...@@ -147,6 +169,7 @@ export default {
getList() { getList() {
this.listLoading = true this.listLoading = true
fetchList(this.listQuery).then(response => { fetchList(this.listQuery).then(response => {
console.log(response.data.data)
this.list = response.data.data.data this.list = response.data.data.data
this.total = response.data.data.total this.total = response.data.data.total
this.listLoading = false this.listLoading = false
...@@ -184,7 +207,7 @@ export default { ...@@ -184,7 +207,7 @@ export default {
}) })
}, },
handleFilter() { handleFilter() {
this.listQuery.page = 1 this.listQuery.page = 0
this.getList() this.getList()
}, },
handleCreate() { 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