Kaynağa Gözat

feat: front device login page and http api

lihao16 6 ay önce
ebeveyn
işleme
c164806f19

+ 105 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/controller/SmsbDeviceLoginController.java

@@ -0,0 +1,105 @@
+package com.inspur.device.controller;
+
+import java.util.List;
+
+import com.inspur.device.domain.bo.SmsbDeviceLoginBo;
+import com.inspur.device.domain.vo.SmsbDeviceLoginVo;
+import com.inspur.device.service.ISmsbDeviceLoginService;
+import lombok.RequiredArgsConstructor;
+import jakarta.servlet.http.HttpServletResponse;
+import jakarta.validation.constraints.*;
+import cn.dev33.satoken.annotation.SaCheckPermission;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.validation.annotation.Validated;
+import org.dromara.common.idempotent.annotation.RepeatSubmit;
+import org.dromara.common.log.annotation.Log;
+import org.dromara.common.web.core.BaseController;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.core.domain.R;
+import org.dromara.common.core.validate.AddGroup;
+import org.dromara.common.core.validate.EditGroup;
+import org.dromara.common.log.enums.BusinessType;
+import org.dromara.common.excel.utils.ExcelUtil;
+
+/**
+ * 设备登录
+ *
+ * @author Hao Li
+ * @date 2025-04-28
+ */
+@Validated
+@RequiredArgsConstructor
+@RestController
+@RequestMapping("/smsb/device/login")
+public class SmsbDeviceLoginController extends BaseController {
+
+    private final ISmsbDeviceLoginService smsbDeviceLoginService;
+
+    /**
+     * 查询设备登录列表
+     */
+    @SaCheckPermission("device:login:list")
+    @GetMapping("/list")
+    public TableDataInfo<SmsbDeviceLoginVo> list(SmsbDeviceLoginBo bo, PageQuery pageQuery) {
+        return smsbDeviceLoginService.queryPageList(bo, pageQuery);
+    }
+
+    /**
+     * 导出设备登录列表
+     */
+    @SaCheckPermission("device:login:export")
+    @Log(title = "设备登录", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(SmsbDeviceLoginBo bo, HttpServletResponse response) {
+        List<SmsbDeviceLoginVo> list = smsbDeviceLoginService.queryList(bo);
+        ExcelUtil.exportExcel(list, "设备登录", SmsbDeviceLoginVo.class, response);
+    }
+
+    /**
+     * 获取设备登录详细信息
+     *
+     * @param id 主键
+     */
+    @SaCheckPermission("device:login:query")
+    @GetMapping("/{id}")
+    public R<SmsbDeviceLoginVo> getInfo(@NotNull(message = "主键不能为空")
+                                        @PathVariable Long id) {
+        return R.ok(smsbDeviceLoginService.queryById(id));
+    }
+
+    /**
+     * 新增设备登录
+     */
+    @SaCheckPermission("device:deviceLogin:add")
+    @Log(title = "设备登录", businessType = BusinessType.INSERT)
+    @RepeatSubmit()
+    @PostMapping()
+    public R<Void> add(@Validated(AddGroup.class) @RequestBody SmsbDeviceLoginBo bo) {
+        return toAjax(smsbDeviceLoginService.insertByBo(bo));
+    }
+
+    /**
+     * 修改设备登录
+     */
+    @SaCheckPermission("device:login:edit")
+    @Log(title = "设备登录", businessType = BusinessType.UPDATE)
+    @RepeatSubmit()
+    @PutMapping()
+    public R<Void> edit(@Validated(EditGroup.class) @RequestBody SmsbDeviceLoginBo bo) {
+        return toAjax(smsbDeviceLoginService.updateByBo(bo));
+    }
+
+    /**
+     * 删除设备登录
+     *
+     * @param ids 主键串
+     */
+    @SaCheckPermission("device:login:remove")
+    @Log(title = "设备登录", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public R<Void> remove(@NotEmpty(message = "主键不能为空")
+                          @PathVariable Long[] ids) {
+        return toAjax(smsbDeviceLoginService.deleteWithValidByIds(List.of(ids), true));
+    }
+}

+ 70 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/domain/SmsbDeviceLogin.java

@@ -0,0 +1,70 @@
+package com.inspur.device.domain;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+
+import java.io.Serial;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 设备登录对象 smsb_device_login
+ *
+ * @author Hao Li
+ * @date 2025-04-28
+ */
+@Data
+@TableName("smsb_device_login")
+public class SmsbDeviceLogin {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    @TableId(value = "id")
+    private Long id;
+
+    /**
+     * 请求标识
+     */
+    private String reqIdentifier;
+
+    /**
+     * 请求IP
+     */
+    private String reqIp;
+
+    /**
+     * 设备标识
+     */
+    private String identifier;
+
+    /**
+     * 登录结果 smsb_device_login_result
+     */
+    private Integer loginResult;
+
+    /**
+     * 创建时间
+     */
+    @TableField(fill = FieldFill.INSERT)
+    private Date createTime;
+
+    /**
+     * 请求参数
+     */
+    @JsonInclude(JsonInclude.Include.NON_EMPTY)
+    @TableField(exist = false)
+    private Map<String, Object> params = new HashMap<>();
+
+
+}

+ 41 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/domain/bo/SmsbDeviceLoginBo.java

@@ -0,0 +1,41 @@
+package com.inspur.device.domain.bo;
+
+import com.inspur.device.domain.SmsbDeviceLogin;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import org.dromara.common.mybatis.core.domain.BaseEntity;
+
+/**
+ * 设备登录业务对象 smsb_device_login
+ *
+ * @author Hao Li
+ * @date 2025-04-28
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+@AutoMapper(target = SmsbDeviceLogin.class, reverseConvertGenerate = false)
+public class SmsbDeviceLoginBo extends BaseEntity {
+
+    private Long id;
+
+    /**
+     * 请求标识
+     */
+    private String reqIdentifier;
+
+    /**
+     * 请求IP
+     */
+    private String reqIp;
+
+    /**
+     * 设备标识
+     */
+    private String identifier;
+
+    /**
+     * 登录结果smsb_device_login_result
+     */
+    private Long loginResult;
+}

+ 87 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/domain/vo/SmsbDeviceLoginVo.java

@@ -0,0 +1,87 @@
+package com.inspur.device.domain.vo;
+
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.inspur.device.domain.SmsbDeviceLogin;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
+import org.dromara.common.excel.annotation.ExcelDictFormat;
+import org.dromara.common.excel.convert.ExcelDictConvert;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * 设备登录视图对象 smsb_device_login
+ *
+ * @author Hao Li
+ * @date 2025-04-28
+ */
+@Data
+@ExcelIgnoreUnannotated
+@AutoMapper(target = SmsbDeviceLogin.class)
+public class SmsbDeviceLoginVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 主键ID
+     */
+    @ExcelProperty(value = "主键ID")
+    private Long id;
+
+    /**
+     * 请求标识
+     */
+    @ExcelProperty(value = "请求标识")
+    private String reqIdentifier;
+
+    /**
+     * 请求IP
+     */
+    @ExcelProperty(value = "请求IP")
+    private String reqIp;
+
+    /**
+     * 设备标识
+     */
+    @ExcelProperty(value = "设备标识")
+    private String identifier;
+
+    /**
+     * 登录结果smsb_device_login_result
+     */
+    @ExcelProperty(value = "登录结果smsb_device_login_result", converter = ExcelDictConvert.class)
+    @ExcelDictFormat(dictType = "smsb_device_login_result")
+    private Long loginResult;
+
+    /**
+     * 登录时间
+     */
+    @ExcelProperty(value = "登录时间")
+    private Date createTime;
+
+    /**
+     * 设备名称
+     */
+    @ExcelProperty(value = "设备名称")
+    private String deviceName;
+
+
+    /**
+     * sn号
+     */
+    @ExcelProperty(value = "sn号")
+    private String serialNumber;
+
+    /**
+     * mac号
+     */
+    @ExcelProperty(value = "mac号")
+    private String mac;
+
+
+}

