13 changed files with 141 additions and 2 deletions
@ -1,10 +1,19 @@ |
|||||
package com.project.operation.application.impl; |
package com.project.operation.application.impl; |
||||
|
|
||||
|
import com.project.base.domain.result.Result; |
||||
import com.project.operation.domain.dto.OperationLogDTO; |
import com.project.operation.domain.dto.OperationLogDTO; |
||||
|
import com.project.operation.domain.param.OperationLogParam; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
public interface OperationLogApplicationService { |
public interface OperationLogApplicationService { |
||||
/** |
/** |
||||
* 保存操作日志 |
* 保存操作日志 |
||||
*/ |
*/ |
||||
void saveOperationLog(OperationLogDTO operationLogDTO); |
void saveOperationLog(OperationLogDTO operationLogDTO); |
||||
|
|
||||
|
/** |
||||
|
* 查询日志 |
||||
|
*/ |
||||
|
Result<List<OperationLogDTO>> list(OperationLogParam param); |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,25 @@ |
|||||
|
package com.project.operation.controller; |
||||
|
|
||||
|
import com.project.base.domain.result.Result; |
||||
|
import com.project.operation.application.impl.OperationLogApplicationService; |
||||
|
import com.project.operation.domain.dto.OperationLogDTO; |
||||
|
import com.project.operation.domain.param.OperationLogParam; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
import org.springframework.web.bind.annotation.RestController; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@RestController |
||||
|
@RequestMapping("/api/admin/operationLog") |
||||
|
public class OperationLogController { |
||||
|
|
||||
|
@Autowired |
||||
|
private OperationLogApplicationService operationLogApplicationService; |
||||
|
|
||||
|
@GetMapping("/list") |
||||
|
public Result<List<OperationLogDTO>> list(OperationLogParam param) throws Exception { |
||||
|
return operationLogApplicationService.list(param); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
package com.project.operation.domain.param; |
||||
|
|
||||
|
import com.project.base.domain.param.BaseParam; |
||||
|
import lombok.Data; |
||||
|
import org.springframework.format.annotation.DateTimeFormat; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
|
||||
|
@Data |
||||
|
public class OperationLogParam extends BaseParam { |
||||
|
//操作
|
||||
|
public String action; |
||||
|
//详细信息
|
||||
|
public String description; |
||||
|
//开始时间
|
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
public Date startTime; |
||||
|
//结束时间
|
||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
||||
|
public Date endTime; |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
package com.project.operation.domain.service; |
||||
|
|
||||
|
import com.project.base.domain.result.Result; |
||||
|
import com.project.operation.domain.dto.OperationLogDTO; |
||||
|
import com.project.operation.domain.param.OperationLogParam; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
public interface SearchOperationLogDomainService { |
||||
|
|
||||
|
Result<List<OperationLogDTO>> list(OperationLogParam param); |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
package com.project.operation.domain.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.project.base.domain.result.Result; |
||||
|
import com.project.operation.domain.dto.OperationLogDTO; |
||||
|
import com.project.operation.domain.entity.OperationLogEntity; |
||||
|
import com.project.operation.domain.param.OperationLogParam; |
||||
|
import com.project.operation.domain.service.OperationLogBaseService; |
||||
|
import com.project.operation.domain.service.SearchOperationLogDomainService; |
||||
|
import org.apache.commons.lang3.StringUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
@Service |
||||
|
public class SearchOperationLogDomainServiceImpl implements SearchOperationLogDomainService { |
||||
|
@Autowired |
||||
|
private OperationLogBaseService operationLogBaseService; |
||||
|
|
||||
|
/** |
||||
|
* 查询日志 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Result<List<OperationLogDTO>> list(OperationLogParam param) { |
||||
|
QueryWrapper<OperationLogEntity> logQueryWrapper = new QueryWrapper<>(); |
||||
|
|
||||
|
if (StringUtils.isNotBlank(param.getAction())){ |
||||
|
logQueryWrapper.like("action",param.getAction()); |
||||
|
} |
||||
|
if (StringUtils.isNotBlank(param.getDescription())){ |
||||
|
logQueryWrapper.like("description",param.getDescription()); |
||||
|
} |
||||
|
if (param.getStartTime() != null) { |
||||
|
logQueryWrapper.ge("create_time",param.getStartTime()); |
||||
|
} |
||||
|
if (param.getEndTime() != null) { |
||||
|
logQueryWrapper.le("create_time",param.getEndTime()); |
||||
|
} |
||||
|
logQueryWrapper.orderByDesc("create_time"); |
||||
|
List<OperationLogEntity> entityList = operationLogBaseService.list(logQueryWrapper); |
||||
|
return Result.success(entityList.stream() |
||||
|
.map(entity -> entity.toDTO(OperationLogDTO::new)) |
||||
|
.collect(Collectors.toList())); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue