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