Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
C
chinafrica
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
zhengfg
chinafrica
Commits
fab8a6ae
提交
fab8a6ae
authored
6月 29, 2020
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
帖子管理代码提交
上级
2ad38adf
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
82 行增加
和
27 行删除
+82
-27
PostController.java
...src/main/java/com/platform/controller/PostController.java
+5
-4
PostDao.java
platform-admin/src/main/java/com/platform/dao/PostDao.java
+1
-0
PostService.java
...admin/src/main/java/com/platform/service/PostService.java
+5
-4
PostServiceImpl.java
.../main/java/com/platform/service/impl/PostServiceImpl.java
+39
-16
PostDao.xml
...orm-admin/src/main/resources/com/platform/dao/PostDao.xml
+8
-1
post.js
platform-admin/src/main/webapp/js/sys/post.js
+24
-2
没有找到文件。
platform-admin/src/main/java/com/platform/controller/PostController.java
浏览文件 @
fab8a6ae
...
@@ -5,6 +5,7 @@ import com.platform.service.PostService;
...
@@ -5,6 +5,7 @@ import com.platform.service.PostService;
import
com.platform.utils.PageUtils
;
import
com.platform.utils.PageUtils
;
import
com.platform.utils.Query
;
import
com.platform.utils.Query
;
import
com.platform.utils.R
;
import
com.platform.utils.R
;
import
com.platform.vo.PostVo
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.apache.shiro.authz.annotation.RequiresPermissions
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
...
@@ -39,7 +40,7 @@ public class PostController {
...
@@ -39,7 +40,7 @@ public class PostController {
//查询列表数据
//查询列表数据
Query
query
=
new
Query
(
params
);
Query
query
=
new
Query
(
params
);
List
<
Post
Entity
>
postList
=
postService
.
queryList
(
query
);
List
<
Post
Vo
>
postList
=
postService
.
queryList
(
query
);
int
total
=
postService
.
queryTotal
(
query
);
int
total
=
postService
.
queryTotal
(
query
);
PageUtils
pageUtil
=
new
PageUtils
(
postList
,
total
,
query
.
getLimit
(),
query
.
getPage
());
PageUtils
pageUtil
=
new
PageUtils
(
postList
,
total
,
query
.
getLimit
(),
query
.
getPage
());
...
@@ -53,7 +54,7 @@ public class PostController {
...
@@ -53,7 +54,7 @@ public class PostController {
@RequestMapping
(
"/info/{id}"
)
@RequestMapping
(
"/info/{id}"
)
@RequiresPermissions
(
"post:info"
)
@RequiresPermissions
(
"post:info"
)
@ResponseBody
@ResponseBody
public
R
info
(
@PathVariable
(
"id"
)
Lo
ng
id
)
{
public
R
info
(
@PathVariable
(
"id"
)
Stri
ng
id
)
{
PostEntity
post
=
postService
.
queryObject
(
id
);
PostEntity
post
=
postService
.
queryObject
(
id
);
return
R
.
ok
().
put
(
"post"
,
post
);
return
R
.
ok
().
put
(
"post"
,
post
);
...
@@ -89,7 +90,7 @@ public class PostController {
...
@@ -89,7 +90,7 @@ public class PostController {
@RequestMapping
(
"/delete"
)
@RequestMapping
(
"/delete"
)
@RequiresPermissions
(
"post:delete"
)
@RequiresPermissions
(
"post:delete"
)
@ResponseBody
@ResponseBody
public
R
delete
(
@RequestBody
Lo
ng
[]
ids
)
{
public
R
delete
(
@RequestBody
Stri
ng
[]
ids
)
{
postService
.
deleteBatch
(
ids
);
postService
.
deleteBatch
(
ids
);
return
R
.
ok
();
return
R
.
ok
();
...
@@ -102,7 +103,7 @@ public class PostController {
...
@@ -102,7 +103,7 @@ public class PostController {
@ResponseBody
@ResponseBody
public
R
queryAll
(
@RequestParam
Map
<
String
,
Object
>
params
)
{
public
R
queryAll
(
@RequestParam
Map
<
String
,
Object
>
params
)
{
List
<
Post
Entity
>
list
=
postService
.
queryList
(
params
);
List
<
Post
Vo
>
list
=
postService
.
queryList
(
params
);
return
R
.
ok
().
put
(
"list"
,
list
);
return
R
.
ok
().
put
(
"list"
,
list
);
}
}
...
...
platform-admin/src/main/java/com/platform/dao/PostDao.java
浏览文件 @
fab8a6ae
...
@@ -10,4 +10,5 @@ import com.platform.entity.PostEntity;
...
@@ -10,4 +10,5 @@ import com.platform.entity.PostEntity;
*/
*/
public
interface
PostDao
extends
BaseDao
<
PostEntity
>
{
public
interface
PostDao
extends
BaseDao
<
PostEntity
>
{
int
changePostStatus
(
String
ids
[]);
}
}
platform-admin/src/main/java/com/platform/service/PostService.java
浏览文件 @
fab8a6ae
package
com
.
platform
.
service
;
package
com
.
platform
.
service
;
import
com.platform.entity.PostEntity
;
import
com.platform.entity.PostEntity
;
import
com.platform.vo.PostVo
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -19,7 +20,7 @@ public interface PostService {
...
@@ -19,7 +20,7 @@ public interface PostService {
* @param id 主键
* @param id 主键
* @return 实体
* @return 实体
*/
*/
PostEntity
queryObject
(
Lo
ng
id
);
PostEntity
queryObject
(
Stri
ng
id
);
/**
/**
* 分页查询
* 分页查询
...
@@ -27,7 +28,7 @@ public interface PostService {
...
@@ -27,7 +28,7 @@ public interface PostService {
* @param map 参数
* @param map 参数
* @return list
* @return list
*/
*/
List
<
Post
Entity
>
queryList
(
Map
<
String
,
Object
>
map
);
List
<
Post
Vo
>
queryList
(
Map
<
String
,
Object
>
map
);
/**
/**
* 分页统计总数
* 分页统计总数
...
@@ -59,7 +60,7 @@ public interface PostService {
...
@@ -59,7 +60,7 @@ public interface PostService {
* @param id
* @param id
* @return 删除条数
* @return 删除条数
*/
*/
int
delete
(
Lo
ng
id
);
int
delete
(
Stri
ng
id
);
/**
/**
* 根据主键批量删除
* 根据主键批量删除
...
@@ -67,5 +68,5 @@ public interface PostService {
...
@@ -67,5 +68,5 @@ public interface PostService {
* @param ids
* @param ids
* @return 删除条数
* @return 删除条数
*/
*/
int
deleteBatch
(
Lo
ng
[]
ids
);
int
deleteBatch
(
Stri
ng
[]
ids
);
}
}
platform-admin/src/main/java/com/platform/service/impl/PostServiceImpl.java
浏览文件 @
fab8a6ae
...
@@ -9,6 +9,8 @@ import com.platform.entity.TbCfUserInfoEntity;
...
@@ -9,6 +9,8 @@ import com.platform.entity.TbCfUserInfoEntity;
import
com.platform.service.PostService
;
import
com.platform.service.PostService
;
import
com.platform.utils.IdUtil
;
import
com.platform.utils.IdUtil
;
import
com.platform.utils.ShiroUtils
;
import
com.platform.utils.ShiroUtils
;
import
com.platform.vo.PostVo
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
...
@@ -27,6 +29,7 @@ import static com.platform.utils.ShiroUtils.getUserId;
...
@@ -27,6 +29,7 @@ import static com.platform.utils.ShiroUtils.getUserId;
* @author lipengjun
* @author lipengjun
* @date 2020-06-17 11:02:21
* @date 2020-06-17 11:02:21
*/
*/
@Slf4j
@Service
(
"postService"
)
@Service
(
"postService"
)
public
class
PostServiceImpl
implements
PostService
{
public
class
PostServiceImpl
implements
PostService
{
@Autowired
@Autowired
...
@@ -39,25 +42,27 @@ public class PostServiceImpl implements PostService {
...
@@ -39,25 +42,27 @@ public class PostServiceImpl implements PostService {
private
SysUserDao
sysUserDao
;
private
SysUserDao
sysUserDao
;
@Override
@Override
public
PostEntity
queryObject
(
Lo
ng
id
)
{
public
PostEntity
queryObject
(
Stri
ng
id
)
{
return
postDao
.
queryObject
(
id
);
return
postDao
.
queryObject
(
id
);
}
}
@Override
@Override
public
List
<
Post
Entity
>
queryList
(
Map
<
String
,
Object
>
map
)
{
public
List
<
Post
Vo
>
queryList
(
Map
<
String
,
Object
>
map
)
{
List
<
Post
Entity
>
list
=
new
ArrayList
<>();
List
<
Post
Vo
>
list
=
new
ArrayList
<>();
List
<
PostEntity
>
postList
=
postDao
.
queryList
(
map
);
List
<
PostEntity
>
postList
=
postDao
.
queryList
(
map
);
postList
.
forEach
(
post
->
{
postList
.
forEach
(
post
->
{
String
userType
=
post
.
getUserType
().
toString
();
String
userType
=
post
.
getUserType
().
toString
();
Post
Entity
postEntity
=
new
PostEntity
();
Post
Vo
postEntity
=
new
PostVo
();
BeanUtils
.
copyProperties
(
post
,
postEntity
);
BeanUtils
.
copyProperties
(
post
,
postEntity
);
//系统用户
//系统用户
if
(
"0"
.
equals
(
userType
))
{
if
(
"0"
.
equals
(
userType
))
{
SysUserEntity
user
=
sysUserDao
.
queryObject
(
post
.
getUserId
());
SysUserEntity
user
=
sysUserDao
.
queryObject
(
post
.
getUserId
());
if
(
user
!=
null
)
postEntity
.
setCreatedBy
(
user
.
getUserName
());
postEntity
.
setCreatedBy
(
user
.
getUserName
());
//app用户
//app用户
}
else
if
(
"1"
.
equals
(
userType
))
{
}
else
if
(
"1"
.
equals
(
userType
))
{
TbCfUserInfoEntity
user
=
tbCfUserInfoDao
.
queryObject
(
post
.
getUserId
());
TbCfUserInfoEntity
user
=
tbCfUserInfoDao
.
queryObject
(
post
.
getUserId
());
if
(
user
!=
null
)
postEntity
.
setCreatedBy
(
user
.
getNick
());
postEntity
.
setCreatedBy
(
user
.
getNick
());
}
}
list
.
add
(
postEntity
);
list
.
add
(
postEntity
);
...
@@ -83,33 +88,51 @@ public class PostServiceImpl implements PostService {
...
@@ -83,33 +88,51 @@ public class PostServiceImpl implements PostService {
String
type
=
String
.
valueOf
(
post
.
getUserType
());
String
type
=
String
.
valueOf
(
post
.
getUserType
());
if
(
"0"
.
equals
(
type
))
{
if
(
"0"
.
equals
(
type
))
{
post
.
setUserId
(
getUserId
());
post
.
setUserId
(
getUserId
());
}
}
else
if
(
"1"
.
equals
(
type
))
{
if
(
"1"
.
equals
(
type
))
{
String
userId
=
tbCfUserInfoDao
.
queryById
(
post
.
getCreatedBy
());
String
userId
=
tbCfUserInfoDao
.
queryById
(
post
.
getCreatedBy
());
post
.
setUserId
(
userId
);
post
.
setUserId
(
userId
);
}
}
post
.
setCategory
(
URLDecoder
.
decode
(
post
.
getCategory
(),
"utf-8"
));
post
.
setCategory
(
URLDecoder
.
decode
(
post
.
getCategory
(),
"utf-8"
));
res
=
postDao
.
save
(
post
);
res
=
postDao
.
save
(
post
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
info
(
e
.
getMessage
());
}
}
return
res
;
return
res
;
}
}
@Override
@Override
public
int
update
(
PostEntity
post
)
{
public
int
update
(
PostEntity
post
)
{
int
res
=
0
;
try
{
String
type
=
String
.
valueOf
(
post
.
getUserType
());
if
(
"0"
.
equals
(
type
))
{
post
.
setUpdatedBy
(
ShiroUtils
.
getUserId
());
}
post
.
setVersion
(
post
.
getVersion
()
+
1
);
post
.
setUpdateDate
(
new
Date
());
post
.
setUpdateDate
(
new
Date
());
post
.
setUpdatedBy
(
ShiroUtils
.
getUserId
());
post
.
setUpdatedBy
(
ShiroUtils
.
getUserId
());
return
postDao
.
update
(
post
);
post
.
setCategory
(
URLDecoder
.
decode
(
post
.
getCategory
(),
"utf-8"
));
res
=
postDao
.
update
(
post
);
}
catch
(
Exception
e
)
{
log
.
info
(
e
.
getMessage
());
}
return
res
;
}
}
@Override
@Override
public
int
delete
(
Long
id
)
{
public
int
delete
(
String
id
)
{
return
postDao
.
delete
(
id
);
String
[]
ids
=
new
String
[]{
id
};
return
postDao
.
changePostStatus
(
ids
);
}
}
/**
* 逻辑删除
*
* @param ids
* @return
*/
@Override
@Override
public
int
deleteBatch
(
Lo
ng
[]
ids
)
{
public
int
deleteBatch
(
Stri
ng
[]
ids
)
{
return
postDao
.
deleteBatch
(
ids
);
return
postDao
.
changePostStatus
(
ids
);
}
}
}
}
platform-admin/src/main/resources/com/platform/dao/PostDao.xml
浏览文件 @
fab8a6ae
...
@@ -54,6 +54,7 @@
...
@@ -54,6 +54,7 @@
LEFT JOIN ( SELECT count( 1 ) count, post_id FROM `comment` GROUP BY post_id ) c ON p.id = c.post_id
LEFT JOIN ( SELECT count( 1 ) count, post_id FROM `comment` GROUP BY post_id ) c ON p.id = c.post_id
LEFT JOIN ( SELECT count( 1 ) likes, post_id FROM post_like GROUP BY post_id ) l ON p.id = l.post_id
LEFT JOIN ( SELECT count( 1 ) likes, post_id FROM post_like GROUP BY post_id ) l ON p.id = l.post_id
WHERE 1=1
WHERE 1=1
and p.archived!=0
<if
test=
"name != null and name.trim() != ''"
>
<if
test=
"name != null and name.trim() != ''"
>
AND name LIKE concat('%',#{name},'%')
AND name LIKE concat('%',#{name},'%')
</if>
</if>
...
@@ -71,7 +72,7 @@
...
@@ -71,7 +72,7 @@
order by ${sidx} ${order}
order by ${sidx} ${order}
</when>
</when>
<otherwise>
<otherwise>
order by create
_tim
e desc
order by create
Dat
e desc
</otherwise>
</otherwise>
</choose>
</choose>
<if
test=
"offset != null and limit != null"
>
<if
test=
"offset != null and limit != null"
>
...
@@ -163,4 +164,10 @@
...
@@ -163,4 +164,10 @@
</foreach>
</foreach>
</delete>
</delete>
<update
id=
"changePostStatus"
>
update post set archived=0 where id in
<foreach
item=
"id"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{id}
</foreach>
</update>
</mapper>
</mapper>
\ No newline at end of file
platform-admin/src/main/webapp/js/sys/post.js
浏览文件 @
fab8a6ae
...
@@ -72,7 +72,7 @@ let vm = new Vue({
...
@@ -72,7 +72,7 @@ let vm = new Vue({
queryAccount
:
function
()
{
queryAccount
:
function
()
{
let
flag
=
vm
.
flag
;
let
flag
=
vm
.
flag
;
let
url
=
'../tbcfuserinfo/queryByAccount?account='
+
this
.
post
.
createdBy
;
let
url
=
'../tbcfuserinfo/queryByAccount?account='
+
this
.
post
.
createdBy
;
console
.
log
(
123456
,
this
.
post
.
createBy
)
console
.
log
(
123456
,
this
.
post
.
createBy
)
Ajax
.
request
({
Ajax
.
request
({
url
:
url
,
url
:
url
,
type
:
"GET"
,
type
:
"GET"
,
...
@@ -139,6 +139,7 @@ let vm = new Vue({
...
@@ -139,6 +139,7 @@ let vm = new Vue({
vm
.
showList
=
false
;
vm
.
showList
=
false
;
vm
.
title
=
"新增"
;
vm
.
title
=
"新增"
;
vm
.
post
=
{};
vm
.
post
=
{};
UE
.
getEditor
(
'content'
).
setContent
(
''
);
},
},
update
:
function
(
event
)
{
update
:
function
(
event
)
{
let
id
=
getSelectedRow
(
"#jqGrid"
);
let
id
=
getSelectedRow
(
"#jqGrid"
);
...
@@ -152,7 +153,7 @@ let vm = new Vue({
...
@@ -152,7 +153,7 @@ let vm = new Vue({
},
},
saveOrUpdate
:
function
(
event
)
{
saveOrUpdate
:
function
(
event
)
{
let
flag
=
vm
.
flag
;
let
flag
=
vm
.
flag
;
console
.
log
(
121323
,
vm
.
post
.
userType
)
console
.
log
(
121323
,
vm
.
post
.
userType
)
if
(
vm
.
post
.
userType
===
1
&&
vm
.
post
.
id
==
null
)
{
if
(
vm
.
post
.
userType
===
1
&&
vm
.
post
.
id
==
null
)
{
flag
=
this
.
queryAccount
();
flag
=
this
.
queryAccount
();
}
}
...
@@ -207,7 +208,28 @@ let vm = new Vue({
...
@@ -207,7 +208,28 @@ let vm = new Vue({
url
:
"../post/info/"
+
id
,
url
:
"../post/info/"
+
id
,
async
:
true
,
async
:
true
,
successCallback
:
function
(
r
)
{
successCallback
:
function
(
r
)
{
vm
.
disabled
=
true
vm
.
post
=
r
.
post
;
vm
.
post
=
r
.
post
;
vm
.
isShow
=
false
;
vm
.
uploadList
=
[];
let
status
=
vm
.
post
.
archived
//正常
if
(
status
===
1
)
{
vm
.
isShow
=
true
}
else
if
(
status
===
2
)
{
//下线
vm
.
isShow
=
false
;
}
let
content
=
vm
.
post
.
category
;
let
picture
=
vm
.
post
.
picture
;
if
(
picture
!=
null
&&
picture
!=
''
)
{
vm
.
uploadList
=
vm
.
post
.
picture
.
split
(
','
);
}
if
(
content
!=
null
)
{
UE
.
getEditor
(
'content'
).
setContent
(
content
);
}
else
{
UE
.
getEditor
(
'content'
).
setContent
(
''
);
}
}
}
});
});
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论