fix: application 接口返回 user 对象
This commit is contained in:
@@ -1,16 +1,18 @@
|
|||||||
package net.geedge.asw.module.app.controller;
|
package net.geedge.asw.module.app.controller;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
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.R;
|
||||||
import net.geedge.asw.common.util.RCode;
|
import net.geedge.asw.common.util.RCode;
|
||||||
import net.geedge.asw.common.util.T;
|
import net.geedge.asw.common.util.T;
|
||||||
import net.geedge.asw.module.app.entity.ApplicationEntity;
|
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.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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@@ -21,14 +23,35 @@ public class ApplicationController {
|
|||||||
private IApplicationService applicationService;
|
private IApplicationService applicationService;
|
||||||
|
|
||||||
@Autowired
|
@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}")
|
@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);
|
ApplicationEntity entity = applicationService.getById(id);
|
||||||
if (T.StrUtil.isNotEmpty(version)){
|
if (T.StrUtil.isNotEmpty(version)){
|
||||||
entity = applicationService.queryByApplicationAndLog(id, 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);
|
return R.ok().putData("record", entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,14 +102,14 @@ public class ApplicationController {
|
|||||||
|
|
||||||
@GetMapping("/log/{id}")
|
@GetMapping("/log/{id}")
|
||||||
public R queryLogList(@PathVariable("id") String id) {
|
public R queryLogList(@PathVariable("id") String id) {
|
||||||
Page page = applicationLogService.queryList(id);
|
List<ApplicationEntity> applicationEntityList = applicationService.queryLogList(id);
|
||||||
return R.ok().putData("record", page);
|
return R.ok().putData("record", applicationEntityList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("/log/{id1}/{id2}")
|
@GetMapping("/log/{id1}/{id2}")
|
||||||
public R applicationCompare(@PathVariable("id1") String id1, @PathVariable("id2") String 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);
|
return R.ok().putData("record", page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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}")
|
@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);
|
ApplicationEntity queryByApplicationAndLog(String id, String version);
|
||||||
|
|
||||||
|
List<ApplicationEntity> queryLogList(String id);
|
||||||
|
|
||||||
|
List<ApplicationEntity> compare(Page page, Map<String, Object> params);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,10 @@
|
|||||||
package net.geedge.asw.module.app.dao;
|
package net.geedge.asw.module.app.dao;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import net.geedge.asw.module.app.entity.ApplicationLogEntity;
|
import net.geedge.asw.module.app.entity.ApplicationLogEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface ApplicationLogDao extends BaseMapper<ApplicationLogEntity> {
|
public interface ApplicationLogDao extends BaseMapper<ApplicationLogEntity> {
|
||||||
|
|
||||||
List<ApplicationLogEntity> queryList(Page page, Map params);
|
|
||||||
|
|
||||||
List<ApplicationLogEntity> compare(Page page, Map params);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package net.geedge.asw.module.app.entity;
|
package net.geedge.asw.module.app.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import net.geedge.asw.module.sys.entity.SysUserEntity;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName("application")
|
@TableName("application")
|
||||||
@@ -25,4 +27,10 @@ public class ApplicationEntity {
|
|||||||
private String workspaceId;
|
private String workspaceId;
|
||||||
private Integer opVersion;
|
private Integer opVersion;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private SysUserEntity createUser;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
private SysUserEntity updateUser;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
package net.geedge.asw.module.app.entity;
|
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 com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@TableName("application_log")
|
@TableName("application_log")
|
||||||
public class ApplicationLogEntity {
|
public class ApplicationLogEntity {
|
||||||
@TableId(type = IdType.ASSIGN_UUID)
|
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
private String longName;
|
private String longName;
|
||||||
|
|||||||
@@ -1,35 +1,13 @@
|
|||||||
package net.geedge.asw.module.app.service.impl;
|
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 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.dao.ApplicationLogDao;
|
||||||
import net.geedge.asw.module.app.entity.ApplicationLogEntity;
|
import net.geedge.asw.module.app.entity.ApplicationLogEntity;
|
||||||
import net.geedge.asw.module.app.service.IApplicationLogService;
|
import net.geedge.asw.module.app.service.IApplicationLogService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ApplicationLogServiceImpl extends ServiceImpl<ApplicationLogDao, ApplicationLogEntity> implements IApplicationLogService {
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import net.geedge.asw.module.app.service.IApplicationService;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -86,4 +87,19 @@ public class ApplicationServiceImpl extends ServiceImpl<ApplicationDao, Applicat
|
|||||||
this.removeBatchByIds(ids);
|
this.removeBatchByIds(ids);
|
||||||
applicationLogService.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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
|
||||||
@@ -2,13 +2,42 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!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">
|
<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
|
SELECT
|
||||||
app.*
|
app.*,
|
||||||
|
cu.id as cu_id,
|
||||||
|
cu.name as cu_name,
|
||||||
|
uu.id as uu_id,
|
||||||
|
uu.id as uu_name
|
||||||
FROM
|
FROM
|
||||||
application app
|
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>
|
<where>
|
||||||
<if test="params.ids != null and params.ids != ''">
|
<if test="params.ids != null and params.ids != ''">
|
||||||
app.id in
|
app.id in
|
||||||
@@ -20,16 +49,59 @@
|
|||||||
<if test="params.q != null and params.q != ''">
|
<if test="params.q != null and params.q != ''">
|
||||||
AND ( locate(#{params.q}, app.name) OR locate(#{params.q}, app.description) )
|
AND ( locate(#{params.q}, app.name) OR locate(#{params.q}, app.description) )
|
||||||
</if>
|
</if>
|
||||||
|
<if test="params.id != null and params.id != ''">
|
||||||
|
AND app.id = #{params.id}
|
||||||
|
</if>
|
||||||
<if test="params.workspaceId != null and params.workspaceId != ''">
|
<if test="params.workspaceId != null and params.workspaceId != ''">
|
||||||
AND app.workspace_id = #{params.workspaceId}
|
AND app.workspace_id = #{params.workspaceId}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
|
||||||
GROUP BY
|
|
||||||
app.id
|
|
||||||
<if test="params.orderBy == null or params.orderBy == ''">
|
<if test="params.orderBy == null or params.orderBy == ''">
|
||||||
ORDER BY app.id
|
ORDER BY app.id
|
||||||
</if>
|
</if>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<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>
|
</mapper>
|
||||||
Reference in New Issue
Block a user