Browse Source

重构国际化,系统设备日志记录接口开发

master
caojianbin 8 months ago
parent
commit
e06ad222b5
  1. 16
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/annotation/FactoryLog.java
  2. 17
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/config/FeignConfiguration.java
  3. 39
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/FactoryLogInfoController.java
  4. 56
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/FactoryLogInfo.java
  5. 59
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/DeviceTimeSwitchApp.java
  6. 17
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/FactoryLogInfoMapper.java
  7. 17
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/api/DeviceTimeSwitchAppMapper.java
  8. 19
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/FactoryLogInfoService.java
  9. 18
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/DeviceTimeSwitchAppService.java
  10. 61
      ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/impl/FactoryLogInfoServiceImpl.java

16
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/annotation/FactoryLog.java

@ -0,0 +1,16 @@
package com.ecell.internationalize.system.annotation;
import com.ecell.internationalize.system.constant.DeviceModelConstants;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author borui
*/
@Target({ ElementType.PARAMETER, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
public @interface FactoryLog {
String unBingType() default DeviceModelConstants.ZERO;
}

17
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/config/FeignConfiguration.java

@ -0,0 +1,17 @@
package com.ecell.internationalize.system.config;
import com.ecell.internationalize.common.security.feign.FeignRequestInterceptor;
import feign.RequestInterceptor;
import org.springframework.context.annotation.Bean;
//@Configuration
public class FeignConfiguration {
@Bean("interceptor")
public RequestInterceptor requestInterceptor()
{
return new FeignRequestInterceptor();
}
}

39
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/controller/FactoryLogInfoController.java

@ -0,0 +1,39 @@
package com.ecell.internationalize.system.controller;
import com.ecell.internationalize.common.core.utils.locale.LocaleUtil;
import com.ecell.internationalize.common.core.web.domain.AjaxResult;
import com.ecell.internationalize.common.system.constant.FieldConstant;
import com.ecell.internationalize.system.entity.dto.ImeiLogPageDTO;
import com.ecell.internationalize.system.service.FactoryLogInfoService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author ${author}
* @since 2022-11-03
*/
@Api(value="解绑日志记录",tags={"解绑日志记录接口"})
@RestController
@RequestMapping("/factory-log-info")
public class FactoryLogInfoController {
@Autowired
private FactoryLogInfoService factoryLogInfoService;
/**
* 分页查询日志
* @param dto
* @return
*/
@PostMapping("/page/list")
public AjaxResult queryPageList(@RequestBody ImeiLogPageDTO dto){
return AjaxResult.success(LocaleUtil.getMessage(FieldConstant.MESSAGES_SUCCESS), factoryLogInfoService.queryByPageList(dto));
}
}

56
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/FactoryLogInfo.java

@ -0,0 +1,56 @@
package com.ecell.internationalize.system.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author ${author}
* @since 2022-11-03
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="FactoryLogInfo对象", description="")
public class FactoryLogInfo implements Serializable {
private static final long serialVersionUID=1L;
@ApiModelProperty(value = "id")
private String imeiDelId;
@ApiModelProperty(value = "ip")
private String ip;
@ApiModelProperty(value = "登录账号")
private String loginAccount;
@ApiModelProperty(value = "用户角色")
private String userRole;
@ApiModelProperty(value = "所属公司")
private String company;
@ApiModelProperty(value = "操作描述")
private String operationDescribe;
@ApiModelProperty(value = "是否删除(0.是,1.否 默认为1)")
private String delFlag;
@ApiModelProperty(value = "创建时间")
private Date createTime;
@ApiModelProperty(value = "解绑方式")
private String unbinding;
}

59
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/entity/api/DeviceTimeSwitchApp.java

@ -0,0 +1,59 @@
package com.ecell.internationalize.system.entity.api;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
* 定时开关机
* </p>
*
* @author ${author}
* @since 2022-09-21
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="DeviceTimeSwitchApp对象", description="定时开关机")
public class DeviceTimeSwitchApp implements Serializable {
private static final long serialVersionUID=1L;
@ApiModelProperty(example = "主键Id",hidden = true)
private String id;
@ApiModelProperty(example = "设备imei")
private String imei;
@ApiModelProperty(example = "开机时间")
private String startTime;
@ApiModelProperty(example = "关机时间")
private String endTime;
@ApiModelProperty(example = "功能是否启用 : 0:关闭, 1:打开")
private String status;
@ApiModelProperty(example = "创建人",hidden = true)
private String createUser;
@ApiModelProperty(example = "创建时间",hidden = true)
@TableField(value = "update_time",fill = FieldFill.INSERT)
private Date createTime;
@ApiModelProperty(example = "修改人",hidden = true)
private String updateUser;
@ApiModelProperty(example = "修改时间",hidden = true)
private Date updateTime;
}

