mqtt账号信息录入判断
This commit is contained in:
@@ -67,10 +67,14 @@ public class EquipmentDeliveryController extends BaseController {
|
|||||||
@DeviceLog(operateType = DeviceOperate.ADD)
|
@DeviceLog(operateType = DeviceOperate.ADD)
|
||||||
public HttpResult<Boolean> addEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm){
|
public HttpResult<Boolean> addEquipmentDelivery(@RequestBody @Validated CsEquipmentDeliveryAddParm csEquipmentDeliveryAddParm){
|
||||||
String methodDescribe = getMethodDescribe("addEquipmentDelivery");
|
String methodDescribe = getMethodDescribe("addEquipmentDelivery");
|
||||||
Boolean flag = csEquipmentDeliveryService.save (csEquipmentDeliveryAddParm);
|
Boolean flag = csEquipmentDeliveryService.save(csEquipmentDeliveryAddParm);
|
||||||
if (flag){
|
if (flag){
|
||||||
//初始化装置mqtt连接信息(使用sha256加密)
|
//查询mqtt用户名和密码是否存在
|
||||||
mqttUserService.insertMqttUser(csEquipmentDeliveryAddParm.getNdid());
|
boolean result = mqttUserService.findMqttUser(csEquipmentDeliveryAddParm.getNdid());
|
||||||
|
if (result){
|
||||||
|
//初始化装置mqtt连接信息(使用sha256加密)
|
||||||
|
mqttUserService.insertMqttUser(csEquipmentDeliveryAddParm.getNdid());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,13 @@ import com.njcn.csdevice.pojo.po.MqttUser;
|
|||||||
*/
|
*/
|
||||||
public interface IMqttUserService extends IService<MqttUser> {
|
public interface IMqttUserService extends IService<MqttUser> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询新增的mqtt用户名和密码是否存在
|
||||||
|
* @param userName 用户名
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
boolean findMqttUser(String userName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据密码生成mqtt连接信息
|
* 根据密码生成mqtt连接信息
|
||||||
* @param password
|
* @param password
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.njcn.csdevice.pojo.po.MqttUser;
|
|||||||
import com.njcn.csdevice.service.IMqttUserService;
|
import com.njcn.csdevice.service.IMqttUserService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -23,6 +24,12 @@ import java.util.Random;
|
|||||||
@DS("mqtt")
|
@DS("mqtt")
|
||||||
public class MqttUserServiceImpl extends ServiceImpl<MqttUserMapper, MqttUser> implements IMqttUserService {
|
public class MqttUserServiceImpl extends ServiceImpl<MqttUserMapper, MqttUser> implements IMqttUserService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean findMqttUser(String userName) {
|
||||||
|
MqttUser mqttUser = this.lambdaQuery().eq(MqttUser::getUsername,userName).one();
|
||||||
|
return Objects.isNull(mqttUser);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void insertMqttUser(String password) {
|
public void insertMqttUser(String password) {
|
||||||
Random r = new Random();
|
Random r = new Random();
|
||||||
|
|||||||
Reference in New Issue
Block a user