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

优化代码

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