mirror of
https://gitee.com/beecue/fastbee.git
synced 2025-12-18 00:45:55 +08:00
19
springboot/sql/update/is_authorize_update.sql
Normal file
19
springboot/sql/update/is_authorize_update.sql
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
ALTER TABLE `iot_product`
|
||||||
|
ADD COLUMN `is_authorize` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否启用授权码(0-否,1-是)' AFTER `is_sys`;
|
||||||
|
|
||||||
|
CREATE TABLE `iot_product_authorize` (
|
||||||
|
`authorize_id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '授权码ID',
|
||||||
|
`authorize_code` varchar(32) NOT NULL COMMENT '授权码',
|
||||||
|
`product_id` bigint NOT NULL COMMENT '产品ID',
|
||||||
|
`device_id` bigint NULL COMMENT '设备ID',
|
||||||
|
`serial_number` varchar(64) NULL COMMENT '设备编号',
|
||||||
|
`user_id` bigint NULL COMMENT '用户ID',
|
||||||
|
`user_name` varchar(30) NULL COMMENT '用户名称',
|
||||||
|
`del_flag` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0' COMMENT '删除标志(0代表存在 2代表删除)',
|
||||||
|
`create_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '' COMMENT '创建者',
|
||||||
|
`create_time` datetime NOT NULL COMMENT '创建时间',
|
||||||
|
`update_by` varchar(64) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT '' COMMENT '更新者',
|
||||||
|
`update_time` datetime NULL DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`remark` varchar(500) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注',
|
||||||
|
PRIMARY KEY (`authorize_id`)
|
||||||
|
) COMMENT = '产品授权码表';
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
package com.ruoyi.iot.controller;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.ruoyi.iot.model.ProductAuthorizeVO;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import com.ruoyi.common.annotation.Log;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.iot.domain.ProductAuthorize;
|
||||||
|
import com.ruoyi.iot.service.IProductAuthorizeService;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品授权码Controller
|
||||||
|
*
|
||||||
|
* @author kami
|
||||||
|
* @date 2022-04-11
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/iot/authorize")
|
||||||
|
public class ProductAuthorizeController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private IProductAuthorizeService productAuthorizeService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品授权码列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:authorize:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(ProductAuthorize productAuthorize)
|
||||||
|
{
|
||||||
|
startPage();
|
||||||
|
List<ProductAuthorize> list = productAuthorizeService.selectProductAuthorizeList(productAuthorize);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出产品授权码列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:authorize:export')")
|
||||||
|
@Log(title = "产品授权码", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, ProductAuthorize productAuthorize)
|
||||||
|
{
|
||||||
|
List<ProductAuthorize> list = productAuthorizeService.selectProductAuthorizeList(productAuthorize);
|
||||||
|
ExcelUtil<ProductAuthorize> util = new ExcelUtil<ProductAuthorize>(ProductAuthorize.class);
|
||||||
|
util.exportExcel(response, list, "产品授权码数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取产品授权码详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:authorize:query')")
|
||||||
|
@GetMapping(value = "/{authorizeId}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("authorizeId") Long authorizeId)
|
||||||
|
{
|
||||||
|
return AjaxResult.success(productAuthorizeService.selectProductAuthorizeByAuthorizeId(authorizeId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增产品授权码
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:authorize:add')")
|
||||||
|
@Log(title = "产品授权码", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping
|
||||||
|
public AjaxResult add(@RequestBody ProductAuthorize productAuthorize)
|
||||||
|
{
|
||||||
|
return toAjax(productAuthorizeService.insertProductAuthorize(productAuthorize));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据数量批量新增产品授权码
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:authorize:add')")
|
||||||
|
@Log(title = "根据数量批量新增产品授权码", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping("addProductAuthorizeByNum")
|
||||||
|
public AjaxResult addProductAuthorizeByNum(@RequestBody ProductAuthorizeVO productAuthorizeVO)
|
||||||
|
{
|
||||||
|
return toAjax(productAuthorizeService.addProductAuthorizeByNum(productAuthorizeVO));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改产品授权码
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:authorize:edit')")
|
||||||
|
@Log(title = "产品授权码", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping
|
||||||
|
public AjaxResult edit(@RequestBody ProductAuthorize productAuthorize)
|
||||||
|
{
|
||||||
|
return toAjax(productAuthorizeService.updateProductAuthorize(productAuthorize));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除产品授权码
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('iot:authorize:remove')")
|
||||||
|
@Log(title = "产品授权码", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{authorizeIds}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] authorizeIds)
|
||||||
|
{
|
||||||
|
return toAjax(productAuthorizeService.deleteProductAuthorizeByAuthorizeIds(authorizeIds));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ import com.ruoyi.common.utils.StringUtils;
|
|||||||
import com.ruoyi.common.utils.file.FileUploadUtils;
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
||||||
import com.ruoyi.common.utils.file.FileUtils;
|
import com.ruoyi.common.utils.file.FileUtils;
|
||||||
import com.ruoyi.iot.domain.Device;
|
import com.ruoyi.iot.domain.Device;
|
||||||
|
import com.ruoyi.iot.domain.ProductAuthorize;
|
||||||
import com.ruoyi.iot.model.AuthenticateInputModel;
|
import com.ruoyi.iot.model.AuthenticateInputModel;
|
||||||
import com.ruoyi.iot.model.DeviceAuthenticateModel;
|
import com.ruoyi.iot.model.DeviceAuthenticateModel;
|
||||||
import com.ruoyi.iot.model.MqttClientConnectModel;
|
import com.ruoyi.iot.model.MqttClientConnectModel;
|
||||||
@@ -24,6 +25,7 @@ import com.ruoyi.iot.model.ThingsModels.ThingsModelShadow;
|
|||||||
import com.ruoyi.iot.mqtt.EmqxService;
|
import com.ruoyi.iot.mqtt.EmqxService;
|
||||||
import com.ruoyi.iot.mqtt.MqttConfig;
|
import com.ruoyi.iot.mqtt.MqttConfig;
|
||||||
import com.ruoyi.iot.service.IDeviceService;
|
import com.ruoyi.iot.service.IDeviceService;
|
||||||
|
import com.ruoyi.iot.service.IProductAuthorizeService;
|
||||||
import com.ruoyi.iot.service.IToolService;
|
import com.ruoyi.iot.service.IToolService;
|
||||||
import com.ruoyi.iot.service.impl.ThingsModelServiceImpl;
|
import com.ruoyi.iot.service.impl.ThingsModelServiceImpl;
|
||||||
import com.ruoyi.iot.util.AESUtils;
|
import com.ruoyi.iot.util.AESUtils;
|
||||||
@@ -77,6 +79,8 @@ public class ToolController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IDeviceService deviceService;
|
private IDeviceService deviceService;
|
||||||
|
|
||||||
|
private IProductAuthorizeService authorizeService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ThingsModelServiceImpl thingsModelService;
|
private ThingsModelServiceImpl thingsModelService;
|
||||||
|
|
||||||
@@ -139,6 +143,8 @@ public class ToolController extends BaseController {
|
|||||||
Device device = deviceService.selectShortDeviceBySerialNumber(deviceNum);
|
Device device = deviceService.selectShortDeviceBySerialNumber(deviceNum);
|
||||||
if (device !=null && mqttConfig.getusername().equals(username) && mqttConfig.getpassword().equals(password)) {
|
if (device !=null && mqttConfig.getusername().equals(username) && mqttConfig.getpassword().equals(password)) {
|
||||||
System.out.println("-----------认证成功,clientId:" + clientid + "---------------");
|
System.out.println("-----------认证成功,clientId:" + clientid + "---------------");
|
||||||
|
ProductAuthorize authorize = new ProductAuthorize(null, device.getProductId(), device.getDeviceId(), device.getSerialNumber(), 1L, "admin");
|
||||||
|
authorizeService.boundProductAuthorize(authorize);
|
||||||
return ResponseEntity.ok().body("ok");
|
return ResponseEntity.ok().body("ok");
|
||||||
}
|
}
|
||||||
return returnUnauthorized(clientid, username, password, "认证信息有误");
|
return returnUnauthorized(clientid, username, password, "认证信息有误");
|
||||||
@@ -172,12 +178,16 @@ public class ToolController extends BaseController {
|
|||||||
// 设备状态验证 (1-未激活,2-禁用,3-在线,4-离线)
|
// 设备状态验证 (1-未激活,2-禁用,3-在线,4-离线)
|
||||||
if (model.getDeviceId() != null && model.getDeviceId() != 0 && model.getStatus() != 2) {
|
if (model.getDeviceId() != null && model.getDeviceId() != 0 && model.getStatus() != 2) {
|
||||||
System.out.println("-----------认证成功,clientId:" + clientid + "---------------");
|
System.out.println("-----------认证成功,clientId:" + clientid + "---------------");
|
||||||
|
ProductAuthorize authorize = new ProductAuthorize(null, model.getProductId(), model.getDeviceId(), model.getSerialNumber(), 1L, "admin");
|
||||||
|
authorizeService.boundProductAuthorize(authorize);
|
||||||
return ResponseEntity.ok().body("ok");
|
return ResponseEntity.ok().body("ok");
|
||||||
} else {
|
} else {
|
||||||
// 自动添加设备
|
// 自动添加设备
|
||||||
int result = deviceService.insertDeviceAuto(deviceNum, userId, productId);
|
int result = deviceService.insertDeviceAuto(deviceNum, userId, productId);
|
||||||
if (result == 1) {
|
if (result == 1) {
|
||||||
System.out.println("-----------认证成功,clientId:" + clientid + "---------------");
|
System.out.println("-----------认证成功,clientId:" + clientid + "---------------");
|
||||||
|
ProductAuthorize authorize = new ProductAuthorize(null, model.getProductId(), model.getDeviceId(), model.getSerialNumber(), 1L, "admin");
|
||||||
|
authorizeService.boundProductAuthorize(authorize);
|
||||||
return ResponseEntity.ok().body("ok");
|
return ResponseEntity.ok().body("ok");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,10 @@ public class Product extends BaseEntity
|
|||||||
@Excel(name = "是否系统通用", readConverterExp = "0=-否,1-是")
|
@Excel(name = "是否系统通用", readConverterExp = "0=-否,1-是")
|
||||||
private Integer isSys;
|
private Integer isSys;
|
||||||
|
|
||||||
|
/** 是否启用授权码(0-否,1-是) */
|
||||||
|
@Excel(name = "是否启用授权码", readConverterExp = "0=-否,1-是")
|
||||||
|
private Integer isAuthorize;
|
||||||
|
|
||||||
/** mqtt账号 */
|
/** mqtt账号 */
|
||||||
private String mqttAccount;
|
private String mqttAccount;
|
||||||
|
|
||||||
@@ -164,6 +168,9 @@ public class Product extends BaseEntity
|
|||||||
return isSys;
|
return isSys;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setIsAuthorize(Integer isAuthorize) {this.isAuthorize = isAuthorize;}
|
||||||
|
public Integer getIsAuthorize() {return isAuthorize;}
|
||||||
|
|
||||||
public void setMqttAccount(String mqttAccount)
|
public void setMqttAccount(String mqttAccount)
|
||||||
{
|
{
|
||||||
this.mqttAccount = mqttAccount;
|
this.mqttAccount = mqttAccount;
|
||||||
@@ -238,6 +245,7 @@ public class Product extends BaseEntity
|
|||||||
.append("tenantId", getTenantId())
|
.append("tenantId", getTenantId())
|
||||||
.append("tenantName", getTenantName())
|
.append("tenantName", getTenantName())
|
||||||
.append("isSys", getIsSys())
|
.append("isSys", getIsSys())
|
||||||
|
.append("isAuthorize", getIsAuthorize())
|
||||||
.append("status", getStatus())
|
.append("status", getStatus())
|
||||||
.append("deviceType", getDeviceType())
|
.append("deviceType", getDeviceType())
|
||||||
.append("networkMethod", getNetworkMethod())
|
.append("networkMethod", getNetworkMethod())
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
package com.ruoyi.iot.domain;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import com.ruoyi.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品授权码对象 iot_product_authorize
|
||||||
|
*
|
||||||
|
* @author kami
|
||||||
|
* @date 2022-04-11
|
||||||
|
*/
|
||||||
|
public class ProductAuthorize extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 授权码ID */
|
||||||
|
private Long authorizeId;
|
||||||
|
|
||||||
|
/** 授权码 */
|
||||||
|
@Excel(name = "授权码")
|
||||||
|
private String authorizeCode;
|
||||||
|
|
||||||
|
/** 产品ID */
|
||||||
|
@Excel(name = "产品ID")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
/** 设备ID */
|
||||||
|
@Excel(name = "设备ID")
|
||||||
|
private Long deviceId;
|
||||||
|
|
||||||
|
/** 设备编号 */
|
||||||
|
@Excel(name = "设备编号")
|
||||||
|
private String serialNumber;
|
||||||
|
|
||||||
|
/** 用户ID */
|
||||||
|
@Excel(name = "用户ID")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/** 用户名称 */
|
||||||
|
@Excel(name = "用户名称")
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/** 删除标志(0代表存在 2代表删除) */
|
||||||
|
private String delFlag;
|
||||||
|
|
||||||
|
public ProductAuthorize() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProductAuthorize(String authorizeCode, Long productId, Long deviceId, String serialNumber, Long userId, String userName) {
|
||||||
|
this.authorizeCode = authorizeCode;
|
||||||
|
this.productId = productId;
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
this.serialNumber = serialNumber;
|
||||||
|
this.userId = userId;
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuthorizeId(Long authorizeId)
|
||||||
|
{
|
||||||
|
this.authorizeId = authorizeId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getAuthorizeId()
|
||||||
|
{
|
||||||
|
return authorizeId;
|
||||||
|
}
|
||||||
|
public void setAuthorizeCode(String authorizeCode)
|
||||||
|
{
|
||||||
|
this.authorizeCode = authorizeCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuthorizeCode()
|
||||||
|
{
|
||||||
|
return authorizeCode;
|
||||||
|
}
|
||||||
|
public void setProductId(Long productId)
|
||||||
|
{
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getProductId()
|
||||||
|
{
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
public void setDeviceId(Long deviceId)
|
||||||
|
{
|
||||||
|
this.deviceId = deviceId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getDeviceId()
|
||||||
|
{
|
||||||
|
return deviceId;
|
||||||
|
}
|
||||||
|
public void setSerialNumber(String serialNumber)
|
||||||
|
{
|
||||||
|
this.serialNumber = serialNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSerialNumber()
|
||||||
|
{
|
||||||
|
return serialNumber;
|
||||||
|
}
|
||||||
|
public void setUserId(Long userId)
|
||||||
|
{
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUserId()
|
||||||
|
{
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
public void setUserName(String userName)
|
||||||
|
{
|
||||||
|
this.userName = userName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName()
|
||||||
|
{
|
||||||
|
return userName;
|
||||||
|
}
|
||||||
|
public void setDelFlag(String delFlag)
|
||||||
|
{
|
||||||
|
this.delFlag = delFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDelFlag()
|
||||||
|
{
|
||||||
|
return delFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("authorizeId", getAuthorizeId())
|
||||||
|
.append("authorizeCode", getAuthorizeCode())
|
||||||
|
.append("productId", getProductId())
|
||||||
|
.append("deviceId", getDeviceId())
|
||||||
|
.append("serialNumber", getSerialNumber())
|
||||||
|
.append("userId", getUserId())
|
||||||
|
.append("userName", getUserName())
|
||||||
|
.append("delFlag", getDelFlag())
|
||||||
|
.append("createBy", getCreateBy())
|
||||||
|
.append("createTime", getCreateTime())
|
||||||
|
.append("updateBy", getUpdateBy())
|
||||||
|
.append("updateTime", getUpdateTime())
|
||||||
|
.append("remark", getRemark())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package com.ruoyi.iot.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.iot.domain.ProductAuthorize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品授权码Mapper接口
|
||||||
|
*
|
||||||
|
* @author kami
|
||||||
|
* @date 2022-04-11
|
||||||
|
*/
|
||||||
|
public interface ProductAuthorizeMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询产品授权码
|
||||||
|
*
|
||||||
|
* @param authorizeId 产品授权码主键
|
||||||
|
* @return 产品授权码
|
||||||
|
*/
|
||||||
|
public ProductAuthorize selectProductAuthorizeByAuthorizeId(Long authorizeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品授权码列表
|
||||||
|
*
|
||||||
|
* @param productAuthorize 产品授权码
|
||||||
|
* @return 产品授权码集合
|
||||||
|
*/
|
||||||
|
public List<ProductAuthorize> selectProductAuthorizeList(ProductAuthorize productAuthorize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增产品授权码
|
||||||
|
*
|
||||||
|
* @param productAuthorize 产品授权码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertProductAuthorize(ProductAuthorize productAuthorize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改产品授权码
|
||||||
|
*
|
||||||
|
* @param productAuthorize 产品授权码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateProductAuthorize(ProductAuthorize productAuthorize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除产品授权码
|
||||||
|
*
|
||||||
|
* @param authorizeId 产品授权码主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteProductAuthorizeByAuthorizeId(Long authorizeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除产品授权码
|
||||||
|
*
|
||||||
|
* @param authorizeIds 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteProductAuthorizeByAuthorizeIds(Long[] authorizeIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增产品授权码
|
||||||
|
* @param list
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int insertBatchAuthorize(List<ProductAuthorize> list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据产品id查询一条未绑定的授权码
|
||||||
|
* @param authorize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ProductAuthorize selectOneUnboundAuthorizeByProductId(ProductAuthorize authorize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据授权码查询一条未绑定的授权码
|
||||||
|
* @param authorize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ProductAuthorize selectOneUnboundAuthorizeByAuthorizeCode(ProductAuthorize authorize);
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.ruoyi.iot.model;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增产品授权码VO
|
||||||
|
*
|
||||||
|
* @author Venus Zhang
|
||||||
|
* @create 2022-04-11 15:04
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class ProductAuthorizeVO {
|
||||||
|
|
||||||
|
private Long productId;
|
||||||
|
private int createNum;
|
||||||
|
|
||||||
|
public Long getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(Long productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCreateNum() {
|
||||||
|
return createNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateNum(int createNum) {
|
||||||
|
this.createNum = createNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package com.ruoyi.iot.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.ruoyi.iot.domain.ProductAuthorize;
|
||||||
|
import com.ruoyi.iot.model.ProductAuthorizeVO;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品授权码Service接口
|
||||||
|
*
|
||||||
|
* @author kami
|
||||||
|
* @date 2022-04-11
|
||||||
|
*/
|
||||||
|
public interface IProductAuthorizeService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询产品授权码
|
||||||
|
*
|
||||||
|
* @param authorizeId 产品授权码主键
|
||||||
|
* @return 产品授权码
|
||||||
|
*/
|
||||||
|
public ProductAuthorize selectProductAuthorizeByAuthorizeId(Long authorizeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品授权码列表
|
||||||
|
*
|
||||||
|
* @param productAuthorize 产品授权码
|
||||||
|
* @return 产品授权码集合
|
||||||
|
*/
|
||||||
|
public List<ProductAuthorize> selectProductAuthorizeList(ProductAuthorize productAuthorize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增产品授权码
|
||||||
|
*
|
||||||
|
* @param productAuthorize 产品授权码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertProductAuthorize(ProductAuthorize productAuthorize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改产品授权码
|
||||||
|
*
|
||||||
|
* @param productAuthorize 产品授权码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateProductAuthorize(ProductAuthorize productAuthorize);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除产品授权码
|
||||||
|
*
|
||||||
|
* @param authorizeIds 需要删除的产品授权码主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteProductAuthorizeByAuthorizeIds(Long[] authorizeIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除产品授权码信息
|
||||||
|
*
|
||||||
|
* @param authorizeId 产品授权码主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteProductAuthorizeByAuthorizeId(Long authorizeId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据数量批量新增产品授权码
|
||||||
|
* @param productAuthorizeVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int addProductAuthorizeByNum(ProductAuthorizeVO productAuthorizeVO);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据产品id和设备序列号绑定授权码
|
||||||
|
* @param productAuthorize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int boundProductAuthorize(ProductAuthorize productAuthorize);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,156 @@
|
|||||||
|
package com.ruoyi.iot.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.constant.HttpStatus;
|
||||||
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||||
|
import com.ruoyi.common.exception.ServiceException;
|
||||||
|
import com.ruoyi.common.utils.DateUtils;
|
||||||
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.uuid.IdUtils;
|
||||||
|
import com.ruoyi.iot.domain.ProductAuthorize;
|
||||||
|
import com.ruoyi.iot.mapper.ProductAuthorizeMapper;
|
||||||
|
import com.ruoyi.iot.model.ProductAuthorizeVO;
|
||||||
|
import com.ruoyi.iot.service.IProductAuthorizeService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 产品授权码Service业务层处理
|
||||||
|
*
|
||||||
|
* @author kami
|
||||||
|
* @date 2022-04-11
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class ProductAuthorizeServiceImpl implements IProductAuthorizeService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ProductAuthorizeMapper productAuthorizeMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品授权码
|
||||||
|
*
|
||||||
|
* @param authorizeId 产品授权码主键
|
||||||
|
* @return 产品授权码
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public ProductAuthorize selectProductAuthorizeByAuthorizeId(Long authorizeId)
|
||||||
|
{
|
||||||
|
return productAuthorizeMapper.selectProductAuthorizeByAuthorizeId(authorizeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询产品授权码列表
|
||||||
|
*
|
||||||
|
* @param productAuthorize 产品授权码
|
||||||
|
* @return 产品授权码
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ProductAuthorize> selectProductAuthorizeList(ProductAuthorize productAuthorize)
|
||||||
|
{
|
||||||
|
return productAuthorizeMapper.selectProductAuthorizeList(productAuthorize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增产品授权码
|
||||||
|
*
|
||||||
|
* @param productAuthorize 产品授权码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertProductAuthorize(ProductAuthorize productAuthorize)
|
||||||
|
{
|
||||||
|
productAuthorize.setCreateTime(DateUtils.getNowDate());
|
||||||
|
return productAuthorizeMapper.insertProductAuthorize(productAuthorize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改产品授权码
|
||||||
|
*
|
||||||
|
* @param productAuthorize 产品授权码
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateProductAuthorize(ProductAuthorize productAuthorize)
|
||||||
|
{
|
||||||
|
productAuthorize.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return productAuthorizeMapper.updateProductAuthorize(productAuthorize);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除产品授权码
|
||||||
|
*
|
||||||
|
* @param authorizeIds 需要删除的产品授权码主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteProductAuthorizeByAuthorizeIds(Long[] authorizeIds)
|
||||||
|
{
|
||||||
|
return productAuthorizeMapper.deleteProductAuthorizeByAuthorizeIds(authorizeIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除产品授权码信息
|
||||||
|
*
|
||||||
|
* @param authorizeId 产品授权码主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteProductAuthorizeByAuthorizeId(Long authorizeId)
|
||||||
|
{
|
||||||
|
return productAuthorizeMapper.deleteProductAuthorizeByAuthorizeId(authorizeId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据数量批量新增产品授权码
|
||||||
|
* @param productAuthorizeVO
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int addProductAuthorizeByNum(ProductAuthorizeVO productAuthorizeVO) {
|
||||||
|
Long productId = productAuthorizeVO.getProductId();
|
||||||
|
int createNum = productAuthorizeVO.getCreateNum();
|
||||||
|
List<ProductAuthorize> list = new ArrayList<>(createNum);
|
||||||
|
SysUser user = getLoginUser().getUser();
|
||||||
|
for (int i = 0; i < createNum; i++) {
|
||||||
|
ProductAuthorize authorize = new ProductAuthorize();
|
||||||
|
authorize.setProductId(productId);
|
||||||
|
authorize.setCreateBy(user.getUserName());
|
||||||
|
authorize.setCreateTime(DateUtils.getNowDate());
|
||||||
|
authorize.setAuthorizeCode(IdUtils.fastSimpleUUID().toUpperCase());
|
||||||
|
list.add(authorize);
|
||||||
|
}
|
||||||
|
return productAuthorizeMapper.insertBatchAuthorize(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据产品id和设备序列号绑定授权码
|
||||||
|
*
|
||||||
|
* @param productAuthorize
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public int boundProductAuthorize(ProductAuthorize productAuthorize){
|
||||||
|
ProductAuthorize authorize = null;
|
||||||
|
if(StringUtils.isEmpty(productAuthorize.getAuthorizeCode())){
|
||||||
|
//TODO-kami: 2022/4/11 13:34 后期无需查询,硬件调用直接传入参数,可以删除
|
||||||
|
authorize = productAuthorizeMapper.selectOneUnboundAuthorizeByProductId(productAuthorize);
|
||||||
|
productAuthorize.setAuthorizeCode(authorize.getAuthorizeCode());
|
||||||
|
}else {
|
||||||
|
authorize = productAuthorizeMapper.selectOneUnboundAuthorizeByAuthorizeCode(productAuthorize);
|
||||||
|
}
|
||||||
|
if (authorize == null){
|
||||||
|
throw new ServiceException("授权码数据异常", HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
productAuthorize.setAuthorizeId(authorize.getAuthorizeId());
|
||||||
|
productAuthorize.setUpdateTime(DateUtils.getNowDate());
|
||||||
|
return productAuthorizeMapper.updateProductAuthorize(productAuthorize);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
<?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.ruoyi.iot.mapper.ProductAuthorizeMapper">
|
||||||
|
|
||||||
|
<resultMap type="com.ruoyi.iot.domain.ProductAuthorize" id="ProductAuthorizeResult">
|
||||||
|
<result property="authorizeId" column="authorize_id" />
|
||||||
|
<result property="authorizeCode" column="authorize_code" />
|
||||||
|
<result property="productId" column="product_id" />
|
||||||
|
<result property="deviceId" column="device_id" />
|
||||||
|
<result property="serialNumber" column="serial_number" />
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="userName" column="user_name" />
|
||||||
|
<result property="delFlag" column="del_flag" />
|
||||||
|
<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="selectProductAuthorizeVo">
|
||||||
|
select authorize_id, authorize_code, product_id, device_id, serial_number, user_id, user_name, del_flag, create_by, create_time, update_by, update_time, remark from iot_product_authorize
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectProductAuthorizeList" parameterType="com.ruoyi.iot.domain.ProductAuthorize" resultMap="ProductAuthorizeResult">
|
||||||
|
<include refid="selectProductAuthorizeVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="authorizeCode != null and authorizeCode != ''"> and authorize_code = #{authorizeCode}</if>
|
||||||
|
<if test="productId != null "> and product_id = #{productId}</if>
|
||||||
|
<if test="deviceId != null "> and device_id = #{deviceId}</if>
|
||||||
|
<if test="serialNumber != null and serialNumber != ''"> and serial_number = #{serialNumber}</if>
|
||||||
|
<if test="userId != null "> and user_id = #{userId}</if>
|
||||||
|
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
|
||||||
|
</where>
|
||||||
|
order by
|
||||||
|
device_id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectProductAuthorizeByAuthorizeId" parameterType="Long" resultMap="ProductAuthorizeResult">
|
||||||
|
<include refid="selectProductAuthorizeVo"/>
|
||||||
|
where authorize_id = #{authorizeId}
|
||||||
|
</select>
|
||||||
|
<select id="selectOneUnboundAuthorizeByProductId" parameterType="com.ruoyi.iot.domain.ProductAuthorize" resultType="com.ruoyi.iot.domain.ProductAuthorize">
|
||||||
|
<include refid="selectProductAuthorizeVo"/>
|
||||||
|
where
|
||||||
|
del_flag = 0
|
||||||
|
and product_id = #{productId}
|
||||||
|
and serial_number is null
|
||||||
|
and device_id is null
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectOneUnboundAuthorizeByAuthorizeCode" parameterType="com.ruoyi.iot.domain.ProductAuthorize" resultType="com.ruoyi.iot.domain.ProductAuthorize">
|
||||||
|
<include refid="selectProductAuthorizeVo"/>
|
||||||
|
where
|
||||||
|
del_flag = 0
|
||||||
|
and authorize_code = #{authorizeCode}
|
||||||
|
and serial_number is null
|
||||||
|
and device_id is null
|
||||||
|
limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertProductAuthorize" parameterType="com.ruoyi.iot.domain.ProductAuthorize">
|
||||||
|
insert into iot_product_authorize
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="authorizeCode != null and authorizeCode != ''">authorize_code,</if>
|
||||||
|
<if test="productId != null">product_id,</if>
|
||||||
|
<if test="deviceId != null">device_id,</if>
|
||||||
|
<if test="serialNumber != null">serial_number,</if>
|
||||||
|
<if test="userId != null">user_id,</if>
|
||||||
|
<if test="userName != null">user_name,</if>
|
||||||
|
<if test="createBy != null and createBy != ''">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="authorizeCode != null and authorizeCode != ''">#{authorizeCode},</if>
|
||||||
|
<if test="productId != null">#{productId},</if>
|
||||||
|
<if test="deviceId != null">#{deviceId},</if>
|
||||||
|
<if test="serialNumber != null">#{serialNumber},</if>
|
||||||
|
<if test="userId != null">#{userId},</if>
|
||||||
|
<if test="userName != null">#{userName},</if>
|
||||||
|
<if test="createBy != null and createBy != ''">#{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>
|
||||||
|
<insert id="insertBatchAuthorize" parameterType="com.ruoyi.iot.domain.ProductAuthorize" useGeneratedKeys="true" keyProperty="authorizeId">
|
||||||
|
insert into iot_product_authorize (authorize_code,product_id,create_by,create_time)
|
||||||
|
values
|
||||||
|
<foreach item="item" collection="list" separator=",">
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
#{item.authorizeCode},#{item.productId},#{item.createBy},#{item.createTime}
|
||||||
|
</trim>
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateProductAuthorize" parameterType="com.ruoyi.iot.domain.ProductAuthorize">
|
||||||
|
update iot_product_authorize
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
user_id = #{userId},
|
||||||
|
device_id = #{deviceId},
|
||||||
|
<if test="authorizeCode != null and authorizeCode != ''">authorize_code = #{authorizeCode},</if>
|
||||||
|
<if test="productId != null">product_id = #{productId},</if>
|
||||||
|
<if test="serialNumber != null">serial_number = #{serialNumber},</if>
|
||||||
|
<if test="userName != null">user_name = #{userName},</if>
|
||||||
|
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
|
||||||
|
<if test="createBy != null and createBy != ''">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 authorize_id = #{authorizeId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteProductAuthorizeByAuthorizeId" parameterType="Long">
|
||||||
|
delete from iot_product_authorize where authorize_id = #{authorizeId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteProductAuthorizeByAuthorizeIds" parameterType="String">
|
||||||
|
delete from iot_product_authorize where authorize_id in
|
||||||
|
<foreach item="authorizeId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{authorizeId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
||||||
@@ -12,6 +12,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<result property="tenantId" column="tenant_id" />
|
<result property="tenantId" column="tenant_id" />
|
||||||
<result property="tenantName" column="tenant_name" />
|
<result property="tenantName" column="tenant_name" />
|
||||||
<result property="isSys" column="is_sys" />
|
<result property="isSys" column="is_sys" />
|
||||||
|
<result property="isAuthorize" column="is_authorize" />
|
||||||
<result property="mqttAccount" column="mqtt_account" />
|
<result property="mqttAccount" column="mqtt_account" />
|
||||||
<result property="mqttPassword" column="mqtt_password" />
|
<result property="mqttPassword" column="mqtt_password" />
|
||||||
<result property="mqttSecret" column="mqtt_secret" />
|
<result property="mqttSecret" column="mqtt_secret" />
|
||||||
@@ -31,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectProductVo">
|
<sql id="selectProductVo">
|
||||||
select product_id, product_name, category_id, category_name, tenant_id, tenant_name, is_sys,mqtt_account,mqtt_password,mqtt_secret ,status, device_type, network_method, vertificate_method, create_time, update_time, img_url,remark from iot_product
|
select product_id, product_name, category_id, category_name, tenant_id, tenant_name, is_sys, is_authorize, mqtt_account,mqtt_password,mqtt_secret ,status, device_type, network_method, vertificate_method, create_time, update_time, img_url,remark from iot_product
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectProductList" parameterType="com.ruoyi.iot.domain.Product" resultMap="ProductResult">
|
<select id="selectProductList" parameterType="com.ruoyi.iot.domain.Product" resultMap="ProductResult">
|
||||||
@@ -43,6 +44,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
|
<if test="tenantId != null "> and tenant_id = #{tenantId}</if>
|
||||||
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
|
<if test="tenantName != null and tenantName != ''"> and tenant_name like concat('%', #{tenantName}, '%')</if>
|
||||||
<if test="isSys != null "> and is_sys = #{isSys}</if>
|
<if test="isSys != null "> and is_sys = #{isSys}</if>
|
||||||
|
<if test="isAuthorize != null "> and is_authorize = #{isAuthorize}</if>
|
||||||
<if test="status != null "> and status = #{status}</if>
|
<if test="status != null "> and status = #{status}</if>
|
||||||
<if test="deviceType != null "> and device_type = #{deviceType}</if>
|
<if test="deviceType != null "> and device_type = #{deviceType}</if>
|
||||||
<if test="networkMethod != null "> and network_method = #{networkMethod}</if>
|
<if test="networkMethod != null "> and network_method = #{networkMethod}</if>
|
||||||
@@ -70,6 +72,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="tenantId != null">tenant_id,</if>
|
<if test="tenantId != null">tenant_id,</if>
|
||||||
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
|
<if test="tenantName != null and tenantName != ''">tenant_name,</if>
|
||||||
<if test="isSys != null">is_sys,</if>
|
<if test="isSys != null">is_sys,</if>
|
||||||
|
<if test="isAuthorize != null">is_authorize,</if>
|
||||||
<if test="mqttAccount != null and mqttAccount != ''">mqtt_account,</if>
|
<if test="mqttAccount != null and mqttAccount != ''">mqtt_account,</if>
|
||||||
<if test="mqttPassword != null and mqttPassword != ''">mqtt_password,</if>
|
<if test="mqttPassword != null and mqttPassword != ''">mqtt_password,</if>
|
||||||
<if test="mqttSecret != null and mqttSecret != ''">mqtt_secret,</if>
|
<if test="mqttSecret != null and mqttSecret != ''">mqtt_secret,</if>
|
||||||
@@ -92,6 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="tenantId != null">#{tenantId},</if>
|
<if test="tenantId != null">#{tenantId},</if>
|
||||||
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
|
<if test="tenantName != null and tenantName != ''">#{tenantName},</if>
|
||||||
<if test="isSys != null">#{isSys},</if>
|
<if test="isSys != null">#{isSys},</if>
|
||||||
|
<if test="isAuthorize != null">#{isAuthorize},</if>
|
||||||
<if test="mqttAccount != null and mqttAccount != ''">#{mqttAccount},</if>
|
<if test="mqttAccount != null and mqttAccount != ''">#{mqttAccount},</if>
|
||||||
<if test="mqttPassword != null and mqttPassword != ''">#{mqttPassword},</if>
|
<if test="mqttPassword != null and mqttPassword != ''">#{mqttPassword},</if>
|
||||||
<if test="mqttSecret != null and mqttSecret != ''">#{mqttSecret},</if>
|
<if test="mqttSecret != null and mqttSecret != ''">#{mqttSecret},</if>
|
||||||
@@ -118,6 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="tenantId != null">tenant_id = #{tenantId},</if>
|
<if test="tenantId != null">tenant_id = #{tenantId},</if>
|
||||||
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
|
<if test="tenantName != null and tenantName != ''">tenant_name = #{tenantName},</if>
|
||||||
<if test="isSys != null">is_sys = #{isSys},</if>
|
<if test="isSys != null">is_sys = #{isSys},</if>
|
||||||
|
<if test="isAuthorize != null">is_authorize = #{isAuthorize},</if>
|
||||||
<if test="mqttAccount != null and mqttAccount != ''">mqtt_account = #{mqttAccount},</if>
|
<if test="mqttAccount != null and mqttAccount != ''">mqtt_account = #{mqttAccount},</if>
|
||||||
<if test="mqttPassword != null and mqttPassword != ''">mqtt_password = #{mqttPassword},</if>
|
<if test="mqttPassword != null and mqttPassword != ''">mqtt_password = #{mqttPassword},</if>
|
||||||
<if test="mqttSecret != null and mqttSecret != ''">mqtt_secret = #{mqttSecret},</if>
|
<if test="mqttSecret != null and mqttSecret != ''">mqtt_secret = #{mqttSecret},</if>
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
"screenfull": "5.0.2",
|
"screenfull": "5.0.2",
|
||||||
"sortablejs": "1.10.2",
|
"sortablejs": "1.10.2",
|
||||||
"vue": "2.6.12",
|
"vue": "2.6.12",
|
||||||
|
"vue-clipboard2": "^0.3.3",
|
||||||
"vue-count-to": "1.0.13",
|
"vue-count-to": "1.0.13",
|
||||||
"vue-cropper": "0.5.5",
|
"vue-cropper": "0.5.5",
|
||||||
"vue-json-viewer": "^2.2.21",
|
"vue-json-viewer": "^2.2.21",
|
||||||
|
|||||||
52
vue/src/api/iot/authorize.js
Normal file
52
vue/src/api/iot/authorize.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询产品授权码列表
|
||||||
|
export function listAuthorize(query) {
|
||||||
|
return request({
|
||||||
|
url: '/iot/authorize/list',
|
||||||
|
method: 'get',
|
||||||
|
params: query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询产品授权码详细
|
||||||
|
export function getAuthorize(authorizeId) {
|
||||||
|
return request({
|
||||||
|
url: '/iot/authorize/' + authorizeId,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增产品授权码
|
||||||
|
export function addAuthorize(data) {
|
||||||
|
return request({
|
||||||
|
url: '/iot/authorize',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据数量批量新增产品授权码
|
||||||
|
export function addProductAuthorizeByNum(data) {
|
||||||
|
return request({
|
||||||
|
url: '/iot/authorize/addProductAuthorizeByNum',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// 修改产品授权码
|
||||||
|
export function updateAuthorize(data) {
|
||||||
|
return request({
|
||||||
|
url: '/iot/authorize',
|
||||||
|
method: 'put',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除产品授权码
|
||||||
|
export function delAuthorize(authorizeId) {
|
||||||
|
return request({
|
||||||
|
url: '/iot/authorize/' + authorizeId,
|
||||||
|
method: 'delete'
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -39,6 +39,8 @@ import DictData from '@/components/DictData'
|
|||||||
import echarts from 'echarts'
|
import echarts from 'echarts'
|
||||||
// mqtt组件
|
// mqtt组件
|
||||||
import mqttClient from './views/iot/device/mqtt-client.vue'
|
import mqttClient from './views/iot/device/mqtt-client.vue'
|
||||||
|
// 一键复制粘贴板组件
|
||||||
|
import VueClipboard from 'vue-clipboard2'
|
||||||
|
|
||||||
// 全局方法挂载
|
// 全局方法挂载
|
||||||
Vue.prototype.getDicts = getDicts
|
Vue.prototype.getDicts = getDicts
|
||||||
@@ -60,7 +62,7 @@ Vue.component('Editor', Editor)
|
|||||||
Vue.component('FileUpload', FileUpload)
|
Vue.component('FileUpload', FileUpload)
|
||||||
Vue.component('ImageUpload', ImageUpload)
|
Vue.component('ImageUpload', ImageUpload)
|
||||||
Vue.component('mqtt-client',mqttClient)
|
Vue.component('mqtt-client',mqttClient)
|
||||||
|
Vue.use(VueClipboard)
|
||||||
Vue.use(directive)
|
Vue.use(directive)
|
||||||
Vue.use(plugins)
|
Vue.use(plugins)
|
||||||
Vue.use(VueMeta)
|
Vue.use(VueMeta)
|
||||||
|
|||||||
375
vue/src/views/iot/product/product-authorize.vue
Normal file
375
vue/src/views/iot/product/product-authorize.vue
Normal file
@@ -0,0 +1,375 @@
|
|||||||
|
<template>
|
||||||
|
<div style="padding-left:20px;">
|
||||||
|
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
|
||||||
|
<el-form-item label="授权码" prop="authorizeCode">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.authorizeCode"
|
||||||
|
placeholder="请输入授权码"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备ID" prop="deviceId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.deviceId"
|
||||||
|
placeholder="请输入设备ID"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备编号" prop="serialNumber">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.serialNumber"
|
||||||
|
placeholder="请输入设备编号"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户ID" prop="userId">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.userId"
|
||||||
|
placeholder="请输入用户ID"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户名称" prop="userName">
|
||||||
|
<el-input
|
||||||
|
v-model="queryParams.userName"
|
||||||
|
placeholder="请输入用户名称"
|
||||||
|
clearable
|
||||||
|
size="small"
|
||||||
|
@keyup.enter.native="handleQuery"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
||||||
|
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<el-row :gutter="10" class="mb8">
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-input-number
|
||||||
|
v-model="createNum"
|
||||||
|
controls-position=""
|
||||||
|
size="mini"
|
||||||
|
:min="1"
|
||||||
|
:max="100"
|
||||||
|
label="新增个数">
|
||||||
|
</el-input-number>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
icon="el-icon-plus"
|
||||||
|
size="mini"
|
||||||
|
@click="handleAdd"
|
||||||
|
v-hasPermi="['iot:authorize:add']"
|
||||||
|
>新增</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="success"
|
||||||
|
plain
|
||||||
|
icon="el-icon-edit"
|
||||||
|
size="mini"
|
||||||
|
:disabled="single"
|
||||||
|
@click="handleUpdate"
|
||||||
|
v-hasPermi="['iot:authorize:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-button
|
||||||
|
type="danger"
|
||||||
|
plain
|
||||||
|
icon="el-icon-delete"
|
||||||
|
size="mini"
|
||||||
|
:disabled="multiple"
|
||||||
|
@click="handleDelete"
|
||||||
|
v-hasPermi="['iot:authorize:remove']"
|
||||||
|
>删除</el-button>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="1.5">
|
||||||
|
<el-link type="danger" style="padding-top:5px" :underline="false">注意:绑定设备之后不可以删除。 Tips:双击可以复制授权码。</el-link>
|
||||||
|
</el-col>
|
||||||
|
<right-toolbar @queryTable="getList"></right-toolbar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-table v-loading="loading" :data="authorizeList" @selection-change="handleSelectionChange" @cell-dblclick="celldblclick">
|
||||||
|
<el-table-column type="selection" :selectable="selectable" width="55" align="center"/>
|
||||||
|
<el-table-column label="ID" width="55" align="center" prop="authorizeId" />
|
||||||
|
<el-table-column label="授权码" width="300" align="center" prop="authorizeCode" />
|
||||||
|
<el-table-column label="设备ID" width="75" align="center" prop="deviceId" />
|
||||||
|
<el-table-column label="设备编号" align="center" prop="serialNumber" />
|
||||||
|
<el-table-column label="用户ID" width="75" align="center" prop="userId" />
|
||||||
|
<el-table-column label="用户名称" align="center" prop="userName" />
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" width="180">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<span>{{ parseTime(scope.row.updateTime, '{y}-{m}-{d} {h}:{m}:{s}') }}</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" />
|
||||||
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-edit"
|
||||||
|
@click="handleUpdate(scope.row)"
|
||||||
|
v-hasPermi="['iot:authorize:edit']"
|
||||||
|
>修改</el-button>
|
||||||
|
<el-button
|
||||||
|
size="mini"
|
||||||
|
type="text"
|
||||||
|
icon="el-icon-delete"
|
||||||
|
@click="handleDelete(scope.row)"
|
||||||
|
v-hasPermi="['iot:authorize:remove']"
|
||||||
|
v-if="!scope.row.deviceId"
|
||||||
|
>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<pagination
|
||||||
|
v-show="total>0"
|
||||||
|
:total="total"
|
||||||
|
:page.sync="queryParams.pageNum"
|
||||||
|
:limit.sync="queryParams.pageSize"
|
||||||
|
@pagination="getList"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<!-- 添加或修改产品授权码对话框 -->
|
||||||
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
||||||
|
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||||
|
<el-form-item label="设备ID" prop="deviceId">
|
||||||
|
<el-input v-model="form.deviceId" placeholder="请输入设备ID" onkeyup="value=value.replace(/[^\d]/g,'')" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="设备编号" prop="serialNumber">
|
||||||
|
<el-input v-model="form.serialNumber" placeholder="请输入设备编号" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户ID" prop="userId">
|
||||||
|
<el-input v-model="form.userId" placeholder="请输入用户ID" onkeyup="value=value.replace(/[^\d]/g,'')" max=""/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="用户名称" prop="userName">
|
||||||
|
<el-input v-model="form.userName" placeholder="请输入用户名称" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="备注" prop="remark">
|
||||||
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div slot="footer" class="dialog-footer">
|
||||||
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||||
|
<el-button @click="cancel">取 消</el-button>
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.specsColor {
|
||||||
|
background-color: #fcfcfc;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listAuthorize, getAuthorize, delAuthorize, addProductAuthorizeByNum, updateAuthorize } from "@/api/iot/authorize";
|
||||||
|
import { isNumberStr } from '@/utils/index'
|
||||||
|
export default {
|
||||||
|
name: "product-authorize",
|
||||||
|
props: {
|
||||||
|
product: {
|
||||||
|
type: Object,
|
||||||
|
default: null
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
// 获取到父组件传递的productId后,刷新列表
|
||||||
|
product: function (newVal, oldVal) {
|
||||||
|
this.productInfo = newVal;
|
||||||
|
if (this.productInfo && this.productInfo.productId != 0) {
|
||||||
|
this.queryParams.productId = this.productInfo.productId;
|
||||||
|
this.getList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
// 遮罩层
|
||||||
|
loading: true,
|
||||||
|
// 选中数组
|
||||||
|
ids: [],
|
||||||
|
// 非单个禁用
|
||||||
|
single: true,
|
||||||
|
// 非多个禁用
|
||||||
|
multiple: true,
|
||||||
|
// 显示搜索条件
|
||||||
|
showSearch: true,
|
||||||
|
// 总条数
|
||||||
|
total: 0,
|
||||||
|
// 产品授权码表格数据
|
||||||
|
authorizeList: [],
|
||||||
|
// 弹出层标题
|
||||||
|
title: "",
|
||||||
|
// 是否显示弹出层
|
||||||
|
open: false,
|
||||||
|
// 新增个数
|
||||||
|
createNum: 0,
|
||||||
|
// 查询参数
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
authorizeCode: null,
|
||||||
|
productId: null,
|
||||||
|
deviceId: null,
|
||||||
|
serialNumber: null,
|
||||||
|
userId: null,
|
||||||
|
userName: null,
|
||||||
|
},
|
||||||
|
// 表单参数
|
||||||
|
form: {},
|
||||||
|
// 表单校验
|
||||||
|
rules: {
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
/** 查询产品授权码列表 */
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
listAuthorize(this.queryParams).then(response => {
|
||||||
|
this.authorizeList = response.rows;
|
||||||
|
this.total = response.total;
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 取消按钮
|
||||||
|
cancel() {
|
||||||
|
this.open = false;
|
||||||
|
this.reset();
|
||||||
|
},
|
||||||
|
// 表单重置
|
||||||
|
reset() {
|
||||||
|
this.form = {
|
||||||
|
authorizeId: null,
|
||||||
|
authorizeCode: null,
|
||||||
|
productId: "",
|
||||||
|
deviceId: null,
|
||||||
|
serialNumber: null,
|
||||||
|
userId: "",
|
||||||
|
userName: null,
|
||||||
|
delFlag: null,
|
||||||
|
createBy: null,
|
||||||
|
createTime: null,
|
||||||
|
updateBy: null,
|
||||||
|
updateTime: null,
|
||||||
|
remark: null
|
||||||
|
};
|
||||||
|
this.resetForm("form");
|
||||||
|
},
|
||||||
|
/** 搜索按钮操作 */
|
||||||
|
handleQuery() {
|
||||||
|
this.queryParams.pageNum = 1;
|
||||||
|
this.getList();
|
||||||
|
},
|
||||||
|
/** 重置按钮操作 */
|
||||||
|
resetQuery() {
|
||||||
|
this.resetForm("queryForm");
|
||||||
|
this.handleQuery();
|
||||||
|
},
|
||||||
|
// 多选框选中数据
|
||||||
|
handleSelectionChange(selection) {
|
||||||
|
this.ids = selection.map(item => item.authorizeId)
|
||||||
|
this.single = selection.lengdelAuthorizeth!==1
|
||||||
|
this.multiple = !selection.length
|
||||||
|
},
|
||||||
|
/** 批量新增按钮操作 */
|
||||||
|
handleAdd() {
|
||||||
|
if (this.queryParams.productId != null) {
|
||||||
|
let _addData = {
|
||||||
|
productId : this.queryParams.productId,
|
||||||
|
createNum : this.createNum
|
||||||
|
}
|
||||||
|
addProductAuthorizeByNum(_addData).then(response => {
|
||||||
|
this.$modal.msgSuccess("新增成功");
|
||||||
|
this.getList();
|
||||||
|
this.createNum = 1;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/** 修改按钮操作 */
|
||||||
|
handleUpdate(row) {
|
||||||
|
this.reset();
|
||||||
|
const authorizeId = row.authorizeId || this.ids
|
||||||
|
getAuthorize(authorizeId).then(response => {
|
||||||
|
this.form = response.data;
|
||||||
|
this.open = true;
|
||||||
|
this.title = "修改产品授权码信息";
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 提交按钮 */
|
||||||
|
submitForm() {
|
||||||
|
this.$refs["form"].validate(valid => {
|
||||||
|
if (valid) {
|
||||||
|
if (this.form.authorizeId != null) {
|
||||||
|
updateAuthorize(this.form).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.open = false;
|
||||||
|
this.getList();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
/** 删除按钮操作 */
|
||||||
|
handleDelete(row) {
|
||||||
|
const authorizeIds = row.authorizeId || this.ids;
|
||||||
|
this.$modal.confirm('是否确认删除产品授权码编号为"' + authorizeIds + '"的数据项?').then(function() {
|
||||||
|
return delAuthorize(authorizeIds);
|
||||||
|
}).then(() => {
|
||||||
|
this.getList();
|
||||||
|
this.$modal.msgSuccess("删除成功");
|
||||||
|
}).catch(() => {});
|
||||||
|
},
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
handleExport() {
|
||||||
|
this.download('iot/authorize/export', {
|
||||||
|
...this.queryParams
|
||||||
|
}, `authorize_${new Date().getTime()}.xlsx`)
|
||||||
|
},
|
||||||
|
handleChange(e){
|
||||||
|
console.log(currentValue)
|
||||||
|
if (!isNumberStr(currentValue)) {
|
||||||
|
this.$modal.msgSuccess("只能输入数字");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//禁用有绑定设备的复选框
|
||||||
|
selectable(row){
|
||||||
|
return row.deviceId != null ? false : true;
|
||||||
|
},
|
||||||
|
//表格增加复制功能
|
||||||
|
celldblclick (row, column, cell, event) {
|
||||||
|
this.$copyText(row[column.property]).then(e=> {
|
||||||
|
this.onCopy()
|
||||||
|
}, function (e) {
|
||||||
|
this.onError()
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onCopy() {
|
||||||
|
this.$notify({title: '成功', message: '复制成功!', type: 'success', offset: 50, duration: 2000})
|
||||||
|
},
|
||||||
|
onError() {
|
||||||
|
this.$notify({title: '失败', message: '复制失败!', type: 'error', offset: 50, duration: 2000})
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
@@ -19,6 +19,9 @@
|
|||||||
<el-option v-for="dict in dict.type.iot_network_method" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
|
<el-option v-for="dict in dict.type.iot_network_method" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item label="授权码开关" prop="networkMethod">
|
||||||
|
<el-switch v-model="form.isAuthorize" @change="changeIsAuthorize(form.isAuthorize)" :active-value="1" :inactive-value="0" />
|
||||||
|
</el-form-item>
|
||||||
<el-form-item label="备注信息" prop="remark">
|
<el-form-item label="备注信息" prop="remark">
|
||||||
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="7" />
|
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" rows="7" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -83,6 +86,11 @@
|
|||||||
<product-app ref="productApp" :product="form" />
|
<product-app ref="productApp" :product="form" />
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
|
|
||||||
|
<el-tab-pane label="" name="productAuthorize" :disabled="form.isAuthorize==0">
|
||||||
|
<span slot="label">授权码</span>
|
||||||
|
<product-authorize ref="productAuthorize" :product="form" />
|
||||||
|
</el-tab-pane>
|
||||||
|
|
||||||
<el-tab-pane label="" disabled name="product01" />
|
<el-tab-pane label="" disabled name="product01" />
|
||||||
<el-tab-pane label="" disabled name="product02" />
|
<el-tab-pane label="" disabled name="product02" />
|
||||||
<el-tab-pane label="" disabled name="product03" />
|
<el-tab-pane label="" disabled name="product03" />
|
||||||
@@ -110,6 +118,7 @@
|
|||||||
import productThingsModel from "./product-things-model";
|
import productThingsModel from "./product-things-model";
|
||||||
import productApp from "./product-app"
|
import productApp from "./product-app"
|
||||||
import productAlert from "./product-alert"
|
import productAlert from "./product-alert"
|
||||||
|
import productAuthorize from "./product-authorize"
|
||||||
import imageUpload from "../../../components/ImageUpload/index"
|
import imageUpload from "../../../components/ImageUpload/index"
|
||||||
import {
|
import {
|
||||||
listShortCategory
|
listShortCategory
|
||||||
@@ -128,6 +137,7 @@ export default {
|
|||||||
productThingsModel,
|
productThingsModel,
|
||||||
productApp,
|
productApp,
|
||||||
productAlert,
|
productAlert,
|
||||||
|
productAuthorize,
|
||||||
imageUpload,
|
imageUpload,
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
@@ -202,6 +212,7 @@ export default {
|
|||||||
categoryName: null,
|
categoryName: null,
|
||||||
status: 0,
|
status: 0,
|
||||||
tslJson: null,
|
tslJson: null,
|
||||||
|
isAuthorize: 0,
|
||||||
deviceType: 1,
|
deviceType: 1,
|
||||||
networkMethod: 1,
|
networkMethod: 1,
|
||||||
vertificateMethod: 3,
|
vertificateMethod: 3,
|
||||||
@@ -282,6 +293,16 @@ export default {
|
|||||||
} else if (name == "password") {
|
} else if (name == "password") {
|
||||||
this.passwordInputType = this.passwordInputType == "password" ? "text" : "password";
|
this.passwordInputType = this.passwordInputType == "password" ? "text" : "password";
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
// 授权码状态修改
|
||||||
|
changeIsAuthorize() {
|
||||||
|
let text = this.form.isAuthorize === "1" ? "启用" : "停用";
|
||||||
|
let _this = this;
|
||||||
|
this.$modal.confirm('确认要[' + text + ']' + this.form.productName + '授权码吗?').then(function() {
|
||||||
|
_this.submitForm();
|
||||||
|
}).catch(() => {
|
||||||
|
this.form.isAuthorize = 0;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user