Commit a11d0a35 by wuwenlong

Merge remote-tracking branch 'origin/main'

parents ceb2132d 1ce984ba
package share.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.enums.BusinessType;
import share.system.domain.DeviceLog;
import share.system.service.DeviceLogService;
import share.common.utils.poi.ExcelUtil;
import share.common.core.page.TableDataInfo;
/**
* 设备操作日志Controller
*
* @author wuwenlong
* @date 2023-11-03
*/
@RestController
@RequestMapping("/system/log")
public class DeviceLogController extends BaseController
{
@Autowired
private DeviceLogService deviceLogService;
/**
* 查询设备操作日志列表
*/
@PreAuthorize("@ss.hasPermi('system:log:list')")
@GetMapping("/list")
public TableDataInfo list(DeviceLog deviceLog)
{
startPage();
List<DeviceLog> list = deviceLogService.selectDeviceLogList(deviceLog);
return getDataTable(list);
}
/**
* 导出设备操作日志列表
*/
@PreAuthorize("@ss.hasPermi('system:log:export')")
@Log(title = "设备操作日志", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DeviceLog deviceLog)
{
List<DeviceLog> list = deviceLogService.selectDeviceLogList(deviceLog);
ExcelUtil<DeviceLog> util = new ExcelUtil<DeviceLog>(DeviceLog.class);
util.exportExcel(response, list, "设备操作日志数据");
}
/**
* 获取设备操作日志详细信息
*/
@PreAuthorize("@ss.hasPermi('system:log:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(deviceLogService.selectDeviceLogById(id));
}
/**
* 新增设备操作日志
*/
@PreAuthorize("@ss.hasPermi('system:log:add')")
@Log(title = "设备操作日志", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DeviceLog deviceLog)
{
return toAjax(deviceLogService.insertDeviceLog(deviceLog));
}
/**
* 修改设备操作日志
*/
@PreAuthorize("@ss.hasPermi('system:log:edit')")
@Log(title = "设备操作日志", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DeviceLog deviceLog)
{
return toAjax(deviceLogService.updateDeviceLog(deviceLog));
}
/**
* 删除设备操作日志
*/
@PreAuthorize("@ss.hasPermi('system:log:remove')")
@Log(title = "设备操作日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(deviceLogService.deleteDeviceLogByIds(ids));
}
}
package share.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import lombok.Data;
/**
* 设备操作日志对象 s_device_log
*
* @author wuwenlong
* @date 2023-11-03
*/
@Data
public class DeviceLog extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 设备mac */
@Excel(name = "设备mac")
private String devMac;
/** 设备id */
@Excel(name = "设备id")
private String devId;
/** 请求的序列号 */
@Excel(name = "请求的序列号")
private String seq;
/** 消息类型:1-下发,2-上报 */
@Excel(name = "消息类型:1-下发,2-上报")
private String mqttType;
/** 消息描述:开门、开灯、网关设备绑定等 */
@Excel(name = "消息描述:开门、开灯、网关设备绑定等")
private String mqttDescribe;
/** 消息主体参数 */
@Excel(name = "消息主体参数")
private String payload;
/** 消息主题 */
@Excel(name = "消息主题")
private String topic;
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("devMac", getDevMac())
.append("devId", getDevId())
.append("seq", getSeq())
.append("mqttType", getMqttType())
.append("mqttDescribe", getMqttDescribe())
.append("payload", getPayload())
.append("topic", getTopic())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.append("remark", getRemark())
.toString();
}
}
package share.system.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.DeviceLog;
/**
* 设备操作日志Mapper接口
*
* @author wuwenlong
* @date 2023-11-03
*/
public interface DeviceLogMapper extends BaseMapper<DeviceLog>
{
/**
* 查询设备操作日志
*
* @param id 设备操作日志主键
* @return 设备操作日志
*/
public DeviceLog selectDeviceLogById(Long id);
/**
* 查询设备操作日志列表
*
* @param deviceLog 设备操作日志
* @return 设备操作日志集合
*/
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog);
/**
* 新增设备操作日志
*
* @param deviceLog 设备操作日志
* @return 结果
*/
public int insertDeviceLog(DeviceLog deviceLog);
/**
* 修改设备操作日志
*
* @param deviceLog 设备操作日志
* @return 结果
*/
public int updateDeviceLog(DeviceLog deviceLog);
/**
* 删除设备操作日志
*
* @param id 设备操作日志主键
* @return 结果
*/
public int deleteDeviceLogById(Long id);
/**
* 批量删除设备操作日志
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteDeviceLogByIds(Long[] ids);
}
package share.system.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.DeviceLog;
/**
* 设备操作日志Service接口
*
* @author wuwenlong
* @date 2023-11-03
*/
public interface DeviceLogService extends IService<DeviceLog>
{
/**
* 查询设备操作日志
*
* @param id 设备操作日志主键
* @return 设备操作日志
*/
public DeviceLog selectDeviceLogById(Long id);
/**
* 查询设备操作日志列表
*
* @param deviceLog 设备操作日志
* @return 设备操作日志集合
*/
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog);
/**
* 新增设备操作日志
*
* @param deviceLog 设备操作日志
* @return 结果
*/
public int insertDeviceLog(DeviceLog deviceLog);
/**
* 修改设备操作日志
*
* @param deviceLog 设备操作日志
* @return 结果
*/
public int updateDeviceLog(DeviceLog deviceLog);
/**
* 批量删除设备操作日志
*
* @param ids 需要删除的设备操作日志主键集合
* @return 结果
*/
public int deleteDeviceLogByIds(Long[] ids);
/**
* 删除设备操作日志信息
*
* @param id 设备操作日志主键
* @return 结果
*/
public int deleteDeviceLogById(Long id);
}
package share.system.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import share.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.system.mapper.DeviceLogMapper;
import share.system.domain.DeviceLog;
import share.system.service.DeviceLogService;
/**
* 设备操作日志Service业务层处理
*
* @author wuwenlong
* @date 2023-11-03
*/
@Service
public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog> implements DeviceLogService
{
@Autowired
private DeviceLogMapper deviceLogMapper;
/**
* 查询设备操作日志
*
* @param id 设备操作日志主键
* @return 设备操作日志
*/
@Override
public DeviceLog selectDeviceLogById(Long id)
{
return deviceLogMapper.selectDeviceLogById(id);
}
/**
* 查询设备操作日志列表
*
* @param deviceLog 设备操作日志
* @return 设备操作日志
*/
@Override
public List<DeviceLog> selectDeviceLogList(DeviceLog deviceLog)
{
return deviceLogMapper.selectDeviceLogList(deviceLog);
}
/**
* 新增设备操作日志
*
* @param deviceLog 设备操作日志
* @return 结果
*/
@Override
public int insertDeviceLog(DeviceLog deviceLog)
{
deviceLog.setCreateTime(DateUtils.getNowDate());
return deviceLogMapper.insertDeviceLog(deviceLog);
}
/**
* 修改设备操作日志
*
* @param deviceLog 设备操作日志
* @return 结果
*/
@Override
public int updateDeviceLog(DeviceLog deviceLog)
{
deviceLog.setUpdateTime(DateUtils.getNowDate());
return deviceLogMapper.updateDeviceLog(deviceLog);
}
/**
* 批量删除设备操作日志
*
* @param ids 需要删除的设备操作日志主键
* @return 结果
*/
@Override
public int deleteDeviceLogByIds(Long[] ids)
{
return deviceLogMapper.deleteDeviceLogByIds(ids);
}
/**
* 删除设备操作日志信息
*
* @param id 设备操作日志主键
* @return 结果
*/
@Override
public int deleteDeviceLogById(Long id)
{
return deviceLogMapper.deleteDeviceLogById(id);
}
}
<?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="share.system.mapper.DeviceLogMapper">
<resultMap type="DeviceLog" id="DeviceLogResult">
<result property="id" column="id" />
<result property="devMac" column="dev_mac" />
<result property="devId" column="dev_id" />
<result property="seq" column="seq" />
<result property="mqttType" column="mqtt_type" />
<result property="mqttDescribe" column="mqtt_describe" />
<result property="payload" column="payload" />
<result property="topic" column="topic" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
</resultMap>
<sql id="selectDeviceLogVo">
select id, dev_mac, dev_id, seq, mqtt_type, mqtt_describe, payload, topic, create_by, create_time, update_by, update_time, remark from s_device_log
</sql>
<select id="selectDeviceLogList" parameterType="DeviceLog" resultMap="DeviceLogResult">
<include refid="selectDeviceLogVo"/>
<where>
<if test="devMac != null and devMac != ''"> and dev_mac = #{devMac}</if>
<if test="devId != null and devId != ''"> and dev_id = #{devId}</if>
<if test="seq != null and seq != ''"> and seq = #{seq}</if>
<if test="mqttType != null and mqttType != ''"> and mqtt_type = #{mqttType}</if>
<if test="mqttDescribe != null and mqttDescribe != ''"> and mqtt_describe = #{mqttDescribe}</if>
<if test="payload != null and payload != ''"> and payload = #{payload}</if>
<if test="topic != null and topic != ''"> and topic = #{topic}</if>
</where>
</select>
<select id="selectDeviceLogById" parameterType="Long" resultMap="DeviceLogResult">
<include refid="selectDeviceLogVo"/>
where id = #{id}
</select>
<insert id="insertDeviceLog" parameterType="DeviceLog" useGeneratedKeys="true" keyProperty="id">
insert into s_device_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="devMac != null">dev_mac,</if>
<if test="devId != null">dev_id,</if>
<if test="seq != null">seq,</if>
<if test="mqttType != null">mqtt_type,</if>
<if test="mqttDescribe != null">mqtt_describe,</if>
<if test="payload != null">payload,</if>
<if test="topic != null">topic,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="remark != null">remark,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="devMac != null">#{devMac},</if>
<if test="devId != null">#{devId},</if>
<if test="seq != null">#{seq},</if>
<if test="mqttType != null">#{mqttType},</if>
<if test="mqttDescribe != null">#{mqttDescribe},</if>
<if test="payload != null">#{payload},</if>
<if test="topic != null">#{topic},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="remark != null">#{remark},</if>
</trim>
</insert>
<update id="updateDeviceLog" parameterType="DeviceLog">
update s_device_log
<trim prefix="SET" suffixOverrides=",">
<if test="devMac != null">dev_mac = #{devMac},</if>
<if test="devId != null">dev_id = #{devId},</if>
<if test="seq != null">seq = #{seq},</if>
<if test="mqttType != null">mqtt_type = #{mqttType},</if>
<if test="mqttDescribe != null">mqtt_describe = #{mqttDescribe},</if>
<if test="payload != null">payload = #{payload},</if>
<if test="topic != null">topic = #{topic},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="remark != null">remark = #{remark},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteDeviceLogById" parameterType="Long">
delete from s_device_log where id = #{id}
</delete>
<delete id="deleteDeviceLogByIds" parameterType="String">
delete from s_device_log where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
\ No newline at end of file
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