Commit 7aedf8ab authored by zengtianlai3's avatar zengtianlai3

增加运维相关的内容

parent 4a671a1b
...@@ -4,10 +4,12 @@ import org.mybatis.spring.annotation.MapperScan; ...@@ -4,10 +4,12 @@ import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan; import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
@ServletComponentScan(basePackages ="iot.sixiang.license") @ServletComponentScan(basePackages ="iot.sixiang.license")
@SpringBootApplication @SpringBootApplication
@EnableScheduling
@MapperScan(basePackages = "iot.sixiang.license.mapper") @MapperScan(basePackages = "iot.sixiang.license.mapper")
public class LicenseApplication { public class LicenseApplication {
......
package iot.sixiang.license.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author m33
* @since 2022-06-10
*/
@RestController
@RequestMapping("/license/alarm")
public class AlarmController {
}
package iot.sixiang.license.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author m33
* @since 2022-06-10
*/
@RestController
@RequestMapping("/license/alarm_read")
public class AlarmReadController {
}
package iot.sixiang.license.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author m33
* @since 2022-06-10
*/
@RestController
@RequestMapping("/license/alarm_type")
public class AlarmTypeController {
}
package iot.sixiang.license.controller; package iot.sixiang.license.controller;
import com.alibaba.fastjson.JSONObject;
import iot.sixiang.license.model.ResResult; import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.SamMonitor; import iot.sixiang.license.model.SamMonitor;
import iot.sixiang.license.operate.OperateManager; import iot.sixiang.license.operate.OperateManager;
...@@ -8,10 +7,10 @@ import iot.sixiang.license.service.AlarmService; ...@@ -8,10 +7,10 @@ import iot.sixiang.license.service.AlarmService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
...@@ -45,8 +44,8 @@ public class OperateController { ...@@ -45,8 +44,8 @@ public class OperateController {
} }
@GetMapping("alarm/add") @PostMapping("alarm/add")
public void addlog(){ public void addlog(){
alarmService.addAlarm("test"); alarmService.addAlarm(1,"test","ssssssss");
} }
} }
package iot.sixiang.license.entity;
import java.time.LocalDateTime;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author m33
* @since 2022-06-10
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class AlarmRead implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 告警唯一id
*/
private Integer id;
/**
* 告警类型id
*/
private Integer typeId;
/**
* 告警标题
*/
private String title;
/**
* 告警内容
*/
private String content;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 阅读用户id
*/
private Integer userId;
}
package iot.sixiang.license.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author m33
* @since 2022-06-10
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class AlarmType implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 告警类型id
*/
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
/**
* 等级
*/
private Integer level;
/**
* 等级描述
*/
private String levleDescribe;
}
...@@ -7,14 +7,13 @@ import iot.sixiang.license.model.ResResult; ...@@ -7,14 +7,13 @@ import iot.sixiang.license.model.ResResult;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import javax.servlet.*; import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.Map; import java.util.Map;
@Slf4j @Slf4j
@WebFilter(filterName = "jwtFilter", urlPatterns = "/iot_license/*") //@WebFilter(filterName = "jwtFilter", urlPatterns = "/iot_license/*")
public class JwtFilter implements Filter { public class JwtFilter implements Filter {
......
...@@ -2,22 +2,11 @@ package iot.sixiang.license.mapper; ...@@ -2,22 +2,11 @@ package iot.sixiang.license.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import iot.sixiang.license.entity.Alarm; import iot.sixiang.license.entity.Alarm;
import iot.sixiang.license.entity.Apply;
import iot.sixiang.license.model.vo.AppVo;
import java.util.List;
/**
* Title: AlarmMapper
* Description: TODO
*
* @author m33
* @version V1.0
* @date 2022-06-09
*/
public interface AlarmMapper extends BaseMapper<Alarm> { public interface AlarmMapper extends BaseMapper<Alarm> {
boolean addAlarm(String content); boolean addAlarm(int typeId, String title, String content);
// List<Alarm> getAlarmList(String id); // List<Alarm> getAlarmList(String id);
// //
......
package iot.sixiang.license.mapper;
import iot.sixiang.license.entity.AlarmRead;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author m33
* @since 2022-06-10
*/
public interface AlarmReadMapper extends BaseMapper<AlarmRead> {
}
package iot.sixiang.license.mapper;
import iot.sixiang.license.entity.AlarmType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author m33
* @since 2022-06-10
*/
public interface AlarmTypeMapper extends BaseMapper<AlarmType> {
}
...@@ -31,7 +31,6 @@ public class OperateClientHandler extends SimpleChannelInboundHandler<Object> { ...@@ -31,7 +31,6 @@ public class OperateClientHandler extends SimpleChannelInboundHandler<Object> {
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
SocketChannel channel = (SocketChannel) ctx.channel();
InetSocketAddress socketAddr = (InetSocketAddress) ctx.channel().remoteAddress(); InetSocketAddress socketAddr = (InetSocketAddress) ctx.channel().remoteAddress();
String remoteIp = socketAddr.getHostString(); String remoteIp = socketAddr.getHostString();
......
...@@ -2,7 +2,6 @@ package iot.sixiang.license.operate; ...@@ -2,7 +2,6 @@ package iot.sixiang.license.operate;
import iot.sixiang.license.entity.Server; import iot.sixiang.license.entity.Server;
import iot.sixiang.license.model.SamMonitor; import iot.sixiang.license.model.SamMonitor;
import iot.sixiang.license.model.vo.DeviceVo;
import iot.sixiang.license.service.ServerService; import iot.sixiang.license.service.ServerService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -51,7 +50,7 @@ public class OperateManager { ...@@ -51,7 +50,7 @@ public class OperateManager {
} }
private void createProxyClient() { public void createProxyClient() {
Iterator<Map.Entry<String, Server>> iterator = allServers.entrySet().iterator(); Iterator<Map.Entry<String, Server>> iterator = allServers.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry<String, Server> next = iterator.next(); Map.Entry<String, Server> next = iterator.next();
......
package iot.sixiang.license.service;
import iot.sixiang.license.entity.AlarmRead;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author m33
* @since 2022-06-10
*/
public interface AlarmReadService extends IService<AlarmRead> {
}
...@@ -2,21 +2,10 @@ package iot.sixiang.license.service; ...@@ -2,21 +2,10 @@ package iot.sixiang.license.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import iot.sixiang.license.entity.Alarm; import iot.sixiang.license.entity.Alarm;
import iot.sixiang.license.entity.Apply;
import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.vo.AppVo;
/**
* Title: AlarmService
* Description: TODO
*
* @author m33
* @version V1.0
* @date 2022-06-09
*/
public interface AlarmService extends IService<Alarm> { public interface AlarmService extends IService<Alarm> {
boolean addAlarm(String content); boolean addAlarm(int typeId, String title, String content);
// PageInfoModel<AppVo> getAppList(int pageNo, int pageSize, String appName); // PageInfoModel<AppVo> getAppList(int pageNo, int pageSize, String appName);
} }
package iot.sixiang.license.service;
import iot.sixiang.license.entity.AlarmType;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author m33
* @since 2022-06-10
*/
public interface AlarmTypeService extends IService<AlarmType> {
}
package iot.sixiang.license.service.impl;
import iot.sixiang.license.entity.AlarmRead;
import iot.sixiang.license.mapper.AlarmReadMapper;
import iot.sixiang.license.service.AlarmReadService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author m33
* @since 2022-06-10
*/
@Service
public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead> implements AlarmReadService {
}
...@@ -18,8 +18,7 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements ...@@ -18,8 +18,7 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements
AlarmMapper alarmMapper; AlarmMapper alarmMapper;
@Override @Override
public boolean addAlarm(String content) { public boolean addAlarm(int typeId, String title, String content) {
return alarmMapper.addAlarm(content); return alarmMapper.addAlarm(typeId, title, content);
} }
} }
package iot.sixiang.license.service.impl;
import iot.sixiang.license.entity.AlarmType;
import iot.sixiang.license.mapper.AlarmTypeMapper;
import iot.sixiang.license.service.AlarmTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author m33
* @since 2022-06-10
*/
@Service
public class AlarmTypeServiceImpl extends ServiceImpl<AlarmTypeMapper, AlarmType> implements AlarmTypeService {
}
...@@ -47,7 +47,7 @@ public class CodeGenerator { ...@@ -47,7 +47,7 @@ public class CodeGenerator {
// 5、策略配置 // 5、策略配置
StrategyConfig strategy = new StrategyConfig(); StrategyConfig strategy = new StrategyConfig();
strategy.setInclude("apply"); strategy.setInclude("alarm_type");
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略 strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
strategy.setTablePrefix(pc.getModuleName() + "_"); //生成实体时去掉表前缀 strategy.setTablePrefix(pc.getModuleName() + "_"); //生成实体时去掉表前缀
......
package iot.sixiang.license.util;
import iot.sixiang.license.operate.OperateManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
/**
* Created by m33 on 2022/6/10 10:30
*/
@Component
public class OperateSchedu {
@Autowired
private OperateManager operateManager;
@Scheduled(cron = "0 0 0/1 * * ?")
public void scheduled(){
operateManager.createProxyClient();
}
}
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
<mapper namespace="iot.sixiang.license.mapper.AlarmMapper"> <mapper namespace="iot.sixiang.license.mapper.AlarmMapper">
<insert id="addAlarm" parameterType="iot.sixiang.license.entity.Alarm"> <insert id="addAlarm" parameterType="iot.sixiang.license.entity.Alarm">
insert into alarm(content) values (#{content}) insert into alarm (type_id, title, content, create_time) values (#{typeId},#{title},#{content},now());
</insert> </insert>
</mapper> </mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="iot.sixiang.license.mapper.AlarmReadMapper">
<insert id="addAlarmRead" parameterType="iot.sixiang.license.entity.AlarmRead">
insert into alarm (type_id, title, content, create_time) values (#{typeId},#{title},#{content},now());
</insert>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="iot.sixiang.license.mapper.AlarmTypeMapper">
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment