Commit 97631822 authored by zengtianlai3's avatar zengtianlai3

Merge remote-tracking branch 'origin/master'

parents 3afb5e5e 316c23de
package iot.sixiang.license.controller; package iot.sixiang.license.controller;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.vo.AlarmVo;
import iot.sixiang.license.service.AlarmService;
import org.springframework.beans.factory.annotation.Autowired;
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.List;
/** /**
* <p> * <p>
* 前端控制器 * 前端控制器
...@@ -14,8 +21,21 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -14,8 +21,21 @@ import org.springframework.web.bind.annotation.RestController;
* @since 2022-06-10 * @since 2022-06-10
*/ */
@RestController @RestController
@RequestMapping("/license/alarm") @RequestMapping("/iot_license/alarm")
public class AlarmController { public class AlarmController {
@Autowired
private AlarmService alarmService;
@PostMapping("add")
public void addAlarm(){
alarmService.addAlarm(1,"test","ssssssss");
}
@GetMapping("list")
public ResResult getAlarmList() {
List<AlarmVo> alarmList = alarmService.getAlarmList();
return ResResult.success().record(alarmList);
}
} }
package iot.sixiang.license.controller; package iot.sixiang.license.controller;
import org.springframework.web.bind.annotation.RequestMapping; import com.alibaba.fastjson.JSONObject;
import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.vo.AlarmVo;
import iot.sixiang.license.service.AlarmReadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RestController; import java.util.List;
/** /**
* <p> * <p>
...@@ -14,8 +20,31 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -14,8 +20,31 @@ import org.springframework.web.bind.annotation.RestController;
* @since 2022-06-10 * @since 2022-06-10
*/ */
@RestController @RestController
@RequestMapping("/license/alarm_read") @RequestMapping("/iot_license/alarm_read")
public class AlarmReadController { public class AlarmReadController {
@Autowired
private AlarmReadService alarmReadService;
@PostMapping("add")
public BaseResult addAlarmRead(@RequestBody JSONObject jsonObject){
int alarmId = jsonObject.getInteger("alarmId");
int typeId = jsonObject.getInteger("typeId");
String title = jsonObject.getString("title");
String content = jsonObject.getString("content");
int userId = jsonObject.getInteger("userId");
boolean res = alarmReadService.addAlarmRead(alarmId,typeId,title,content,userId);
if (res) {
return BaseResult.success();
} else {
return BaseResult.fail();
}
}
@GetMapping("list")
public ResResult getAlarmReadList() {
List<AlarmVo> alarmReadList = alarmReadService.getAlarmReadList();
return ResResult.success().record(alarmReadList);
}
} }
...@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController;
* @since 2022-06-10 * @since 2022-06-10
*/ */
@RestController @RestController
@RequestMapping("/license/alarm_type") @RequestMapping("/iot_license/alarm_type")
public class AlarmTypeController { public class AlarmTypeController {
} }
......
...@@ -7,7 +7,6 @@ import iot.sixiang.license.service.AlarmService; ...@@ -7,7 +7,6 @@ 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;
...@@ -43,9 +42,4 @@ public class OperateController { ...@@ -43,9 +42,4 @@ public class OperateController {
return ResResult.success().record(records); return ResResult.success().record(records);
} }
@PostMapping("alarm/add")
public void addlog(){
alarmService.addAlarm(1,"test","ssssssss");
}
} }
...@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableId; ...@@ -5,6 +5,9 @@ import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data @Data
@EqualsAndHashCode(callSuper = false) @EqualsAndHashCode(callSuper = false)
...@@ -14,5 +17,9 @@ public class Alarm { ...@@ -14,5 +17,9 @@ public class Alarm {
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Integer id; private Integer id;
private int typeId;
private String title;
private String content; private String content;
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
} }
package iot.sixiang.license.entity; package iot.sixiang.license.entity;
import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.IdType;
import java.io.Serializable; import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
/** /**
* <p> * <p>
...@@ -22,14 +26,20 @@ public class AlarmRead implements Serializable { ...@@ -22,14 +26,20 @@ public class AlarmRead implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 告警唯一id * 告警已读唯一id
*/ */
@TableId(type = IdType.AUTO)
private Integer id; private Integer id;
/**
* 告警id
*/
private int alarmId;
/** /**
* 告警类型id * 告警类型id
*/ */
private Integer typeId; private int typeId;
/** /**
* 告警标题 * 告警标题
...@@ -44,7 +54,8 @@ public class AlarmRead implements Serializable { ...@@ -44,7 +54,8 @@ public class AlarmRead implements Serializable {
/** /**
* 创建时间 * 创建时间
*/ */
private LocalDateTime createTime; @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** /**
* 阅读用户id * 阅读用户id
......
...@@ -2,11 +2,12 @@ package iot.sixiang.license.entity; ...@@ -2,11 +2,12 @@ package iot.sixiang.license.entity;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.io.Serializable;
/** /**
* <p> * <p>
* *
...@@ -36,7 +37,7 @@ public class AlarmType implements Serializable { ...@@ -36,7 +37,7 @@ public class AlarmType implements Serializable {
/** /**
* 等级描述 * 等级描述
*/ */
private String levleDescribe; private String levelDescribe;
} }
...@@ -2,12 +2,17 @@ package iot.sixiang.license.mapper; ...@@ -2,12 +2,17 @@ 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.model.vo.AlarmVo;
import java.util.List;
public interface AlarmMapper extends BaseMapper<Alarm> { public interface AlarmMapper extends BaseMapper<Alarm> {
boolean addAlarm(int typeId, String title, String content); boolean addAlarm(int typeId, String title, String content);
List<AlarmVo> getAlarmList();
// List<Alarm> getAlarmList(String id); // List<Alarm> getAlarmList(String id);
// //
// Apply getApplyByAppName(String id); // Apply getApplyByAppName(String id);
......
...@@ -2,6 +2,9 @@ package iot.sixiang.license.mapper; ...@@ -2,6 +2,9 @@ package iot.sixiang.license.mapper;
import iot.sixiang.license.entity.AlarmRead; import iot.sixiang.license.entity.AlarmRead;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import iot.sixiang.license.model.vo.AlarmVo;
import java.util.List;
/** /**
* <p> * <p>
...@@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/ */
public interface AlarmReadMapper extends BaseMapper<AlarmRead> { public interface AlarmReadMapper extends BaseMapper<AlarmRead> {
boolean addAlarmRead(int alarmId, int typeId, String title, String content, int userId);
List<AlarmVo> getAlarmReadList();
} }
package iot.sixiang.license.model.vo;
import iot.sixiang.license.entity.Alarm;
import lombok.Data;
/**
* Created by m33 on 2022/6/10 11:58
*/
@Data
public class AlarmVo extends Alarm {
private int level;
private String levelDescribe;
}
...@@ -2,6 +2,9 @@ package iot.sixiang.license.service; ...@@ -2,6 +2,9 @@ package iot.sixiang.license.service;
import iot.sixiang.license.entity.AlarmRead; import iot.sixiang.license.entity.AlarmRead;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import iot.sixiang.license.model.vo.AlarmVo;
import java.util.List;
/** /**
* <p> * <p>
...@@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.extension.service.IService; ...@@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
*/ */
public interface AlarmReadService extends IService<AlarmRead> { public interface AlarmReadService extends IService<AlarmRead> {
boolean addAlarmRead(int alarmId, int typeId, String title, String content, int userId);
List<AlarmVo> getAlarmReadList();
} }
...@@ -2,10 +2,15 @@ package iot.sixiang.license.service; ...@@ -2,10 +2,15 @@ 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.model.vo.AlarmVo;
import java.util.List;
public interface AlarmService extends IService<Alarm> { public interface AlarmService extends IService<Alarm> {
boolean addAlarm(int typeId, String title, String content); boolean addAlarm(int typeId, String title, String content);
List<AlarmVo> getAlarmList();
// PageInfoModel<AppVo> getAppList(int pageNo, int pageSize, String appName); // PageInfoModel<AppVo> getAppList(int pageNo, int pageSize, String appName);
} }
package iot.sixiang.license.service.impl; package iot.sixiang.license.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import iot.sixiang.license.entity.AlarmRead; import iot.sixiang.license.entity.AlarmRead;
import iot.sixiang.license.mapper.AlarmReadMapper; import iot.sixiang.license.mapper.AlarmReadMapper;
import iot.sixiang.license.model.vo.AlarmVo;
import iot.sixiang.license.service.AlarmReadService; import iot.sixiang.license.service.AlarmReadService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/** /**
* <p> * <p>
* 服务实现类 * 服务实现类
...@@ -17,4 +21,16 @@ import org.springframework.stereotype.Service; ...@@ -17,4 +21,16 @@ import org.springframework.stereotype.Service;
@Service @Service
public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead> implements AlarmReadService { public class AlarmReadServiceImpl extends ServiceImpl<AlarmReadMapper, AlarmRead> implements AlarmReadService {
@Resource
AlarmReadMapper alarmReadMapper;
@Override
public boolean addAlarmRead(int alarmId, int typeId, String title, String content, int userId) {
return alarmReadMapper.addAlarmRead(alarmId,typeId,title,content,userId);
}
@Override
public List<AlarmVo> getAlarmReadList() {
return alarmReadMapper.getAlarmReadList();
}
} }
...@@ -2,15 +2,13 @@ package iot.sixiang.license.service.impl; ...@@ -2,15 +2,13 @@ package iot.sixiang.license.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import iot.sixiang.license.entity.Alarm; import iot.sixiang.license.entity.Alarm;
import iot.sixiang.license.entity.Apply;
import iot.sixiang.license.handler.IotLicenseException;
import iot.sixiang.license.mapper.AlarmMapper; import iot.sixiang.license.mapper.AlarmMapper;
import iot.sixiang.license.mapper.ApplyMapper; import iot.sixiang.license.model.vo.AlarmVo;
import iot.sixiang.license.service.AlarmService; import iot.sixiang.license.service.AlarmService;
import iot.sixiang.license.service.ApplyService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List;
@Service @Service
public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements AlarmService { public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements AlarmService {
...@@ -21,4 +19,9 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements ...@@ -21,4 +19,9 @@ public class AlarmServiceImpl extends ServiceImpl<AlarmMapper, Alarm> implements
public boolean addAlarm(int typeId, String title, String content) { public boolean addAlarm(int typeId, String title, String content) {
return alarmMapper.addAlarm(typeId, title, content); return alarmMapper.addAlarm(typeId, title, content);
} }
@Override
public List<AlarmVo> getAlarmList() {
return alarmMapper.getAlarmList();
}
} }
...@@ -6,5 +6,8 @@ ...@@ -6,5 +6,8 @@
insert into alarm (type_id, title, content, create_time) values (#{typeId},#{title},#{content},now()); insert into alarm (type_id, title, content, create_time) values (#{typeId},#{title},#{content},now());
</insert> </insert>
<select id="getAlarmList" resultType="iot.sixiang.license.model.vo.AlarmVo">
SELECT al.id,al.type_id,al.title,content,DATE_FORMAT(al.create_time,'%Y-%m-%d %H:%I:%S') create_time,alt.level,level_describe FROM alarm AS al JOIN alarm_type AS alt ON al.type_id = alt.id
</select>
</mapper> </mapper>
...@@ -3,7 +3,11 @@ ...@@ -3,7 +3,11 @@
<mapper namespace="iot.sixiang.license.mapper.AlarmReadMapper"> <mapper namespace="iot.sixiang.license.mapper.AlarmReadMapper">
<insert id="addAlarmRead" parameterType="iot.sixiang.license.entity.AlarmRead"> <insert id="addAlarmRead" parameterType="iot.sixiang.license.entity.AlarmRead">
insert into alarm (type_id, title, content, create_time) values (#{typeId},#{title},#{content},now()); insert into alarm_read (alarm_id, type_id, title, content, create_time, user_id) values (#{alarmId},#{typeId},#{title},#{content},now(),#{userId});
</insert> </insert>
<select id="getAlarmReadList" resultType="iot.sixiang.license.entity.AlarmRead">
SELECT id,alarm_id,type_id,title,content,DATE_FORMAT(create_time,'%Y-%m-%d %H:%I:%S') create_time,us.user_id,user_name FROM alarm_read AS al JOIN user AS us ON us.user_id = al.user_id
</select>
</mapper> </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