+ 19 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/mapper/SmsbDeviceLoginMapper.java

@@ -0,0 +1,19 @@
+package com.inspur.device.mapper;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.inspur.device.domain.SmsbDeviceLogin;
+import com.inspur.device.domain.bo.SmsbDeviceLoginBo;
+import com.inspur.device.domain.vo.SmsbDeviceLoginVo;
+import org.apache.ibatis.annotations.Param;
+import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
+
+/**
+ * 设备登录Mapper接口
+ *
+ * @author Hao Li
+ * @date 2025-04-28
+ */
+public interface SmsbDeviceLoginMapper extends BaseMapperPlus<SmsbDeviceLogin, SmsbDeviceLoginVo> {
+
+    Page<SmsbDeviceLoginVo> selectPageVoList(@Param("page") Page<SmsbDeviceLogin> page, @Param("bo") SmsbDeviceLoginBo bo);
+}

+ 78 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/service/ISmsbDeviceLoginService.java

@@ -0,0 +1,78 @@
+package com.inspur.device.service;
+
+import com.inspur.device.domain.bo.HttpHeartbeatReq;
+import com.inspur.device.domain.bo.SmsbDeviceLoginBo;
+import com.inspur.device.domain.vo.HttpHeartbeatRspVo;
+import com.inspur.device.domain.vo.SmsbDeviceLoginVo;
+import org.dromara.common.core.domain.R;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * 设备登录Service接口
+ *
+ * @author Hao Li
+ * @date 2025-04-28
+ */
+public interface ISmsbDeviceLoginService {
+
+    /**
+     * 查询设备登录
+     *
+     * @param id 主键
+     * @return 设备登录
+     */
+    SmsbDeviceLoginVo queryById(Long id);
+
+    /**
+     * 分页查询设备登录列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 设备登录分页列表
+     */
+    TableDataInfo<SmsbDeviceLoginVo> queryPageList(SmsbDeviceLoginBo bo, PageQuery pageQuery);
+
+    /**
+     * 查询符合条件的设备登录列表
+     *
+     * @param bo 查询条件
+     * @return 设备登录列表
+     */
+    List<SmsbDeviceLoginVo> queryList(SmsbDeviceLoginBo bo);
+
+    /**
+     * 新增设备登录
+     *
+     * @param bo 设备登录
+     * @return 是否新增成功
+     */
+    Boolean insertByBo(SmsbDeviceLoginBo bo);
+
+    /**
+     * 修改设备登录
+     *
+     * @param bo 设备登录
+     * @return 是否修改成功
+     */
+    Boolean updateByBo(SmsbDeviceLoginBo bo);
+
+    /**
+     * 校验并批量删除设备登录信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
+
+    /**
+     * 前端设备登录
+     * @param requestParam
+     * @return
+     */
+    R<HttpHeartbeatRspVo> deviceLogin(HttpHeartbeatReq requestParam);
+}

