增加管理员日志详情接口

This commit is contained in:
xxx 2023-09-05 16:23:53 +08:00
parent 61eb5be2ee
commit 06da295d58
4 changed files with 30 additions and 5 deletions

View File

@ -19,10 +19,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import xyz.playedu.common.annotation.BackendPermission;
import xyz.playedu.common.annotation.Log;
@ -31,6 +28,7 @@ import xyz.playedu.common.constant.BPermissionConstant;
import xyz.playedu.common.constant.BusinessTypeConstant;
import xyz.playedu.common.context.BCtx;
import xyz.playedu.common.domain.AdminLog;
import xyz.playedu.common.exception.ServiceException;
import xyz.playedu.common.service.AdminLogService;
import xyz.playedu.common.types.JsonResponse;
import xyz.playedu.common.types.paginate.AdminLogPaginateFiler;
@ -87,4 +85,19 @@ public class AdminLogController {
return JsonResponse.data(data);
}
@BackendPermission(slug = BPermissionConstant.ADMIN_LOG)
@GetMapping("/detail/{id}")
public JsonResponse detail(@PathVariable(name = "id") Integer id) {
Integer adminId = 0;
if (!backendBus.isSuperAdmin()) {
adminId = BCtx.getId();
}
AdminLog log = adminLogService.find(id, adminId);
if (log == null) {
throw new ServiceException("日志不存在");
}
return JsonResponse.data(log);
}
}

View File

@ -28,4 +28,6 @@ import xyz.playedu.common.types.paginate.PaginationResult;
*/
public interface AdminLogService extends IService<AdminLog> {
PaginationResult<AdminLog> paginate(int page, int size, AdminLogPaginateFiler filter);
AdminLog find(Integer id, Integer adminId);
}

View File

@ -44,4 +44,12 @@ public class AdminLogServiceImpl extends ServiceImpl<AdminLogMapper, AdminLog>
return pageResult;
}
@Override
public AdminLog find(Integer id, Integer adminId) {
if (adminId == 0) {
return getOne(query().getWrapper().eq("id", id));
}
return getOne(query().getWrapper().eq("id", id).eq("admin_id", adminId));
}
}

View File

@ -29,7 +29,9 @@
</sql>
<select id="paginate" resultType="xyz.playedu.common.domain.AdminLog">
SELECT `admin_logs`.*
SELECT `admin_logs`.`id`,`admin_logs`.`admin_id`,`admin_logs`.`admin_name`,`admin_logs`.`module`,`admin_logs`.`title`,
`admin_logs`.`opt`,`admin_logs`.`method`,`admin_logs`.`request_method`,`admin_logs`.`url`,`admin_logs`.`ip`,`admin_logs`.`param`,
`admin_logs`.`ip_area`,`admin_logs`.`created_at`
FROM `admin_logs`
<where>
<if test="adminId != null">