Commit c3fa9bb8 by 284718418@qq.com

mybatis-plus-join

parent a45e7414
......@@ -304,13 +304,13 @@
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.0</version>
<version>3.4.1</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.3.0</version>
<version>3.4.1</version>
</dependency>
<!-- mybatis-plus-join -->
<dependency>
......
......@@ -92,9 +92,13 @@ public class CmsController {
@ApiOperation(value = "获取最新讯息的标题、发布时间", httpMethod = "GET", notes = "接口发布说明")
public Result<List<CmsContent>> groupbyTime(@CurrentUser UserBean userBean) {
Integer orgCode = userBean.getOrgCode();
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.select("id", "title", "author", "releasetime", "fmtpath").eq("releasestate", 0)
.eq("organization_id", orgCode).orderByDesc("releasetime").last("limit 6");
MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.select("t.id", "t.title", "t.author", "t.releasetime", "t.fmtpath")
.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(true,q -> q.eq("t.open_status", 0).eq("ccr.user_id",userBean.getEmpNum())))
.eq("t.organization_id", orgCode)
.groupBy("t.id")
.orderByDesc("t.releasetime").last("limit 6");
List<CmsContent> qynr = CmsContent.builder().build().selectList(queryWrapper);
return ResultUtil.data(qynr, "查询分类成功!");
}
......@@ -151,9 +155,8 @@ public class CmsController {
MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.select("t.id", "t.modularid", "t.title", "t.author", "t.releasetime")
.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())))
queryWrapper.eq("t.releasestate", 0).and(!StringUtils.isEmpty(userBean.getEmpNum()), wq -> wq.eq("t.open_status", 1).or(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");
List<CmsContent> qynrs = CmsContent.builder().build().selectList(queryWrapper);
......@@ -330,14 +333,18 @@ public class CmsController {
qyxxQueryDto.getCurrentPage() == null ? 1 : qyxxQueryDto.getCurrentPage(),
qyxxQueryDto.getTotalPage() == null ? 10 : qyxxQueryDto.getTotalPage());
QueryWrapper<CmsContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("organization_id", userBean.getOrgCode()).eq("status", 1).eq("releasestate", 0)
.eq(t != null && t > -1, "modularid", t).eq(r != null && r > -1, "releasestate", r)
.between(!StrUtil.hasBlank(s) && !StrUtil.hasBlank(e), "releasetime",
MPJQueryWrapper<CmsContent> queryWrapper = new MPJQueryWrapper<>();
queryWrapper.select("t.id", "t.title", "t.author", "t.releasetime", "t.fmtpath")
.leftJoin("cms_content_read ccr on t.id = ccr.cms_content_id");
queryWrapper.and(!StringUtils.isEmpty(userBean.getEmpNum()), wq -> wq.eq("t.open_status", 1).or(true,sq -> sq.eq("t.open_status", 0).eq("ccr.user_id",userBean.getEmpNum())));
queryWrapper.eq("t.organization_id", userBean.getOrgCode()).eq("t.status", 1).eq("t.releasestate", 0)
.eq(t != null && t > -1, "t.modularid", t).eq(r != null && r > -1, "t.releasestate", r)
.between(!StrUtil.hasBlank(s) && !StrUtil.hasBlank(e), "t.releasetime",
!StrUtil.hasBlank(s) ? s : "1000-01-01 00:00:00",
!StrUtil.hasBlank(e) ? e : "9999-01-01 00:00:00")
.and(!StrUtil.hasBlank(q), wq -> wq.like("userid", q).or().like("author", q).or().like("title", q))
.orderByDesc("addeddate");
.and(!StrUtil.hasBlank(q), wq -> wq.like("t.userid", q).or().like("t.author", q).or().like("title", q))
.groupBy("t.id")
.orderByDesc("t.addeddate");
IPage<CmsContent> cmsContentPage = CmsContent.builder().build().selectPage(page, queryWrapper);
List<CmsContent> cmsContents = cmsContentPage.getRecords();
cmsContentPage.getCurrent();
......
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