17
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/FactoryLogInfoMapper.java

@ -0,0 +1,17 @@
package com.ecell.internationalize.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ecell.internationalize.system.entity.FactoryLogInfo;
/**
* <p>
* Mapper 接口
* </p>
*
* @author ${author}
* @since 2022-11-03
*/
public interface FactoryLogInfoMapper extends BaseMapper<FactoryLogInfo> {
}

17
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/mapper/api/DeviceTimeSwitchAppMapper.java

@ -0,0 +1,17 @@
package com.ecell.internationalize.system.mapper.api;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ecell.internationalize.system.entity.api.DeviceTimeSwitchApp;
/**
* <p>
* 定时开关机 Mapper 接口
* </p>
*
* @author ${author}
* @since 2022-09-21
*/
public interface DeviceTimeSwitchAppMapper extends BaseMapper<DeviceTimeSwitchApp> {
}

19
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/FactoryLogInfoService.java

@ -0,0 +1,19 @@
package com.ecell.internationalize.system.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ecell.internationalize.system.entity.FactoryLogInfo;
import com.ecell.internationalize.system.entity.dto.ImeiLogPageDTO;
/**
* <p>
* 服务类
* </p>
*
* @author ${author}
* @since 2022-11-03
*/
public interface FactoryLogInfoService extends IService<FactoryLogInfo> {
IPage queryByPageList(ImeiLogPageDTO dto);
}

18
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/api/DeviceTimeSwitchAppService.java

@ -0,0 +1,18 @@
package com.ecell.internationalize.system.service.api;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ecell.internationalize.system.entity.api.DeviceTimeSwitchApp;
/**
* <p>
* 定时开关机 服务类
* </p>
*
* @author ${author}
* @since 2022-09-21
*/
public interface DeviceTimeSwitchAppService extends IService<DeviceTimeSwitchApp> {
void sendToKafka(DeviceTimeSwitchApp deviceTimeSwitchApp);
}

61
ecell-internationalize/ecell-internationalize-system/src/main/java/com/ecell/internationalize/system/service/impl/FactoryLogInfoServiceImpl.java

@ -0,0 +1,61 @@
package com.ecell.internationalize.system.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ecell.internationalize.common.core.utils.StringUtils;
import com.ecell.internationalize.system.constant.DeviceModelConstants;
import com.ecell.internationalize.system.entity.FactoryLogInfo;
import com.ecell.internationalize.system.entity.dto.ImeiLogPageDTO;
import com.ecell.internationalize.system.mapper.FactoryLogInfoMapper;
import com.ecell.internationalize.system.service.FactoryLogInfoService;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author ${author}
* @since 2022-11-03
*/
@Service
public class FactoryLogInfoServiceImpl extends ServiceImpl<FactoryLogInfoMapper, FactoryLogInfo> implements FactoryLogInfoService {
@Override
public IPage queryByPageList(ImeiLogPageDTO dto) {
Page page =new Page(dto.getCurrent(),dto.getPageSize());
QueryWrapper wrapper = getQueryWrapper(dto);
return baseMapper.selectPage(page, wrapper);
}
/**
* 分页查询条件封装
* @param dto
* @return
*/
private QueryWrapper getQueryWrapper(ImeiLogPageDTO dto) {
QueryWrapper wrapper=new QueryWrapper();
if (StringUtils.isNotEmpty(dto.getIp())){
wrapper.like("ip", dto.getIp());
}
if (StringUtils.isNotEmpty(dto.getUserRole())){
wrapper.eq("user_role", dto.getUserRole());
}
if (StringUtils.isNotEmpty(dto.getLoginAccount())){
wrapper.eq("login_account", dto.getLoginAccount());
}
wrapper.eq("del_flag", DeviceModelConstants.ONE);
return wrapper;
}
@Async("threadPoolTaskExecutor")
public void saveDelImeiLog(FactoryLogInfo info) {
save(info);
}
}
Loading…
Cancel
Save