Commit 93b6f4b6 authored by 万成波's avatar 万成波

优化代码

parent 1eff28d9
...@@ -74,6 +74,18 @@ public class SysDept extends BaseEntity { ...@@ -74,6 +74,18 @@ public class SysDept extends BaseEntity {
*/ */
private String parentName; private String parentName;
private String deptType;
public String getDeptType() {
return deptType;
}
public void setDeptType(String deptType) {
this.deptType = deptType;
}
/** /**
* 子部门 * 子部门
*/ */
......
...@@ -42,4 +42,7 @@ public class BbsCommentDetailVO { ...@@ -42,4 +42,7 @@ public class BbsCommentDetailVO {
/** 评论是否精选:0 否、1 是 */ /** 评论是否精选:0 否、1 是 */
private Integer isFeatured; private Integer isFeatured;
/** 评论是否置顶:0 否、1 是 */
private Integer isTop;
} }
...@@ -33,4 +33,7 @@ public class BbsCommentVO { ...@@ -33,4 +33,7 @@ public class BbsCommentVO {
/** 是否本人评论:0 否、1 是 */ /** 是否本人评论:0 否、1 是 */
private Integer isSelf; private Integer isSelf;
/** 是否置顶:0 否、1 是 */
private Integer isTop;
} }
package com.tangguo.mapper; package com.tangguo.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tangguo.common.core.domain.entity.SysDept;
import com.tangguo.domain.BbsMoment; import com.tangguo.domain.BbsMoment;
import com.tangguo.domain.bo.QueryMomentBO; import com.tangguo.domain.bo.QueryMomentBO;
import com.tangguo.domain.vo.BbsMomentListVO; import com.tangguo.domain.vo.BbsMomentListVO;
...@@ -20,7 +19,7 @@ public interface BbsMomentMapper extends BaseMapper<BbsMoment> { ...@@ -20,7 +19,7 @@ public interface BbsMomentMapper extends BaseMapper<BbsMoment> {
List<BbsMoment> selectBbsMomentList(@Param("moment") BbsMoment moment); List<BbsMoment> selectBbsMomentList(@Param("moment") BbsMoment moment);
List<String> selectBbsMomentDepts(@Param("deptIds") String[] deptIds); String selectBbsMomentDept(@Param("deptIds") String[] deptIds);
BbsUserMomentCountVO selectUserMomentCount(@Param("userName") String userName); BbsUserMomentCountVO selectUserMomentCount(@Param("userName") String userName);
......
...@@ -6,7 +6,6 @@ import cn.hutool.core.util.StrUtil; ...@@ -6,7 +6,6 @@ import cn.hutool.core.util.StrUtil;
import cn.hutool.dfa.FoundWord; import cn.hutool.dfa.FoundWord;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tangguo.common.core.domain.entity.SysDept;
import com.tangguo.common.core.domain.entity.SysUser; import com.tangguo.common.core.domain.entity.SysUser;
import com.tangguo.common.enums.*; import com.tangguo.common.enums.*;
import com.tangguo.common.exception.ServiceException; import com.tangguo.common.exception.ServiceException;
...@@ -82,9 +81,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -82,9 +81,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
String[] deptIds = dbMoment.getAncestors().split(","); String[] deptIds = dbMoment.getAncestors().split(",");
if (ArrayUtil.isNotEmpty(deptIds)) { if (ArrayUtil.isNotEmpty(deptIds)) {
List<String> deptNames = this.baseMapper.selectBbsMomentDepts(deptIds); String deptName = this.baseMapper.selectBbsMomentDept(deptIds);
String deptName = deptNames.stream().filter(s -> s.contains("学院"))
.reduce((first, second) -> second).orElse(null);
dbMoment.setFullDeptName(deptName); dbMoment.setFullDeptName(deptName);
} }
} }
...@@ -674,6 +671,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment ...@@ -674,6 +671,7 @@ public class BbsMomentServiceImpl extends ServiceImpl<BbsMomentMapper, BbsMoment
cv.setUserName(c.getUserName()); cv.setUserName(c.getUserName());
cv.setContent(c.getContent()); cv.setContent(c.getContent());
cv.setIsSelf(c.getIsSelf()); cv.setIsSelf(c.getIsSelf());
cv.setIsTop(c.getIsTop());
cvs.add(cv); cvs.add(cv);
} }
moment.setComments(cvs); moment.setComments(cvs);
......
...@@ -68,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -68,6 +68,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
c.content, c.content,
c.parent_id, c.parent_id,
c.reply_nick_name, c.reply_nick_name,
c.is_top,
IF(c.user_name = #{userName}, 1, 0) AS is_self, IF(c.user_name = #{userName}, 1, 0) AS is_self,
ROW_NUMBER() OVER (PARTITION BY moment_id ORDER BY create_time) AS rn ROW_NUMBER() OVER (PARTITION BY moment_id ORDER BY create_time) AS rn
FROM FROM
...@@ -112,6 +113,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -112,6 +113,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
c.parent_id, c.parent_id,
c.reply_nick_name, c.reply_nick_name,
c.is_featured, c.is_featured,
c.is_top,
IF(c.user_name = #{userName}, 1, 0) AS is_self IF(c.user_name = #{userName}, 1, 0) AS is_self
FROM FROM
bbs_moment_comment c bbs_moment_comment c
......
...@@ -44,16 +44,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -44,16 +44,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select> </select>
<select id="selectBbsMomentDepts" resultType="java.lang.String"> <select id="selectBbsMomentDept" resultType="java.lang.String">
SELECT SELECT
dept_name dept_name
FROM FROM
sys_dept sys_dept
WHERE WHERE
dept_type = '3'
AND
dept_id IN dept_id IN
<foreach collection="deptIds" item="deptId" open="(" separator="," close=")"> <foreach collection="deptIds" item="deptId" open="(" separator="," close=")">
#{deptId} #{deptId}
</foreach> </foreach>
LIMIT 1
</select> </select>
......
...@@ -191,10 +191,10 @@ ...@@ -191,10 +191,10 @@
<update id="syncQwmhSysDeptToLocal"> <update id="syncQwmhSysDeptToLocal">
INSERT INTO sys_dept(dept_id, parent_id, ancestors, dept_name, order_num, create_time) INSERT INTO sys_dept(dept_id, parent_id, ancestors, dept_name, order_num, create_time, dept_type)
( (
SELECT SELECT
q.id, q.parent_id, q.ancestors, q.dept_name, q.order_num, q.create_time q.id, q.parent_id, q.ancestors, q.dept_name, q.order_num, q.create_time, q.dept_type
FROM FROM
ods_sys_dept_view q ods_sys_dept_view q
LEFT JOIN LEFT JOIN
......
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