feat: ASW-18 application log 查询接口开发

This commit is contained in:
zhangshuai
2024-07-30 17:10:29 +08:00
parent 6b78f8e61a
commit 17328600aa
5 changed files with 94 additions and 0 deletions

View File

@@ -5,6 +5,7 @@ import net.geedge.asw.common.util.R;
import net.geedge.asw.common.util.RCode;
import net.geedge.asw.common.util.T;
import net.geedge.asw.module.app.entity.ApplicationEntity;
import net.geedge.asw.module.app.service.IApplicationLogService;
import net.geedge.asw.module.app.service.IApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -18,6 +19,9 @@ public class ApplicationController {
@Autowired
private IApplicationService applicationService;
@Autowired
private IApplicationLogService applicationLogService;
@GetMapping("/{id}")
public R detail(@PathVariable("id") String id) {
ApplicationEntity entity = applicationService.getById(id);
@@ -67,4 +71,17 @@ public class ApplicationController {
applicationService.removeApplication(T.ListUtil.of(ids));
return R.ok();
}
@GetMapping("/log/{id}")
public R queryLogList(@PathVariable("id") String id) {
Page page = applicationLogService.queryList(id);
return R.ok().putData("record", page);
}
@GetMapping("/log/{id1}/{id2}")
public R applicationCompare(@PathVariable("id1") String id1, @PathVariable("id2") String id2) {
Page page = applicationLogService.compare(id1,id2);
return R.ok().putData("record", page);
}
}

View File

@@ -1,9 +1,18 @@
package net.geedge.asw.module.app.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.geedge.asw.module.app.entity.ApplicationLogEntity;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
import java.util.Map;
@Mapper
public interface ApplicationLogDao extends BaseMapper<ApplicationLogEntity> {
List<ApplicationLogEntity> queryList(Page page, Map params);
List<ApplicationLogEntity> compare(Page page, Map params);
}

View File

@@ -1,7 +1,11 @@
package net.geedge.asw.module.app.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import net.geedge.asw.module.app.entity.ApplicationLogEntity;
public interface IApplicationLogService extends IService<ApplicationLogEntity> {
Page queryList(String id);
Page compare(String id1, String id2);
}

View File

@@ -1,11 +1,35 @@
package net.geedge.asw.module.app.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.geedge.asw.common.util.T;
import net.geedge.asw.module.app.dao.ApplicationLogDao;
import net.geedge.asw.module.app.entity.ApplicationLogEntity;
import net.geedge.asw.module.app.service.IApplicationLogService;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Service
public class ApplicationLogServiceImpl extends ServiceImpl<ApplicationLogDao, ApplicationLogEntity> implements IApplicationLogService {
@Override
public Page queryList(String id) {
Map<String, Object> params = Map.of("id", id);
Page page = T.PageUtil.getPage(params);
List<ApplicationLogEntity> packageList = this.getBaseMapper().queryList(page, params);
page.setRecords(packageList);
return page;
}
@Override
public Page compare(String id1, String id2) {
Map<String, Object> params = Map.of("ids", Arrays.asList(id1, id2));
Page page = T.PageUtil.getPage(params);
List<ApplicationLogEntity> packageList = this.getBaseMapper().compare(page, params);
page.setRecords(packageList);
return page;
}
}

View File

@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.geedge.asw.module.app.dao.ApplicationLogDao">
<select id="queryList" resultType="net.geedge.asw.module.app.entity.ApplicationLogEntity">
SELECT
app.*
FROM
(select * from application union select * from application_log) app
<where>
<if test="params.id != null and params.id != ''">
AND app.id = #{params.id}
</if>
</where>
<if test="params.orderBy == null or params.orderBy == ''">
ORDER BY app.id
</if>
</select>
<select id="compare" resultType="net.geedge.asw.module.app.entity.ApplicationLogEntity">
SELECT
app.*
FROM
(select * from application union select * from application_log ) app
<where>
<if test="params.ids != null and params.ids != ''">
app.id in
<foreach item="id" collection="params.ids" separator="," open="(" close=")">
#{id}
</foreach>
</if>
</where>
<if test="params.orderBy == null or params.orderBy == ''">
ORDER BY app.id
</if>
</select>
</mapper>