Commit a45e7414 by 284718418@qq.com

mybatis-plus-join

parent d6557609
...@@ -312,6 +312,12 @@ ...@@ -312,6 +312,12 @@
<artifactId>mybatis-plus</artifactId> <artifactId>mybatis-plus</artifactId>
<version>3.3.0</version> <version>3.3.0</version>
</dependency> </dependency>
<!-- mybatis-plus-join -->
<dependency>
<groupId>com.github.yulichang</groupId>
<artifactId>mybatis-plus-join</artifactId>
<version>1.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok-maven-plugin --> <!-- https://mvnrepository.com/artifact/org.projectlombok/lombok-maven-plugin -->
<!-- <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok-maven-plugin</artifactId> <!-- <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok-maven-plugin</artifactId>
......
...@@ -9,6 +9,7 @@ import java.util.TimerTask; ...@@ -9,6 +9,7 @@ import java.util.TimerTask;
import cn.timer.api.bean.qyxx.*; import cn.timer.api.bean.qyxx.*;
import cn.timer.api.dto.qyxx.CmsContentReadDto; import cn.timer.api.dto.qyxx.CmsContentReadDto;
import cn.timer.api.utils.redis.RedisUtil; import cn.timer.api.utils.redis.RedisUtil;
import com.github.yulichang.query.MPJQueryWrapper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
...@@ -147,9 +148,13 @@ public class CmsController { ...@@ -147,9 +148,13 @@ public class CmsController {
for (CmsContentModular cmsContentModular : list) { for (CmsContentModular cmsContentModular : list) {
// 分类模块id // 分类模块id
Integer id = cmsContentModular.getId(); Integer id = cmsContentModular.getId();
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>(); MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.select("id", "modularid", "title", "author", "releasetime").eq("releasestate", 0) queryWrapper.select("t.id", "t.modularid", "t.title", "t.author", "t.releasetime")
.eq("organization_id", userBean.getOrgCode()).orderByDesc("releasetime").eq("modularid", id) .leftJoin("cms_content_read ccr on t.id = ccr.cms_content_id");
queryWrapper.eq("t.releasestate", 0).and(!StringUtils.isEmpty(userBean.getEmpNum()), wq -> wq.eq("t.open_status", 1).or().and(true,q -> q.eq("t.open_status", 0).eq("ccr.user_id",userBean.getEmpNum())))
.eq("ccr.user_id", userBean.getEmpNum())
.eq("t.organization_id", userBean.getOrgCode()).orderByDesc("t.releasetime").eq("t.modularid", id)
.last("limit 5"); .last("limit 5");
List<CmsContent> qynrs = CmsContent.builder().build().selectList(queryWrapper); List<CmsContent> qynrs = CmsContent.builder().build().selectList(queryWrapper);
o.add(qynrs); o.add(qynrs);
......
package cn.timer.api.dao.qyxx; package cn.timer.api.dao.qyxx;
import com.github.yulichang.base.MPJBaseMapper;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
...@@ -12,6 +13,6 @@ import cn.timer.api.bean.qyxx.CmsContent; ...@@ -12,6 +13,6 @@ import cn.timer.api.bean.qyxx.CmsContent;
* @author dsc 2019-12-10 * @author dsc 2019-12-10
*/ */
@Repository @Repository
public interface CmsContentMapper extends BaseMapper<CmsContent> { public interface CmsContentMapper extends MPJBaseMapper<CmsContent> {
} }
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