切换导航条
此项目
正在载入...
登录
郭盛
/
enterprise
·
提交
转到一个项目
GitLab
转到仪表盘
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
何书鹏
4 years ago
提交
926e78d6f547e64d51d9944323770f71fc43938e
1 个父辈
93f15a90
1 个管道 的构建
通过
耗费 0 秒
bug修改
变更
2
构建
1
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
69 行增加
和
28 行删除
application/mobile/controller/Topic.php
application/mobile/controller/User.php
application/mobile/controller/Topic.php
查看文件 @
926e78d
...
...
@@ -71,13 +71,20 @@ class Topic extends Api
*/
public
function
topicAdd
()
{
$post
=
$this
->
request
->
param
();
empty
(
$post
[
'topic_category_id'
])
&&
$this
->
error
(
'请选择话题分类'
);
empty
(
$post
[
'title'
])
&&
$this
->
error
(
'请输入标题'
);
empty
(
$post
[
'content'
])
&&
$this
->
error
(
'请填写话题内容'
);
$this
->
model
->
allowField
(
true
)
->
save
(
array_merge
([
'user_id'
=>
$this
->
auth
->
id
],
$post
));
$topic_category_id
=
$this
->
request
->
param
(
'topic_category_id'
);
$title
=
$this
->
request
->
param
(
'title'
);
$cover
=
$this
->
request
->
param
(
'cover'
);
$content
=
$this
->
request
->
param
(
'content'
,
''
,
'htmlspecialchars_decode'
);
empty
(
$topic_category_id
)
&&
$this
->
error
(
'请选择话题分类'
);
empty
(
$title
)
&&
$this
->
error
(
'请输入标题'
);
empty
(
$content
)
&&
$this
->
error
(
'请填写话题内容'
);
$this
->
model
->
allowField
(
true
)
->
save
([
'user_id'
=>
$this
->
auth
->
id
,
'topic_category_id'
=>
$topic_category_id
,
'title'
=>
$title
,
'cover'
=>
$cover
,
'content'
=>
$content
]);
$this
->
success
(
'发帖成功'
);
}
...
...
@@ -93,13 +100,14 @@ class Topic extends Api
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "160
1349634
",
"time": "160
2300901
",
"data": {
"total": 1, //数据总数
"list": [{
"id": 1, //话题ID
"title": "公司即将上市", //话题标题
"content": "这就是街舞", //话题内容
"cover": "http://qizhibang.brotop.cn/uploads/20201009/9bc002db9517fe79f93478550a979768.jpg", //封面图
"content": "他咯土佐玉木桶浴", //话题内容
"agree_num": 0, //赞同量
"download_num": 0, //下载量
"createtime": "2020.09.29 09:11", //发布时间
...
...
@@ -107,7 +115,10 @@ class Topic extends Api
"id": 15, //用户ID
"nickname": "", //昵称
"image": "" //头像
}
},
"imgs": [ //发布内容图片
"http://qizhibang.brotop.cn/uploads/20201010/dd2b86d8186f0e89735798d6f9a8f56c.jpg"
]
}]
}
})
...
...
@@ -141,13 +152,19 @@ class Topic extends Api
->
order
(
$order
)
->
paginate
(
$page_num
,
false
,[
'page'
=>
$page
])
->
each
(
function
(
$v
){
$v
->
visible
([
'id'
,
'title'
,
'cover'
,
'content'
,
'createtime'
,
'agree_num'
,
'download_num'
,
'user'
]);
// 发布时间格式化
$v
->
createtime
=
date
(
'Y.m.d H:i'
,
$v
->
createtime
);
// 过滤标签
$content1
=
htmlspecialchars_decode
(
$v
->
content
);
$content2
=
str_replace
([
' '
,
' '
],[
''
,
''
],
$content1
);
$v
->
content
=
strip_tags
(
$content2
);
// 拼装图片
$imgs
=
strip_tags
(
$content2
,
'<img>'
);
//$matches[1] 为图片路径数组
preg_match_all
(
'/\<img\s+src\=\"([\w:\/\.]+)\"/'
,
$imgs
,
$matches
);
$v
->
imgs
=
$matches
[
1
];
// 显示数据
$v
->
visible
([
'id'
,
'title'
,
'cover'
,
'content'
,
'createtime'
,
'agree_num'
,
'download_num'
,
'user'
])
->
append
([
'imgs'
]);
$v
->
getRelation
(
'user'
)
->
visible
([
'id'
,
'image'
,
'nickname'
]);
})
->
toArray
();
$this
->
success
(
'成功'
,[
'total'
=>
$data
[
'total'
],
'list'
=>
$data
[
'data'
]]);
...
...
@@ -210,13 +227,14 @@ class Topic extends Api
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "160
1349634
",
"time": "160
2300901
",
"data": {
"total": 1, //数据总数
"list": [{
"id": 1, //话题ID
"title": "公司即将上市", //话题标题
"content": "这就是街舞", //话题内容
"cover": "http://qizhibang.brotop.cn/uploads/20201009/9bc002db9517fe79f93478550a979768.jpg", //封面图
"content": "他咯土佐玉木桶浴", //话题内容
"agree_num": 0, //赞同量
"download_num": 0, //下载量
"createtime": "2020.09.29 09:11", //发布时间
...
...
@@ -224,7 +242,10 @@ class Topic extends Api
"id": 15, //用户ID
"nickname": "", //昵称
"image": "" //头像
}
},
"imgs": [ //发布内容图片
"http://qizhibang.brotop.cn/uploads/20201010/dd2b86d8186f0e89735798d6f9a8f56c.jpg"
]
}]
}
})
...
...
@@ -260,13 +281,19 @@ class Topic extends Api
->
order
([
'hot_num'
=>
'desc'
])
->
paginate
(
$page_num
,
false
,[
'page'
=>
$page
])
->
each
(
function
(
$v
){
$v
->
visible
([
'id'
,
'title'
,
'cover'
,
'content'
,
'createtime'
,
'agree_num'
,
'download_num'
,
'user'
]);
// 发布时间格式化
$v
->
createtime
=
date
(
'Y.m.d H:i'
,
$v
->
createtime
);
// 过滤标签
$content1
=
htmlspecialchars_decode
(
$v
->
content
);
$content2
=
str_replace
([
' '
,
' '
],[
''
,
''
],
$content1
);
$v
->
content
=
strip_tags
(
$content2
);
// 拼装图片
$imgs
=
strip_tags
(
$content2
,
'<img>'
);
//$matches[1] 为图片路径数组
preg_match_all
(
'/\<img\s+src\=\"([\w:\/\.]+)\"/'
,
$imgs
,
$matches
);
$v
->
imgs
=
$matches
[
1
];
// 显示数据
$v
->
visible
([
'id'
,
'title'
,
'cover'
,
'content'
,
'createtime'
,
'agree_num'
,
'download_num'
,
'user'
])
->
append
([
'imgs'
]);
$v
->
getRelation
(
'user'
)
->
visible
([
'id'
,
'image'
,
'nickname'
]);
})
->
toArray
();
$this
->
success
(
'成功'
,[
'total'
=>
$data
[
'total'
],
'list'
=>
$data
[
'data'
]]);
...
...
application/mobile/controller/User.php
查看文件 @
926e78d
...
...
@@ -60,7 +60,7 @@ class User extends Api
$ret
=
Sms
::
check
(
$mobile
,
$code
,
'register'
);
!
$ret
&&
$this
->
error
(
'验证码不正确'
);
$ret
=
$this
->
auth
->
register
(
$username
=
''
,
$password
,
$email
=
''
,
$mobile
,
[]);
$ret
=
$this
->
auth
->
register
(
$username
=
get_order_sn
()
,
$password
,
$email
=
''
,
$mobile
,
[]);
if
(
$ret
)
{
$this
->
auth
->
setAllowFields
([
'id'
,
'mobile'
,
'group_id'
]);
$data
=
[
'userinfo'
=>
$this
->
auth
->
getUserinfo
()];
...
...
@@ -124,7 +124,7 @@ class User extends Api
Db
::
startTrans
();
try
{
$ret
=
$this
->
auth
->
register
(
$username
=
''
,
$password
,
$email
=
''
,
$mobile
,
[]);
$ret
=
$this
->
auth
->
register
(
$username
=
get_order_sn
()
,
$password
,
$email
=
''
,
$mobile
,
[]);
if
(
!
$ret
)
{
$this
->
error
(
$this
->
auth
->
getError
());
}
...
...
@@ -1153,22 +1153,25 @@ class User extends Api
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1602
292309
",
"time": "1602
300901
",
"data": {
"total": 1, //数据总
条
数
"total": 1, //数据总数
"list": [{
"id": 1, //帖子ID
"title": "公司即将上市", //标题
"id": 1, //话题ID
"title": "公司即将上市", //话题标题
"cover": "http://qizhibang.brotop.cn/uploads/20201009/9bc002db9517fe79f93478550a979768.jpg", //封面图
"content": "
这就是街舞", //
内容
"content": "
他咯土佐玉木桶浴", //话题
内容
"agree_num": 0, //赞同量
"download_num": 0, //下载量
"createtime": "2020.09.29 09:11", //发帖时间
"user": { //用户信息
"createtime": "2020.09.29 09:11", //发布时间
"user": { //发布者信息
"id": 15, //用户ID
"nickname": "", //
真实姓名
"nickname": "", //
昵称
"image": "" //头像
}
},
"imgs": [ //发布内容图片
"http://qizhibang.brotop.cn/uploads/20201010/dd2b86d8186f0e89735798d6f9a8f56c.jpg"
]
}]
}
})
...
...
@@ -1183,8 +1186,19 @@ class User extends Api
->
order
(
'createtime desc'
)
->
paginate
(
$page_num
,
false
,[
'page'
=>
$page
])
->
each
(
function
(
$v
){
$v
->
visible
([
'id'
,
'title'
,
'cover'
,
'content'
,
'createtime'
,
'agree_num'
,
'download_num'
,
'user'
]);
$v
->
createtime
=
date
(
'Y.m.d H:i'
,
$v
[
'createtime'
]);
// 发布时间格式化
$v
->
createtime
=
date
(
'Y.m.d H:i'
,
$v
->
createtime
);
// 过滤标签
$content1
=
htmlspecialchars_decode
(
$v
->
content
);
$content2
=
str_replace
([
' '
,
' '
],[
''
,
''
],
$content1
);
$v
->
content
=
strip_tags
(
$content2
);
// 拼装图片
$imgs
=
strip_tags
(
$content2
,
'<img>'
);
//$matches[1] 为图片路径数组
preg_match_all
(
'/\<img\s+src\=\"([\w:\/\.]+)\"/'
,
$imgs
,
$matches
);
$v
->
imgs
=
$matches
[
1
];
// 显示数据
$v
->
visible
([
'id'
,
'title'
,
'cover'
,
'content'
,
'createtime'
,
'agree_num'
,
'download_num'
,
'user'
])
->
append
([
'imgs'
]);
$v
->
getRelation
(
'user'
)
->
visible
([
'id'
,
'image'
,
'nickname'
]);
})
->
toArray
();
$this
->
success
(
'成功'
,
[
'total'
=>
$data
[
'total'
],
'list'
=>
$data
[
'data'
]]);
...
...
请
注册
或
登录
后发表评论