use of com.ruoyi.common.core.domain.entity.SysUser in project wumei-smart by kerwincui.
the class DeviceServiceImpl method insertDeviceAuto.
/**
* 设备认证后自动添加设备
*
* @return 结果
*/
@Override
public int insertDeviceAuto(String serialNumber, Long userId, Long productId) {
Device device = new Device();
int random = (int) (Math.random() * (9000)) + 1000;
device.setDeviceName("设备" + random);
device.setSerialNumber(serialNumber);
SysUser user = userService.selectUserById(userId);
device.setUserId(userId);
device.setUserName(user.getUserName());
Product product = productService.selectProductByProductId(productId);
device.setProductId(productId);
device.setProductName(product.getProductName());
device.setTenantId(userId);
device.setTenantName(user.getUserName());
device.setFirmwareVersion(BigDecimal.valueOf(1.0));
device.setStatus(3);
device.setActiveTime(DateUtils.getNowDate());
device.setIsShadow(0);
device.setRssi(0);
device.setIsCustomLocation(0);
device.setCreateTime(DateUtils.getNowDate());
device.setThingsModelValue(JSONObject.toJSONString(getThingsModelDefaultValue(device.getProductId())));
return deviceMapper.insertDevice(device);
}
use of com.ruoyi.common.core.domain.entity.SysUser in project wumei-smart by kerwincui.
the class DeviceServiceImpl method insertDevice.
/**
* 新增设备
*
* @param device 设备
* @return 结果
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Device insertDevice(Device device) {
SysUser sysUser = getLoginUser().getUser();
// 添加设备
device.setCreateTime(DateUtils.getNowDate());
device.setThingsModelValue(JSONObject.toJSONString(getThingsModelDefaultValue(device.getProductId())));
device.setUserId(sysUser.getUserId());
device.setUserName(sysUser.getUserName());
device.setTenantId(sysUser.getUserId());
device.setTenantName(sysUser.getUserName());
device.setRssi(0);
deviceMapper.insertDevice(device);
// deviceUserMapper.insertDeviceUser(deviceUser);
return device;
}
use of com.ruoyi.common.core.domain.entity.SysUser in project wumei-smart by kerwincui.
the class DeviceUserServiceImpl method insertDeviceUser.
/**
* 新增设备用户
*
* @param deviceUser 设备用户
* @return 结果
*/
@Override
public int insertDeviceUser(DeviceUser deviceUser) {
List<DeviceUser> deviceUsers = selectDeviceUserList(deviceUser);
if (!deviceUsers.isEmpty())
throw new RuntimeException("该用户已添加, 禁止重复添加");
deviceUser.setCreateTime(DateUtils.getNowDate());
deviceUser.setIsOwner(0);
SysUser sysUser = getLoginUser().getUser();
deviceUser.setTenantId(sysUser.getUserId());
deviceUser.setTenantName(sysUser.getUserName());
return deviceUserMapper.insertDeviceUser(deviceUser);
}
use of com.ruoyi.common.core.domain.entity.SysUser in project wumei-smart by kerwincui.
the class ProductAuthorizeServiceImpl method addProductAuthorizeByNum.
/**
* 根据数量批量新增产品授权码
* @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);
}
use of com.ruoyi.common.core.domain.entity.SysUser in project wumei-smart by kerwincui.
the class SocialLoginServiceImpl method callback.
@Override
public String callback(String source, AuthCallback authCallback, HttpServletRequest httpServletRequest) {
AuthRequestWrap authRequestWrap = null;
try {
authRequestWrap = iAuthRequestFactory.getAuthRequest(source);
checkSocialPlatform(authRequestWrap.getSocialPlatform());
AuthResponse<AuthUser> authResponse = authRequestWrap.getAuthRequest().login(authCallback);
String bindId = null;
String loginId = null;
if (authResponse.ok()) {
SocialUser socialUser = findSocialUser(authResponse.getData().getUuid(), authResponse.getData().getSource());
createOrUpdateSocialUser(socialUser, authResponse.getData());
if (socialUser == null) {
// 第一次登录
bindId = genBindId(authResponse.getData());
} else if (socialUser.getSysUserId() == null || socialUser.getSysUserId() <= 0) {
// 初次绑定
bindId = genBindId(authResponse.getData());
} else {
// 查看是否已经绑定
SysUser sysUser = iSysUserService.selectUserById(socialUser.getSysUserId());
if (sysUser == null) {
bindId = genBindId(authResponse.getData());
} else {
// 直接登录跳转
loginId = genLoginId(sysUser);
}
}
if (StringUtils.isNotEmpty(bindId)) {
return authRequestWrap.getSocialPlatform().getBindUri() + bindId;
} else {
return authRequestWrap.getSocialPlatform().getRedirectLoginUri() + loginId;
}
} else {
log.error("登录授权异常,code:{}, msg:{}", authResponse.getCode(), authResponse.getMsg());
String errorId = genErrorId(authResponse.getMsg());
return authRequestWrap.getSocialPlatform().getErrorMsgUri() + errorId;
}
} catch (AuthException authException) {
// 返回错误信息
log.error("", authException);
if (authRequestWrap != null) {
String errorId = genErrorId(authException.getMessage());
return authRequestWrap.getSocialPlatform().getErrorMsgUri() + errorId;
} else {
return httpServletRequest.getServerName() + httpServletRequest.getServerPort();
}
} catch (Exception exception) {
log.error("", exception);
return HTTPS + httpServletRequest.getServerName();
}
}
Aggregations