summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzhangshuai <[email protected]>2024-08-06 18:15:11 +0800
committerzhangshuai <[email protected]>2024-08-06 18:15:11 +0800
commitd5f6aef383fed6c7ead3dbd01983d055bff03d6c (patch)
treec58e6f5b43cdd416ff0dbd51f0062e715a3415c5
parent875eb83d6e27516dabd9998a76fe5ca33b537478 (diff)
fix: application 接口返回 user 对象
-rw-r--r--src/main/java/net/geedge/asw/module/app/controller/ApplicationController.java37
-rw-r--r--src/main/java/net/geedge/asw/module/app/dao/ApplicationDao.java6
-rw-r--r--src/main/java/net/geedge/asw/module/app/dao/ApplicationLogDao.java8
-rw-r--r--src/main/java/net/geedge/asw/module/app/entity/ApplicationEntity.java8
-rw-r--r--src/main/java/net/geedge/asw/module/app/entity/ApplicationLogEntity.java4
-rw-r--r--src/main/java/net/geedge/asw/module/app/service/impl/ApplicationLogServiceImpl.java22
-rw-r--r--src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java16
-rw-r--r--src/main/resources/db/mapper/app/ApplicationLogMapper.xml40
-rw-r--r--src/main/resources/db/mapper/app/ApplicationMapper.xml80
9 files changed, 137 insertions, 84 deletions
diff --git a/src/main/java/net/geedge/asw/module/app/controller/ApplicationController.java b/src/main/java/net/geedge/asw/module/app/controller/ApplicationController.java
index 9fcc94e..4944840 100644
--- a/src/main/java/net/geedge/asw/module/app/controller/ApplicationController.java
+++ b/src/main/java/net/geedge/asw/module/app/controller/ApplicationController.java
@@ -1,16 +1,18 @@
package net.geedge.asw.module.app.controller;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import net.geedge.asw.common.util.ASWException;
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 net.geedge.asw.module.sys.entity.SysUserEntity;
+import net.geedge.asw.module.sys.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
+import java.util.List;
import java.util.Map;
@RestController
@@ -21,14 +23,35 @@ public class ApplicationController {
private IApplicationService applicationService;
@Autowired
- private IApplicationLogService applicationLogService;
+ private ISysUserService userService;
+
+ @GetMapping("/{id}")
+ public R detail(@PathVariable String id) {
+ ApplicationEntity entity = applicationService.getById(id);
+ if (T.ObjectUtil.isNull(entity)){
+ throw new ASWException(RCode.APP_NOT_EXIST);
+ }
+ SysUserEntity createUser = userService.getById(entity.getCreateUserId());
+ SysUserEntity updateUser = userService.getById(entity.getUpdateUserId());
+ entity.setCreateUser(createUser);
+ entity.setUpdateUser(updateUser);
+ return R.ok().putData("record", entity);
+ }
@GetMapping("/{id}/{version}")
- public R detail(@PathVariable("id") String id, @PathVariable(value = "version",required = false) String version) {
+ public R detail(@PathVariable String id,
+ @PathVariable(required = false) String version) {
ApplicationEntity entity = applicationService.getById(id);
if (T.StrUtil.isNotEmpty(version)){
entity = applicationService.queryByApplicationAndLog(id, version);
}
+ if (T.ObjectUtil.isNull(entity)){
+ throw new ASWException(RCode.APP_NOT_EXIST);
+ }
+ SysUserEntity createUser = userService.getById(entity.getCreateUserId());
+ SysUserEntity updateUser = userService.getById(entity.getUpdateUserId());
+ entity.setCreateUser(createUser);
+ entity.setUpdateUser(updateUser);
return R.ok().putData("record", entity);
}
@@ -79,14 +102,14 @@ public class ApplicationController {
@GetMapping("/log/{id}")
public R queryLogList(@PathVariable("id") String id) {
- Page page = applicationLogService.queryList(id);
- return R.ok().putData("record", page);
+ List<ApplicationEntity> applicationEntityList = applicationService.queryLogList(id);
+ return R.ok().putData("record", applicationEntityList);
}
@GetMapping("/log/{id1}/{id2}")
public R applicationCompare(@PathVariable("id1") String id1, @PathVariable("id2") String id2) {
- Page page = applicationLogService.compare(id1,id2);
+ Page page = applicationService.compare(id1, id2);
return R.ok().putData("record", page);
}
}
diff --git a/src/main/java/net/geedge/asw/module/app/dao/ApplicationDao.java b/src/main/java/net/geedge/asw/module/app/dao/ApplicationDao.java
index f5c91aa..87ab274 100644
--- a/src/main/java/net/geedge/asw/module/app/dao/ApplicationDao.java
+++ b/src/main/java/net/geedge/asw/module/app/dao/ApplicationDao.java
@@ -16,4 +16,10 @@ public interface ApplicationDao extends BaseMapper<ApplicationEntity>{
@Select("select * from ( select * from application union select * from application_log ) app where app.id = #{id} and app.op_version = #{version}")
ApplicationEntity queryByApplicationAndLog(String id, String version);
+
+ List<ApplicationEntity> queryLogList(String id);
+
+ List<ApplicationEntity> compare(Page page, Map<String, Object> params);
+
+
}
diff --git a/src/main/java/net/geedge/asw/module/app/dao/ApplicationLogDao.java b/src/main/java/net/geedge/asw/module/app/dao/ApplicationLogDao.java
index 48fc3b6..913dcf2 100644
--- a/src/main/java/net/geedge/asw/module/app/dao/ApplicationLogDao.java
+++ b/src/main/java/net/geedge/asw/module/app/dao/ApplicationLogDao.java
@@ -1,18 +1,10 @@
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);
-
}
diff --git a/src/main/java/net/geedge/asw/module/app/entity/ApplicationEntity.java b/src/main/java/net/geedge/asw/module/app/entity/ApplicationEntity.java
index fc62f68..ab9e3fc 100644
--- a/src/main/java/net/geedge/asw/module/app/entity/ApplicationEntity.java
+++ b/src/main/java/net/geedge/asw/module/app/entity/ApplicationEntity.java
@@ -1,9 +1,11 @@
package net.geedge.asw.module.app.entity;
import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
+import net.geedge.asw.module.sys.entity.SysUserEntity;
@Data
@TableName("application")
@@ -25,4 +27,10 @@ public class ApplicationEntity {
private String workspaceId;
private Integer opVersion;
+ @TableField(exist = false)
+ private SysUserEntity createUser;
+
+ @TableField(exist = false)
+ private SysUserEntity updateUser;
+
} \ No newline at end of file
diff --git a/src/main/java/net/geedge/asw/module/app/entity/ApplicationLogEntity.java b/src/main/java/net/geedge/asw/module/app/entity/ApplicationLogEntity.java
index 48415aa..16a7661 100644
--- a/src/main/java/net/geedge/asw/module/app/entity/ApplicationLogEntity.java
+++ b/src/main/java/net/geedge/asw/module/app/entity/ApplicationLogEntity.java
@@ -1,14 +1,12 @@
package net.geedge.asw.module.app.entity;
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("application_log")
public class ApplicationLogEntity {
- @TableId(type = IdType.ASSIGN_UUID)
+
private String id;
private String name;
private String longName;
diff --git a/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationLogServiceImpl.java b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationLogServiceImpl.java
index 1eb7757..7dd3dc5 100644
--- a/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationLogServiceImpl.java
+++ b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationLogServiceImpl.java
@@ -1,35 +1,13 @@
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;
- }
}
diff --git a/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java
index a67fb12..f72f3e1 100644
--- a/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java
+++ b/src/main/java/net/geedge/asw/module/app/service/impl/ApplicationServiceImpl.java
@@ -15,6 +15,7 @@ import net.geedge.asw.module.app.service.IApplicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -86,4 +87,19 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, Applicat
this.removeBatchByIds(ids);
applicationLogService.removeBatchByIds(ids);
}
+
+ @Override
+ public List<ApplicationEntity> queryLogList(String id) {
+ List<ApplicationEntity> packageList = this.getBaseMapper().queryLogList(id);
+ return packageList;
+ }
+
+ @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<ApplicationEntity> packageList = this.getBaseMapper().compare(page, params);
+ page.setRecords(packageList);
+ return page;
+ }
}
diff --git a/src/main/resources/db/mapper/app/ApplicationLogMapper.xml b/src/main/resources/db/mapper/app/ApplicationLogMapper.xml
deleted file mode 100644
index c701328..0000000
--- a/src/main/resources/db/mapper/app/ApplicationLogMapper.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?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> \ No newline at end of file
diff --git a/src/main/resources/db/mapper/app/ApplicationMapper.xml b/src/main/resources/db/mapper/app/ApplicationMapper.xml
index 9396a10..4dfc19b 100644
--- a/src/main/resources/db/mapper/app/ApplicationMapper.xml
+++ b/src/main/resources/db/mapper/app/ApplicationMapper.xml
@@ -2,13 +2,42 @@
<!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.ApplicationDao">
+ <resultMap id="appResult" type="net.geedge.asw.module.app.entity.ApplicationEntity">
+ <result property="id" column="id"/>
+ <result property="name" column="name"/>
+ <result property="longName" column="long_name"/>
+ <result property="properties" column="properties"/>
+ <result property="description" column="description"/>
+ <result property="surrogates" column="surrogates"/>
+ <result property="createTimestamp" column="create_timestamp"/>
+ <result property="updateTimestamp" column="update_timestamp"/>
+ <result property="createUserId" column="create_user_id"/>
+ <result property="updateUserId" column="update_user_id"/>
+ <result property="workspaceId" column="workspace_id"/>
+ <result property="opVersion" column="op_version"/>
+ <association property="createUser" columnPrefix="cu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
+ <id property="id" column="id"/>
+ <result property="name" column="name"/>
+ </association>
- <select id="queryList" resultType="net.geedge.asw.module.app.entity.ApplicationEntity">
+ <association property="updateUser" columnPrefix="uu_" javaType="net.geedge.asw.module.sys.entity.SysUserEntity">
+ <id property="id" column="id"/>
+ <result property="name" column="name"/>
+ </association>
+ </resultMap>
+
+ <select id="queryList" resultMap="appResult">
SELECT
- app.*
+ app.*,
+ cu.id as cu_id,
+ cu.name as cu_name,
+ uu.id as uu_id,
+ uu.id as uu_name
FROM
application app
+ left join sys_user cu on app.create_user_id = cu.id
+ left join sys_user uu on app.update_user_id = uu.id
<where>
<if test="params.ids != null and params.ids != ''">
app.id in
@@ -20,16 +49,59 @@
<if test="params.q != null and params.q != ''">
AND ( locate(#{params.q}, app.name) OR locate(#{params.q}, app.description) )
</if>
+ <if test="params.id != null and params.id != ''">
+ AND app.id = #{params.id}
+ </if>
<if test="params.workspaceId != null and params.workspaceId != ''">
AND app.workspace_id = #{params.workspaceId}
</if>
</where>
+ <if test="params.orderBy == null or params.orderBy == ''">
+ ORDER BY app.id
+ </if>
+ </select>
- GROUP BY
- app.id
+ <select id="queryLogList" resultMap="appResult">
+ SELECT
+ app.*,
+ cu.id as cu_id,
+ cu.name as cu_name,
+ uu.id as uu_id,
+ uu.id as uu_name
+ FROM
+ (select * from application union select * from application_log) app
+ left join sys_user cu on app.create_user_id = cu.id
+ left join sys_user uu on app.update_user_id = uu.id
+ <where>
+ <if test="id != null and id != ''">
+ AND app.id = #{id}
+ </if>
+ </where>
+ </select>
+
+ <select id="compare" resultMap="appResult">
+ SELECT
+ app.*,
+ cu.id as cu_id,
+ cu.name as cu_name,
+ uu.id as uu_id,
+ uu.id as uu_name
+ FROM
+ (select * from application union select * from application_log ) app
+ left join sys_user cu on app.create_user_id = cu.id
+ left join sys_user uu on app.update_user_id = uu.id
+ <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> \ No newline at end of file