+ 181 - 0
smsb-modules/smsb-device/src/main/java/com/inspur/device/service/impl/SmsbDeviceLoginServiceImpl.java

@@ -0,0 +1,181 @@
+package com.inspur.device.service.impl;
+
+import cn.hutool.json.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.inspur.device.domain.SmsbDeviceLogin;
+import com.inspur.device.domain.bo.HttpHeartbeatReq;
+import com.inspur.device.domain.bo.SmsbDeviceLoginBo;
+import com.inspur.device.domain.constants.DeviceConstants;
+import com.inspur.device.domain.vo.HttpHeartbeatRspVo;
+import com.inspur.device.domain.vo.SmsbDeviceLoginVo;
+import com.inspur.device.domain.vo.SmsbDeviceVo;
+import com.inspur.device.mapper.SmsbDeviceLoginMapper;
+import com.inspur.device.service.ISmsbDeviceLoginService;
+import com.inspur.device.service.ISmsbDeviceService;
+import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.domain.R;
+import org.dromara.common.core.utils.MapstructUtils;
+import org.dromara.common.core.utils.StringUtils;
+import org.dromara.common.mybatis.core.page.PageQuery;
+import org.dromara.common.mybatis.core.page.TableDataInfo;
+import org.dromara.common.redis.utils.RedisUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+/**
+ * 设备登录Service业务层处理
+ *
+ * @author Hao Li
+ * @date 2025-04-28
+ */
+@RequiredArgsConstructor
+@Service
+public class SmsbDeviceLoginServiceImpl implements ISmsbDeviceLoginService {
+
+    private final SmsbDeviceLoginMapper baseMapper;
+
+    private final ISmsbDeviceService smsbDeviceService;
+
+    /**
+     * 查询设备登录
+     *
+     * @param id 主键
+     * @return 设备登录
+     */
+    @Override
+    public SmsbDeviceLoginVo queryById(Long id) {
+        return baseMapper.selectVoById(id);
+    }
+
+    /**
+     * 分页查询设备登录列表
+     *
+     * @param bo        查询条件
+     * @param pageQuery 分页参数
+     * @return 设备登录分页列表
+     */
+    @Override
+    public TableDataInfo<SmsbDeviceLoginVo> queryPageList(SmsbDeviceLoginBo bo, PageQuery pageQuery) {
+        // LambdaQueryWrapper<SmsbDeviceLogin> lqw = buildQueryWrapper(bo);
+
+        Page<SmsbDeviceLoginVo> result = baseMapper.selectPageVoList(pageQuery.build(), bo);
+        return TableDataInfo.build(result);
+    }
+
+    /**
+     * 查询符合条件的设备登录列表
+     *
+     * @param bo 查询条件
+     * @return 设备登录列表
+     */
+    @Override
+    public List<SmsbDeviceLoginVo> queryList(SmsbDeviceLoginBo bo) {
+        LambdaQueryWrapper<SmsbDeviceLogin> lqw = buildQueryWrapper(bo);
+        return baseMapper.selectVoList(lqw);
+    }
+
+    private LambdaQueryWrapper<SmsbDeviceLogin> buildQueryWrapper(SmsbDeviceLoginBo bo) {
+        Map<String, Object> params = bo.getParams();
+        LambdaQueryWrapper<SmsbDeviceLogin> lqw = Wrappers.lambdaQuery();
+        lqw.eq(StringUtils.isNotBlank(bo.getReqIdentifier()), SmsbDeviceLogin::getReqIdentifier, bo.getReqIdentifier());
+        lqw.eq(StringUtils.isNotBlank(bo.getReqIp()), SmsbDeviceLogin::getReqIp, bo.getReqIp());
+        lqw.eq(StringUtils.isNotBlank(bo.getIdentifier()), SmsbDeviceLogin::getIdentifier, bo.getIdentifier());
+        lqw.eq(bo.getLoginResult() != null, SmsbDeviceLogin::getLoginResult, bo.getLoginResult());
+        return lqw;
+    }
+
+    /**
+     * 新增设备登录
+     *
+     * @param bo 设备登录
+     * @return 是否新增成功
+     */
+    @Override
+    public Boolean insertByBo(SmsbDeviceLoginBo bo) {
+        SmsbDeviceLogin add = MapstructUtils.convert(bo, SmsbDeviceLogin.class);
+        validEntityBeforeSave(add);
+        boolean flag = baseMapper.insert(add) > 0;
+        if (flag) {
+            bo.setId(add.getId());
+        }
+        return flag;
+    }
+
+    /**
+     * 修改设备登录
+     *
+     * @param bo 设备登录
+     * @return 是否修改成功
+     */
+    @Override
+    public Boolean updateByBo(SmsbDeviceLoginBo bo) {
+        SmsbDeviceLogin update = MapstructUtils.convert(bo, SmsbDeviceLogin.class);
+        validEntityBeforeSave(update);
+        return baseMapper.updateById(update) > 0;
+    }
+
+    /**
+     * 保存前的数据校验
+     */
+    private void validEntityBeforeSave(SmsbDeviceLogin entity) {
+        //TODO 做一些数据校验,如唯一约束
+    }
+
+    /**
+     * 校验并批量删除设备登录信息
+     *
+     * @param ids     待删除的主键集合
+     * @param isValid 是否进行有效性校验
+     * @return 是否删除成功
+     */
+    @Override
+    public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
+        if (isValid) {
+            //TODO 做一些业务上的校验,判断是否需要校验
+        }
+        return baseMapper.deleteByIds(ids) > 0;
+    }
+
+    @Override
+    public R<HttpHeartbeatRspVo> deviceLogin(HttpHeartbeatReq requestParam) {
+        HttpHeartbeatRspVo result = new HttpHeartbeatRspVo();
+        JSONObject resultMessage = new JSONObject();
+
+        SmsbDeviceLogin add = new SmsbDeviceLogin();
+
+        String reqIdentifier = requestParam.getIdentifier();
+        String reqIp = requestParam.getDeviceIp();
+        add.setReqIdentifier(reqIdentifier);
+        add.setReqIp(reqIp);
+
+        // 1 根据reqIdentifier 查询是否是合法设备
+        SmsbDeviceVo smsbDeviceVo = smsbDeviceService.getDeviceByIdentifier(reqIdentifier);
+        // 非法设备
+        if (null == smsbDeviceVo) {
+            add.setLoginResult(0);
+            baseMapper.insert(add);
+            resultMessage.putOpt("code", "0");
+            resultMessage.putOpt("data", "非法设备");
+            result.setMessage(resultMessage.toString());
+            return R.ok(result);
+        }
+        // 合法设备
+        add.setLoginResult(1);
+        add.setIdentifier(reqIdentifier);
+        baseMapper.insert(add);
+        // 2 数据库缓存auth key
+        String authKey = UUID.randomUUID().toString().replace("-","");
+        RedisUtils.setCacheObject(DeviceConstants.REDIS_DEVICE_AUTH_KEY + reqIdentifier, authKey);
+        // 3 接口返回 auth key
+        resultMessage.putOpt("code", "1");
+        resultMessage.putOpt("data", authKey);
+        result.setMessage(resultMessage.toString());
+        return R.ok(result);
+    }
+}

