mirror of
https://github.com/CodePhiliaX/Chat2DB.git
synced 2025-08-01 08:52:11 +08:00
Fix some team project bugs
This commit is contained in:
@ -12,6 +12,11 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class OperationLogPageQueryParam extends PageQueryParam {
|
public class OperationLogPageQueryParam extends PageQueryParam {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户id
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 搜索关键词
|
* 搜索关键词
|
||||||
*/
|
*/
|
||||||
|
@ -18,12 +18,12 @@ import ai.chat2db.server.domain.repository.mapper.OperationLogMapper;
|
|||||||
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
|
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
|
||||||
import ai.chat2db.server.tools.base.wrapper.result.ListResult;
|
import ai.chat2db.server.tools.base.wrapper.result.ListResult;
|
||||||
import ai.chat2db.server.tools.base.wrapper.result.PageResult;
|
import ai.chat2db.server.tools.base.wrapper.result.PageResult;
|
||||||
|
import ai.chat2db.server.tools.common.model.EasyLambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import ai.chat2db.server.tools.common.util.ContextUtils;
|
||||||
|
import ai.chat2db.server.tools.common.util.EasySqlUtils;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.apache.commons.collections4.CollectionUtils;
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -49,16 +49,17 @@ public class OperationLogServiceImpl implements OperationLogService {
|
|||||||
OperationLogDO userExecutedDdlDO = operationLogConverter.param2do(param);
|
OperationLogDO userExecutedDdlDO = operationLogConverter.param2do(param);
|
||||||
userExecutedDdlDO.setGmtCreate(LocalDateTime.now());
|
userExecutedDdlDO.setGmtCreate(LocalDateTime.now());
|
||||||
userExecutedDdlDO.setGmtModified(LocalDateTime.now());
|
userExecutedDdlDO.setGmtModified(LocalDateTime.now());
|
||||||
|
userExecutedDdlDO.setUserId(ContextUtils.getUserId());
|
||||||
operationLogMapper.insert(userExecutedDdlDO);
|
operationLogMapper.insert(userExecutedDdlDO);
|
||||||
return DataResult.of(userExecutedDdlDO.getId());
|
return DataResult.of(userExecutedDdlDO.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<OperationLog> queryPage(OperationLogPageQueryParam param) {
|
public PageResult<OperationLog> queryPage(OperationLogPageQueryParam param) {
|
||||||
QueryWrapper<OperationLogDO> queryWrapper = new QueryWrapper<>();
|
EasyLambdaQueryWrapper<OperationLogDO> queryWrapper = new EasyLambdaQueryWrapper<>();
|
||||||
if (StringUtils.isNotBlank(param.getSearchKey())) {
|
queryWrapper.likeWhenPresent(OperationLogDO::getDdl, EasySqlUtils.buildLikeRightFuzzy(param.getSearchKey()))
|
||||||
queryWrapper.like("ddl", param.getSearchKey());
|
.eqWhenPresent(OperationLogDO::getUserId, param.getUserId())
|
||||||
}
|
;
|
||||||
Integer start = param.getPageNo();
|
Integer start = param.getPageNo();
|
||||||
Integer offset = param.getPageSize();
|
Integer offset = param.getPageSize();
|
||||||
Page<OperationLogDO> page = new Page<>(start, offset);
|
Page<OperationLogDO> page = new Page<>(start, offset);
|
||||||
|
@ -114,6 +114,12 @@ ALTER TABLE `operation_saved`
|
|||||||
update operation_saved
|
update operation_saved
|
||||||
set user_id= 1;
|
set user_id= 1;
|
||||||
|
|
||||||
|
ALTER TABLE `operation_log`
|
||||||
|
modify COLUMN `user_id` bigint(20) unsigned NOT NULL DEFAULT 1 COMMENT '用户id';
|
||||||
|
|
||||||
|
update operation_log
|
||||||
|
set user_id= 1;
|
||||||
|
|
||||||
ALTER TABLE `dashboard`
|
ALTER TABLE `dashboard`
|
||||||
modify `user_id` bigint(20) unsigned NOT NULL DEFAULT 1 COMMENT '用户id';
|
modify `user_id` bigint(20) unsigned NOT NULL DEFAULT 1 COMMENT '用户id';
|
||||||
update dashboard
|
update dashboard
|
||||||
|
@ -9,6 +9,7 @@ import ai.chat2db.server.domain.api.service.OperationLogService;
|
|||||||
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
|
import ai.chat2db.server.tools.base.wrapper.result.DataResult;
|
||||||
import ai.chat2db.server.tools.base.wrapper.result.PageResult;
|
import ai.chat2db.server.tools.base.wrapper.result.PageResult;
|
||||||
import ai.chat2db.server.tools.base.wrapper.result.web.WebPageResult;
|
import ai.chat2db.server.tools.base.wrapper.result.web.WebPageResult;
|
||||||
|
import ai.chat2db.server.tools.common.util.ContextUtils;
|
||||||
import ai.chat2db.server.web.api.controller.operation.log.converter.OperationLogWebConverter;
|
import ai.chat2db.server.web.api.controller.operation.log.converter.OperationLogWebConverter;
|
||||||
import ai.chat2db.server.web.api.controller.operation.log.request.OperationLogCreateRequest;
|
import ai.chat2db.server.web.api.controller.operation.log.request.OperationLogCreateRequest;
|
||||||
import ai.chat2db.server.web.api.controller.operation.log.request.OperationLogQueryRequest;
|
import ai.chat2db.server.web.api.controller.operation.log.request.OperationLogQueryRequest;
|
||||||
@ -47,6 +48,7 @@ public class OperationLogController {
|
|||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public WebPageResult<OperationLogVO> list(OperationLogQueryRequest request) {
|
public WebPageResult<OperationLogVO> list(OperationLogQueryRequest request) {
|
||||||
OperationLogPageQueryParam param = operationLogWebConverter.req2param(request);
|
OperationLogPageQueryParam param = operationLogWebConverter.req2param(request);
|
||||||
|
param.setUserId(ContextUtils.getUserId());
|
||||||
PageResult<OperationLog> result = operationLogService.queryPage(param);
|
PageResult<OperationLog> result = operationLogService.queryPage(param);
|
||||||
List<OperationLogVO> operationLogVOList = operationLogWebConverter.dto2vo(result.getData());
|
List<OperationLogVO> operationLogVOList = operationLogWebConverter.dto2vo(result.getData());
|
||||||
return WebPageResult.of(operationLogVOList, result.getTotal(), result.getPageNo(), result.getPageSize());
|
return WebPageResult.of(operationLogVOList, result.getTotal(), result.getPageNo(), result.getPageSize());
|
||||||
|
Reference in New Issue
Block a user