|
@@ -0,0 +1,60 @@
|
|
|
+package com.xy.service;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.xy.dto.DeviceLogDto;
|
|
|
+import com.xy.entity.DeviceLog;
|
|
|
+import com.xy.mapper.DeviceLogMapper;
|
|
|
+import com.xy.utils.MybatisPlusQuery;
|
|
|
+import com.xy.utils.PageBean;
|
|
|
+import com.xy.utils.R;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+
|
|
|
+import static com.xy.utils.PlusBeans.toIPage;
|
|
|
+import static com.xy.utils.PlusBeans.toPageBean;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 设备-日志 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author lijin
|
|
|
+ * @since 2023-03-16
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@AllArgsConstructor
|
|
|
+@Api(tags = "设备-日志")
|
|
|
+public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog> implements DeviceLogService {
|
|
|
+
|
|
|
+ @PostMapping("page")
|
|
|
+ @ApiOperation("分页查询")
|
|
|
+ public R<PageBean<DeviceLogDto.Vo>> page(@RequestBody DeviceLogDto.Page page) {
|
|
|
+ PageBean pageBean = page.getPage();
|
|
|
+ LambdaQueryWrapper<DeviceLog> lambdaQueryWrapper = new MybatisPlusQuery().eqWrapper(page, DeviceLog.class).build();
|
|
|
+ IPage<DeviceLog> iPage = page(toIPage(pageBean), lambdaQueryWrapper);
|
|
|
+ return R.ok(toPageBean(DeviceLogDto.Vo.class, iPage));
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("update")
|
|
|
+ @ApiOperation("修改")
|
|
|
+ public R update(@RequestBody @Validated DeviceLogDto.Update update) {
|
|
|
+ LambdaQueryWrapper<DeviceLog> logLambdaQueryWrapper = new LambdaQueryWrapper<DeviceLog>().eq(DeviceLog::getDeviceId, update.getDeviceId())
|
|
|
+ .orderByDesc(DeviceLog::getCreateTime)
|
|
|
+ .last("limit 1");
|
|
|
+ DeviceLog deviceLog = getOne(logLambdaQueryWrapper)
|
|
|
+ .setLogName(update.getLogName())
|
|
|
+ .setUpdateTime(LocalDateTime.now());
|
|
|
+ updateById(deviceLog);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+}
|