+ 29 - 0
smsb-modules/smsb-device/src/main/resources/mapper/device/SmsbDeviceLoginMapper.xml

@@ -0,0 +1,29 @@
+<?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="com.inspur.device.mapper.SmsbDeviceLoginMapper">
+
+    <select id="selectPageVoList" resultType="com.inspur.device.domain.vo.SmsbDeviceLoginVo" parameterType="com.inspur.device.domain.bo.SmsbDeviceLoginBo">
+        SELECT
+            sdl.*,
+            sd.NAME AS deviceName,
+            sd.serial_number,
+            sd.mac
+        FROM
+            smsb_device_login sdl
+        LEFT JOIN smsb_device sd ON sdl.identifier = sd.identifier
+        WHERE 1=1
+        <if test="bo.identifier != null and bo.identifier != ''">
+            AND sdl.identifier = #{bo.identifier}
+        </if>
+        <if test="bo.reqIp != null and bo.reqIp != ''">
+            AND sdl.reqIp = #{bo.reqIp}
+        </if>
+        <if test="bo.loginResult != null">
+            AND sdl.loginResult = #{bo.loginResult}
+        </if>
+        ORDER BY sdl.create_time DESC
+    </select>
+
+</mapper>

+ 63 - 0
smsb-plus-ui/src/api/smsb/device/device_login.ts

@@ -0,0 +1,63 @@
+import request from '@/utils/request';
+import { AxiosPromise } from 'axios';
+import { DeviceLoginVO, DeviceLoginForm, DeviceLoginQuery } from '@/api/device/deviceLogin/types';
+
+/**
+ * 查询设备登录列表
+ * @param query
+ * @returns {*}
+ */
+
+export const listDeviceLogin = (query?: DeviceLoginQuery): AxiosPromise<DeviceLoginVO[]> => {
+  return request({
+    url: '/smsb/device/login/list',
+    method: 'get',
+    params: query
+  });
+};
+
+/**
+ * 查询设备登录详细
+ * @param id
+ */
+export const getDeviceLogin = (id: string | number): AxiosPromise<DeviceLoginVO> => {
+  return request({
+    url: '/smsb/device/login/' + id,
+    method: 'get'
+  });
+};
+
+/**
+ * 新增设备登录
+ * @param data
+ */
+export const addDeviceLogin = (data: DeviceLoginForm) => {
+  return request({
+    url: '/smsb/device/login',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改设备登录
+ * @param data
+ */
+export const updateDeviceLogin = (data: DeviceLoginForm) => {
+  return request({
+    url: '/smsb/device/login',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除设备登录
+ * @param id
+ */
+export const delDeviceLogin = (id: string | number | Array<string | number>) => {
+  return request({
+    url: '/smsb/device/login/' + id,
+    method: 'delete'
+  });
+};

+ 66 - 0
smsb-plus-ui/src/api/smsb/device/device_login_type.ts

@@ -0,0 +1,66 @@
+export interface DeviceLoginVO {
+  /**
+   * 主键ID
+   */
+  id: string | number;
+
+  /**
+   * 请求标识
+   */
+  reqIdentifier: string | number;
+
+  /**
+   * 请求IP
+   */
+  reqIp: string;
+
+  /**
+   * 设备标识
+   */
+  identifier: string | number;
+
+  /**
+   * 登录结果smsb_device_login_result
+   */
+  loginResult: number;
+
+  /**
+   * 登录时间
+   */
+  createTime: string;
+
+}
+
+export interface DeviceLoginForm extends BaseEntity {
+}
+
+export interface DeviceLoginQuery extends PageQuery {
+
+  /**
+   * 请求标识
+   */
+  reqIdentifier?: string | number;
+
+  /**
+   * 请求IP
+   */
+  reqIp?: string;
+
+  /**
+   * 设备标识
+   */
+  identifier?: string | number;
+
+  /**
+   * 登录结果smsb_device_login_result
+   */
+  loginResult?: number;
+
+  /**
+   * 日期范围参数
+   */
+  params?: any;
+}
+
+
+

+ 237 - 0
smsb-plus-ui/src/views/smsb/deviceLogin/index.vue

@@ -0,0 +1,237 @@
+<template>
+  <div class="p-2">
+    <transition :enter-active-class="proxy?.animate.searchAnimate.enter"
+                :leave-active-class="proxy?.animate.searchAnimate.leave">
+      <div v-show="showSearch" class="mb-[10px]">
+        <el-card shadow="hover" :style="{ marginTop: '10px', height: '60px' }">
+          <el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="70px">
+            <el-form-item label="唯一标识" prop="reqIdentifier">
+              <el-input v-model="queryParams.reqIdentifier" placeholder="请输入请求标识" clearable @keyup.enter="handleQuery"/>
+            </el-form-item>
+            <el-form-item label="设备IP" prop="reqIp">
+              <el-input v-model="queryParams.reqIp" placeholder="请输入请求IP" clearable @keyup.enter="handleQuery"/>
+            </el-form-item>
+            <el-form-item label="登录结果" prop="loginResult">
+              <el-select v-model="form.loginResult" placeholder="请选择设备型号" clearable @keyup.enter="handleQuery">
+                <el-option v-for="dict in smsb_device_login_result" :key="dict.value" :label="dict.label"
+                           :value="dict.value"/>
+              </el-select>
+            </el-form-item>
+            <el-form-item>
+              <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
+              <el-button icon="Refresh" @click="resetQuery">重置</el-button>
+            </el-form-item>
+          </el-form>
+        </el-card>
+      </div>
+    </transition>
+
+    <el-card shadow="never">
+      <!--      <template #header>
+              <el-row :gutter="10" class="mb8">
+                <el-col :span="1.5">
+                  <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['device:deviceLogin:add']">新增</el-button>
+                </el-col>
+                <el-col :span="1.5">
+                  <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['device:deviceLogin:edit']">修改</el-button>
+                </el-col>
+                <el-col :span="1.5">
+                  <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['device:deviceLogin:remove']">删除</el-button>
+                </el-col>
+                <el-col :span="1.5">
+                  <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['device:deviceLogin:export']">导出</el-button>
+                </el-col>
+                <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
+              </el-row>
+            </template>-->
+
+      <el-table v-loading="loading" :data="deviceLoginList" @selection-change="handleSelectionChange">
+        <!--
+                <el-table-column type="selection" width="55" align="center" />
+        -->
+        <el-table-column label="ID" align="left" prop="id" v-if="true" width="180"
+                         :show-overflow-tooltip="true"/>
+        <el-table-column label="请求标识" align="left" prop="reqIdentifier" width="250" :show-overflow-tooltip="true"/>
+        <el-table-column label="请求IP" align="left" prop="reqIp" width="150" :show-overflow-tooltip="true"/>
+        <el-table-column label="登录结果" align="center" prop="loginResult" width="120">
+          <template #default="scope">
+            <dict-tag :options="smsb_device_login_result" :value="scope.row.loginResult"/>
+          </template>
+        </el-table-column>
+        <el-table-column label="登录时间" align="left" prop="createTime" width="160"/>
+        <el-table-column label="设备名称" align="left" prop="deviceName" width="220" :show-overflow-tooltip="true" />
+        <el-table-column label="设备标识" align="left" prop="identifier" width="250" :show-overflow-tooltip="true"/>
+        <el-table-column label="设备SN" align="left" prop="serialNumber" width="200" :show-overflow-tooltip="true" />
+        <el-table-column label="设备MAC" align="left" prop="mac" width="150" />
+        <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="100">
+          <template #default="scope">
+            <!--            <el-tooltip content="修改" placement="top">
+                          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['device:deviceLogin:edit']"></el-button>
+                        </el-tooltip>-->
+            <el-tooltip content="删除" placement="top">
+              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)"
+                         v-hasPermi="['device:deviceLogin:remove']"></el-button>
+            </el-tooltip>
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum"
+                  v-model:limit="queryParams.pageSize" @pagination="getList"/>
+    </el-card>
+    <!-- 添加或修改设备登录对话框 -->
+    <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
+      <el-form ref="deviceLoginFormRef" :model="form" :rules="rules" label-width="80px">
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
+          <el-button @click="cancel">取 消</el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup name="DeviceLogin" lang="ts">
+import {
+  addDeviceLogin,
+  delDeviceLogin,
+  getDeviceLogin,
+  listDeviceLogin,
+  updateDeviceLogin
+} from '@/api/smsb/device/device_login';
+import {DeviceLoginForm, DeviceLoginQuery, DeviceLoginVO} from '@/api/smsb/device/device_login_type';
+
+const {proxy} = getCurrentInstance() as ComponentInternalInstance;
+const {smsb_device_login_result} = toRefs<any>(
+  proxy?.useDict('smsb_device_login_result')
+);
+const deviceLoginList = ref<DeviceLoginVO[]>([]);
+const buttonLoading = ref(false);
+const loading = ref(true);
+const showSearch = ref(true);
+const ids = ref<Array<string | number>>([]);
+const single = ref(true);
+const multiple = ref(true);
+const total = ref(0);
+
+const queryFormRef = ref<ElFormInstance>();
+const deviceLoginFormRef = ref<ElFormInstance>();
+
+const dialog = reactive<DialogOption>({
+  visible: false,
+  title: ''
+});
+
+const initFormData: DeviceLoginForm = {}
+const data = reactive<PageData<DeviceLoginForm, DeviceLoginQuery>>({
+  form: {...initFormData},
+  queryParams: {
+    pageNum: 1,
+    pageSize: 10,
+    reqIdentifier: undefined,
+    reqIp: undefined,
+    identifier: undefined,
+    loginResult: undefined,
+    params: {}
+  },
+  rules: {}
+});
+
+const {queryParams, form, rules} = toRefs(data);
+
+/** 查询设备登录列表 */
+const getList = async () => {
+  loading.value = true;
+  const res = await listDeviceLogin(queryParams.value);
+  deviceLoginList.value = res.rows;
+  total.value = res.total;
+  loading.value = false;
+}
+
+/** 取消按钮 */
+const cancel = () => {
+  reset();
+  dialog.visible = false;
+}
+
+/** 表单重置 */
+const reset = () => {
+  form.value = {...initFormData};
+  deviceLoginFormRef.value?.resetFields();
+}
+
+/** 搜索按钮操作 */
+const handleQuery = () => {
+  queryParams.value.pageNum = 1;
+  getList();
+}
+
+/** 重置按钮操作 */
+const resetQuery = () => {
+  queryFormRef.value?.resetFields();
+  handleQuery();
+}
+
+/** 多选框选中数据 */
+const handleSelectionChange = (selection: DeviceLoginVO[]) => {
+  ids.value = selection.map(item => item.id);
+  single.value = selection.length != 1;
+  multiple.value = !selection.length;
+}
+
+/** 新增按钮操作 */
+const handleAdd = () => {
+  reset();
+  dialog.visible = true;
+  dialog.title = "添加设备登录";
+}
+
+/** 修改按钮操作 */
+const handleUpdate = async (row?: DeviceLoginVO) => {
+  reset();
+  const _id = row?.id || ids.value[0]
+  const res = await getDeviceLogin(_id);
+  Object.assign(form.value, res.data);
+  dialog.visible = true;
+  dialog.title = "修改设备登录";
+}
+
+/** 提交按钮 */
+const submitForm = () => {
+  deviceLoginFormRef.value?.validate(async (valid: boolean) => {
+    if (valid) {
+      buttonLoading.value = true;
+      if (form.value.id) {
+        await updateDeviceLogin(form.value).finally(() => buttonLoading.value = false);
+      } else {
+        await addDeviceLogin(form.value).finally(() => buttonLoading.value = false);
+      }
+      proxy?.$modal.msgSuccess("操作成功");
+      dialog.visible = false;
+      await getList();
+    }
+  });
+}
+
+/** 删除按钮操作 */
+const handleDelete = async (row?: DeviceLoginVO) => {
+  const _ids = row?.id || ids.value;
+  await proxy?.$modal.confirm('是否确认删除设备登录编号为"' + _ids + '"的数据项?').finally(() => loading.value = false);
+  await delDeviceLogin(_ids);
+  proxy?.$modal.msgSuccess("删除成功");
+  await getList();
+}
+
+/** 导出按钮操作 */
+const handleExport = () => {
+  proxy?.download('device/deviceLogin/export', {
+    ...queryParams.value
+  }, `deviceLogin_${new Date().getTime()}.xlsx`)
+}
+
+onMounted(() => {
+  getList();
+});
+</script>