Compare commits
15 Commits
main
...
f1d1528c40
Author | SHA1 | Date | |
---|---|---|---|
f1d1528c40 | |||
4e608b8f3a | |||
3c2d97aaf2 | |||
6ed1241a6d | |||
1cf7c47ef9 | |||
bdee8c8383 | |||
6f4e18fb3f | |||
3ca6b69709 | |||
e13e3c57a6 | |||
56704f6014 | |||
4f00c69f91 | |||
fcd17634dc | |||
24f0caacd5 | |||
c73a700210 | |||
3ed2f97752 |
@ -94,10 +94,10 @@
|
||||
</dependency>
|
||||
|
||||
<!-- demo模块 -->
|
||||
<!--<dependency>
|
||||
<dependency>
|
||||
<groupId>com.fuyuanshen</groupId>
|
||||
<artifactId>fys-demo</artifactId>
|
||||
</dependency>-->
|
||||
</dependency>
|
||||
|
||||
<!-- 工作流模块 -->
|
||||
<dependency>
|
||||
|
@ -4,14 +4,13 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.app.model.AppSmsLoginBody;
|
||||
import com.fuyuanshen.app.service.AppLoginService;
|
||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.domain.model.RegisterBody;
|
||||
import com.fuyuanshen.common.core.domain.model.SmsLoginBody;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginBody;
|
||||
import com.fuyuanshen.common.core.domain.model.AppSmsRegisterBody;
|
||||
import com.fuyuanshen.common.core.domain.model.PasswordLoginBody;
|
||||
import com.fuyuanshen.common.core.utils.*;
|
||||
import com.fuyuanshen.common.encrypt.annotation.ApiEncrypt;
|
||||
import com.fuyuanshen.common.json.utils.JsonUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||
@ -24,8 +23,8 @@ import com.fuyuanshen.system.service.ISysTenantService;
|
||||
import com.fuyuanshen.web.domain.vo.LoginTenantVo;
|
||||
import com.fuyuanshen.web.domain.vo.LoginVo;
|
||||
import com.fuyuanshen.web.domain.vo.TenantListVo;
|
||||
import com.fuyuanshen.web.service.AppRegisterService;
|
||||
import com.fuyuanshen.web.service.IAuthStrategy;
|
||||
import com.fuyuanshen.web.service.SysRegisterService;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -51,7 +50,7 @@ import java.util.List;
|
||||
public class AppAuthController {
|
||||
|
||||
private final AppLoginService loginService;
|
||||
private final SysRegisterService registerService;
|
||||
private final AppRegisterService registerService;
|
||||
private final ISysConfigService configService;
|
||||
private final ISysTenantService tenantService;
|
||||
private final ISysClientService clientService;
|
||||
@ -64,15 +63,15 @@ public class AppAuthController {
|
||||
*/
|
||||
// @ApiEncrypt
|
||||
@PostMapping("/login")
|
||||
public R<LoginVo> login(@RequestBody AppSmsLoginBody appSmsLoginBody) {
|
||||
public R<LoginVo> login(@RequestBody AppLoginBody appLoginBody) {
|
||||
// SmsLoginBody loginBody = JsonUtils.parseObject(body, SmsLoginBody.class);
|
||||
ValidatorUtils.validate(appSmsLoginBody);
|
||||
SmsLoginBody loginBody = new SmsLoginBody();
|
||||
loginBody.setPhonenumber(appSmsLoginBody.getPhonenumber());
|
||||
loginBody.setSmsCode(appSmsLoginBody.getSmsCode());
|
||||
loginBody.setTenantId(appSmsLoginBody.getTenantId());
|
||||
loginBody.setClientId("ca839698e245d60aa2f0e59bd52b34f8");
|
||||
loginBody.setGrantType("appSms");
|
||||
ValidatorUtils.validate(appLoginBody);
|
||||
PasswordLoginBody loginBody = new PasswordLoginBody();
|
||||
loginBody.setUsername(appLoginBody.getUserName());
|
||||
loginBody.setPassword(appLoginBody.getPassword());
|
||||
loginBody.setTenantId(appLoginBody.getTenantId());
|
||||
loginBody.setClientId("835b15335d389c9fcfdf99421fa8019b");
|
||||
loginBody.setGrantType("appPassword");
|
||||
// 授权类型和客户端id
|
||||
String clientId = loginBody.getClientId();
|
||||
String grantType = loginBody.getGrantType();
|
||||
@ -107,12 +106,8 @@ public class AppAuthController {
|
||||
/**
|
||||
* 用户注册
|
||||
*/
|
||||
@ApiEncrypt
|
||||
@PostMapping("/register")
|
||||
public R<Void> register(@Validated @RequestBody RegisterBody user) {
|
||||
if (!configService.selectRegisterEnabled(user.getTenantId())) {
|
||||
return R.fail("当前系统没有开启注册功能!");
|
||||
}
|
||||
public R<Void> register(@Validated @RequestBody AppSmsRegisterBody user) {
|
||||
registerService.register(user);
|
||||
return R.ok();
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@ -102,7 +101,7 @@ public class AppDeviceController extends BaseController {
|
||||
* 发送信息
|
||||
*/
|
||||
@PostMapping(value = "/sendMessage")
|
||||
public R<Void> sendMessage(@RequestBody AppDeviceSendMsgBo bo) {
|
||||
public R<Void> sendMessage(@RequestBody AppDeviceBo bo) {
|
||||
return toAjax(appDeviceService.sendMessage(bo));
|
||||
}
|
||||
}
|
||||
|
@ -55,14 +55,6 @@ public class AppDeviceShareController extends BaseController {
|
||||
return deviceShareService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 他人分享管理列表
|
||||
*/
|
||||
@GetMapping("/otherDeviceShareList")
|
||||
public TableDataInfo<AppDeviceShareVo> otherDeviceShareList(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||
return deviceShareService.otherDeviceShareList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取设备分享详细信息
|
||||
*
|
||||
|
@ -0,0 +1,62 @@
|
||||
package com.fuyuanshen.app.controller;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordSmsDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPUpdateUserDTO;
|
||||
import com.fuyuanshen.app.domain.vo.APPUserInfoVo;
|
||||
import com.fuyuanshen.app.service.IAppUserService;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* APP 用户管理
|
||||
* @date 2025-06-27
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/app/user")
|
||||
public class AppUserController extends BaseController {
|
||||
|
||||
private final IAppUserService appUserService;
|
||||
|
||||
/**
|
||||
* 个人中心
|
||||
*/
|
||||
@GetMapping("/getUserInfo")
|
||||
public R<APPUserInfoVo> getUserInfo() {
|
||||
return R.ok(appUserService.getUserInfo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改个人信息
|
||||
*/
|
||||
@PostMapping("/updateUser")
|
||||
public R<Void> updateUser(@Validated @ModelAttribute APPUpdateUserDTO bo) {
|
||||
return toAjax(appUserService.updateUser(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 忘记密码
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/forgotPassword")
|
||||
public R<Void> forgotPassword(@RequestBody APPForgotPasswordDTO bo) {
|
||||
return toAjax(appUserService.forgotPassword(bo));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 发送忘记密码短信
|
||||
*/
|
||||
@SaIgnore
|
||||
@PostMapping("/sendForgotPasswordSms")
|
||||
public R<Void> sendForgotPasswordSms(@Validated @RequestBody APPForgotPasswordSmsDTO dto) throws Exception {
|
||||
return toAjax(appUserService.sendForgotPasswordSms(dto));
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -12,33 +11,25 @@ import com.fuyuanshen.app.domain.vo.AppDeviceDetailVo;
|
||||
import com.fuyuanshen.app.domain.vo.AppPersonnelInfoVo;
|
||||
import com.fuyuanshen.app.mapper.AppPersonnelInfoMapper;
|
||||
import com.fuyuanshen.app.mapper.equipment.APPDeviceMapper;
|
||||
import com.fuyuanshen.common.core.exception.ServiceException;
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.common.core.utils.ObjectUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceBo;
|
||||
import com.fuyuanshen.equipment.domain.dto.AppDeviceSendMsgBo;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
|
||||
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||
import com.fuyuanshen.equipment.utils.c.ReliableTextToBitmap;
|
||||
import com.fuyuanshen.system.mqtt.config.MqttGateway;
|
||||
import com.fuyuanshen.system.mqtt.constants.MqttConstants;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@ -50,7 +41,6 @@ public class AppDeviceBizService {
|
||||
private final DeviceMapper deviceMapper;
|
||||
private final AppPersonnelInfoMapper appPersonnelInfoMapper;
|
||||
private final DeviceTypeMapper deviceTypeMapper;
|
||||
private final MqttGateway mqttGateway;
|
||||
|
||||
|
||||
public List<APPDeviceTypeVo> getTypeList() {
|
||||
@ -67,31 +57,12 @@ public class AppDeviceBizService {
|
||||
}
|
||||
|
||||
|
||||
public int sendMessage(AppDeviceSendMsgBo bo) {
|
||||
List<Long> deviceIds = bo.getDeviceIds();
|
||||
if(deviceIds == null || deviceIds.isEmpty()){
|
||||
throw new ServiceException("请选择设备");
|
||||
}
|
||||
for (Long deviceId : deviceIds){
|
||||
Device deviceObj = deviceMapper.selectById(deviceId);
|
||||
if(deviceObj==null) {
|
||||
throw new ServiceException("设备不存在"+deviceId);
|
||||
}
|
||||
|
||||
byte[] msg = ReliableTextToBitmap.textToBitmapBytes(bo.getSendMsg());
|
||||
Map<String,Object> linkHashMap = new HashMap<>();
|
||||
linkHashMap.put("message",msg);
|
||||
String sendMsg = JSON.toJSONString(linkHashMap);
|
||||
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY+deviceObj.getDeviceImei(), 1 ,sendMsg);
|
||||
log.info("发送设备消息:{}", bo.getSendMsg());
|
||||
|
||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", deviceId)
|
||||
.eq("binding_user_id", AppLoginHelper.getUserId())
|
||||
.set("send_msg", bo.getSendMsg());
|
||||
deviceMapper.update(updateWrapper);
|
||||
}
|
||||
return 1;
|
||||
public int sendMessage(AppDeviceBo bo) {
|
||||
UpdateWrapper<Device> updateWrapper = new UpdateWrapper<>();
|
||||
updateWrapper.eq("id", bo.getDeviceId())
|
||||
.eq("binding_user_id", AppLoginHelper.getUserId())
|
||||
.set("send_msg", bo.getSendMsg());
|
||||
return deviceMapper.update(updateWrapper);
|
||||
}
|
||||
|
||||
|
||||
@ -167,9 +138,6 @@ public class AppDeviceBizService {
|
||||
|
||||
public AppDeviceDetailVo getInfo(Long id) {
|
||||
Device device = deviceMapper.selectById(id);
|
||||
if (device == null) {
|
||||
throw new RuntimeException("请先将设备入库!!!");
|
||||
}
|
||||
AppDeviceDetailVo vo = new AppDeviceDetailVo();
|
||||
vo.setDeviceId(device.getId());
|
||||
vo.setDeviceName(device.getDeviceName());
|
||||
@ -184,11 +152,7 @@ public class AppDeviceBizService {
|
||||
}
|
||||
vo.setBluetoothName(device.getBluetoothName());
|
||||
|
||||
vo.setSendMsg(device.getSendMsg());
|
||||
|
||||
QueryWrapper<AppPersonnelInfo> qw = new QueryWrapper<AppPersonnelInfo>()
|
||||
.eq("device_id", device.getId());
|
||||
AppPersonnelInfo appPersonnelInfo = appPersonnelInfoMapper.selectOne(qw);
|
||||
AppPersonnelInfo appPersonnelInfo = appPersonnelInfoMapper.selectById(device.getId());
|
||||
if(appPersonnelInfo != null){
|
||||
AppPersonnelInfoVo personnelInfoVo = MapstructUtils.convert(appPersonnelInfo, AppPersonnelInfoVo.class);
|
||||
vo.setPersonnelInfo(personnelInfoVo);
|
||||
@ -197,41 +161,7 @@ public class AppDeviceBizService {
|
||||
}
|
||||
|
||||
public boolean registerPersonInfo(AppPersonnelInfoBo bo) {
|
||||
Long deviceId = bo.getDeviceId();
|
||||
Device deviceObj = deviceMapper.selectById(deviceId);
|
||||
if(deviceObj == null){
|
||||
throw new RuntimeException("请先将设备入库!!!");
|
||||
}
|
||||
QueryWrapper<AppPersonnelInfo> qw = new QueryWrapper<AppPersonnelInfo>()
|
||||
.eq("device_id", deviceId);
|
||||
List<AppPersonnelInfoVo> appPersonnelInfoVos = appPersonnelInfoMapper.selectVoList(qw);
|
||||
// unitName,position,name,id
|
||||
byte[] unitName = ReliableTextToBitmap.textToBitmapBytes(bo.getUnitName());
|
||||
byte[] position = ReliableTextToBitmap.textToBitmapBytes(bo.getPosition());
|
||||
byte[] name = ReliableTextToBitmap.textToBitmapBytes(bo.getName());
|
||||
byte[] id = ReliableTextToBitmap.textToBitmapBytes(bo.getCode());
|
||||
Map<String,Object> linkHashMap = new HashMap<>();
|
||||
linkHashMap.put("unitName",unitName);
|
||||
linkHashMap.put("position",position);
|
||||
linkHashMap.put("name",name);
|
||||
linkHashMap.put("id",id);
|
||||
String personnelInfo = JSON.toJSONString(linkHashMap);
|
||||
mqttGateway.sendMsgToMqtt(MqttConstants.GLOBAL_PUB_KEY+deviceObj.getDeviceImei(), 1 ,personnelInfo);
|
||||
log.info("发送点阵数据到设备消息:{}", bo);
|
||||
|
||||
if(ObjectUtils.length(appPersonnelInfoVos) == 0){
|
||||
AppPersonnelInfo appPersonnelInfo = MapstructUtils.convert(bo, AppPersonnelInfo.class);
|
||||
return appPersonnelInfoMapper.insertOrUpdate(appPersonnelInfo);
|
||||
}else {
|
||||
UpdateWrapper<AppPersonnelInfo> uw = new UpdateWrapper<>();
|
||||
uw.eq("device_id", deviceId)
|
||||
.set("name", bo.getName())
|
||||
.set("position", bo.getPosition())
|
||||
.set("unit_name", bo.getUnitName())
|
||||
.set("code",bo.getCode());
|
||||
return appPersonnelInfoMapper.update(null, uw)>0;
|
||||
}
|
||||
|
||||
|
||||
AppPersonnelInfo appPersonnelInfo = MapstructUtils.convert(bo, AppPersonnelInfo.class);
|
||||
return appPersonnelInfoMapper.insertOrUpdate(appPersonnelInfo);
|
||||
}
|
||||
}
|
||||
|
@ -95,10 +95,7 @@ public class AppDeviceShareService {
|
||||
return code.equals(smsCode);
|
||||
}
|
||||
public int deviceShare(AppDeviceShareBo bo) {
|
||||
boolean flag = validateSmsCode(AppLoginHelper.getTenantId(), bo.getPhonenumber(), bo.getSmsCode());
|
||||
if(!flag){
|
||||
throw new ServiceException("验证码错误");
|
||||
}
|
||||
validateSmsCode(AppLoginHelper.getTenantId(), bo.getPhonenumber(), bo.getSmsCode());
|
||||
|
||||
Device device = deviceMapper.selectById(bo.getDeviceId());
|
||||
if(device==null){
|
||||
|
@ -2,14 +2,11 @@ package com.fuyuanshen.app.service;
|
||||
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.fuyuanshen.app.domain.vo.AppRoleVo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.common.core.constant.Constants;
|
||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||
import com.fuyuanshen.common.core.constant.TenantConstants;
|
||||
import com.fuyuanshen.common.core.domain.dto.RoleDTO;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
|
||||
import com.fuyuanshen.common.core.enums.LoginType;
|
||||
import com.fuyuanshen.common.core.exception.user.UserException;
|
||||
@ -31,7 +28,10 @@ import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,129 @@
|
||||
package com.fuyuanshen.web.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.mapper.AppUserMapper;
|
||||
import com.fuyuanshen.common.core.constant.Constants;
|
||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||
import com.fuyuanshen.common.core.domain.model.AppSmsRegisterBody;
|
||||
import com.fuyuanshen.common.core.exception.BadRequestException;
|
||||
import com.fuyuanshen.common.core.exception.user.CaptchaException;
|
||||
import com.fuyuanshen.common.core.exception.user.CaptchaExpireException;
|
||||
import com.fuyuanshen.common.core.exception.user.UserException;
|
||||
import com.fuyuanshen.common.core.utils.MessageUtils;
|
||||
import com.fuyuanshen.common.core.utils.ServletUtils;
|
||||
import com.fuyuanshen.common.core.utils.SpringUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.log.event.LogininforEvent;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||
import com.fuyuanshen.common.web.config.properties.CaptchaProperties;
|
||||
import com.fuyuanshen.system.mapper.SysUserMapper;
|
||||
import com.fuyuanshen.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 注册校验方法
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class AppRegisterService {
|
||||
|
||||
private final ISysUserService userService;
|
||||
private final SysUserMapper userMapper;
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final AppUserMapper appUserMapper;
|
||||
|
||||
/**
|
||||
* 注册
|
||||
*/
|
||||
public void register(AppSmsRegisterBody registerBody) {
|
||||
String phoneNumber = registerBody.getPhoneNumber();
|
||||
LambdaQueryWrapper<AppUser> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(AppUser::getPhonenumber, phoneNumber);
|
||||
AppUserVo appUserVo = appUserMapper.selectVoOne(wrapper);
|
||||
if (appUserVo != null) {
|
||||
throw new BadRequestException("该手机号已被注册");
|
||||
}
|
||||
String verificationCode = RedisUtils.getCacheObject(GlobalConstants.CAPTCHA_CODE_KEY + phoneNumber);
|
||||
if (verificationCode == null) {
|
||||
throw new BadRequestException("验证码已过期");
|
||||
}
|
||||
if(!registerBody.getVerificationCode().equals(verificationCode)){
|
||||
throw new BadRequestException("验证码错误");
|
||||
}
|
||||
String tenantId = registerBody.getTenantId();
|
||||
String username = registerBody.getPhoneNumber();
|
||||
String password = registerBody.getPassword();
|
||||
|
||||
AppUser appUser = new AppUser();
|
||||
appUser.setUserName(username);
|
||||
appUser.setNickName(username);
|
||||
appUser.setPhonenumber(phoneNumber);
|
||||
appUser.setPassword(password);
|
||||
appUser.setUserType("app_user");
|
||||
appUser.setTenantId(tenantId);
|
||||
appUser.setLoginIp(ServletUtils.getClientIP());
|
||||
appUser.setStatus("0");
|
||||
appUser.setDelFlag("0");
|
||||
appUser.setCreateTime(new Date());
|
||||
|
||||
|
||||
boolean exist = TenantHelper.dynamic(tenantId, () -> {
|
||||
return appUserMapper.exists(new LambdaQueryWrapper<AppUser>()
|
||||
.eq(AppUser::getUserName, appUser.getUserName()));
|
||||
});
|
||||
if (exist) {
|
||||
throw new UserException("user.register.save.error", username);
|
||||
}
|
||||
appUserMapper.insert(appUser);
|
||||
recordLogininfor(tenantId, username, Constants.REGISTER, MessageUtils.message("user.register.success"));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
*/
|
||||
public void validateCaptcha(String tenantId, String username, String code, String uuid) {
|
||||
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.blankToDefault(uuid, "");
|
||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||
RedisUtils.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
|
||||
throw new CaptchaException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录信息
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
* @param username 用户名
|
||||
* @param status 状态
|
||||
* @param message 消息内容
|
||||
* @return
|
||||
*/
|
||||
private void recordLogininfor(String tenantId, String username, String status, String message) {
|
||||
LogininforEvent logininforEvent = new LogininforEvent();
|
||||
logininforEvent.setTenantId(tenantId);
|
||||
logininforEvent.setUsername(username);
|
||||
logininforEvent.setStatus(status);
|
||||
logininforEvent.setMessage(message);
|
||||
logininforEvent.setRequest(ServletUtils.getRequest());
|
||||
SpringUtils.context().publishEvent(logininforEvent);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
package com.fuyuanshen.web.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.dev33.satoken.stp.parameter.SaLoginParameter;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.mapper.AppUserMapper;
|
||||
import com.fuyuanshen.app.service.AppLoginService;
|
||||
import com.fuyuanshen.common.core.constant.Constants;
|
||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||
import com.fuyuanshen.common.core.constant.SystemConstants;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
|
||||
import com.fuyuanshen.common.core.domain.model.PasswordLoginBody;
|
||||
import com.fuyuanshen.common.core.enums.LoginType;
|
||||
import com.fuyuanshen.common.core.exception.user.CaptchaException;
|
||||
import com.fuyuanshen.common.core.exception.user.CaptchaExpireException;
|
||||
import com.fuyuanshen.common.core.exception.user.UserException;
|
||||
import com.fuyuanshen.common.core.utils.MessageUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.core.utils.ValidatorUtils;
|
||||
import com.fuyuanshen.common.json.utils.JsonUtils;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.common.tenant.helper.TenantHelper;
|
||||
import com.fuyuanshen.common.web.config.properties.CaptchaProperties;
|
||||
import com.fuyuanshen.system.domain.vo.SysClientVo;
|
||||
import com.fuyuanshen.web.domain.vo.LoginVo;
|
||||
import com.fuyuanshen.web.service.IAuthStrategy;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 密码认证策略
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
@Slf4j
|
||||
@Service("appPassword" + IAuthStrategy.BASE_NAME)
|
||||
@RequiredArgsConstructor
|
||||
public class AppPasswordAuthStrategy implements IAuthStrategy {
|
||||
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final AppLoginService loginService;
|
||||
private final AppUserMapper appUserMapper;
|
||||
@Override
|
||||
public LoginVo login(String body, SysClientVo client) {
|
||||
PasswordLoginBody loginBody = JsonUtils.parseObject(body, PasswordLoginBody.class);
|
||||
ValidatorUtils.validate(loginBody);
|
||||
String tenantId = loginBody.getTenantId();
|
||||
String username = loginBody.getUsername();
|
||||
String password = loginBody.getPassword();
|
||||
String code = loginBody.getCode();
|
||||
String uuid = loginBody.getUuid();
|
||||
|
||||
// boolean captchaEnabled = captchaProperties.getEnable();
|
||||
// // 验证码开关
|
||||
// if (captchaEnabled) {
|
||||
// validateCaptcha(tenantId, username, code, uuid);
|
||||
// }
|
||||
AppLoginUser loginUser = TenantHelper.dynamic(tenantId, () -> {
|
||||
AppUserVo user = loadUserByUsername(username);
|
||||
loginService.checkLogin(LoginType.PASSWORD, tenantId, username, () -> !password.equals(user.getPassword()));
|
||||
// 此处可根据登录用户的数据不同 自行创建 loginUser
|
||||
return loginService.buildLoginUser(user);
|
||||
});
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
loginUser.setDeviceType(client.getDeviceType());
|
||||
SaLoginParameter model = new SaLoginParameter();
|
||||
model.setDeviceType(client.getDeviceType());
|
||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||
// 例如: 后台用户30分钟过期 app用户1天过期
|
||||
model.setTimeout(client.getTimeout());
|
||||
model.setActiveTimeout(client.getActiveTimeout());
|
||||
model.setExtra(LoginHelper.CLIENT_KEY, client.getClientId());
|
||||
// 生成token
|
||||
AppLoginHelper.login(loginUser, model);
|
||||
|
||||
LoginVo loginVo = new LoginVo();
|
||||
loginVo.setAccessToken(StpUtil.getTokenValue());
|
||||
loginVo.setExpireIn(StpUtil.getTokenTimeout());
|
||||
loginVo.setClientId(client.getClientId());
|
||||
return loginVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验验证码
|
||||
*
|
||||
* @param username 用户名
|
||||
* @param code 验证码
|
||||
* @param uuid 唯一标识
|
||||
*/
|
||||
private void validateCaptcha(String tenantId, String username, String code, String uuid) {
|
||||
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.blankToDefault(uuid, "");
|
||||
String captcha = RedisUtils.getCacheObject(verifyKey);
|
||||
RedisUtils.deleteObject(verifyKey);
|
||||
if (captcha == null) {
|
||||
loginService.recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire"));
|
||||
throw new CaptchaExpireException();
|
||||
}
|
||||
if (!code.equalsIgnoreCase(captcha)) {
|
||||
loginService.recordLogininfor(tenantId, username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error"));
|
||||
throw new CaptchaException();
|
||||
}
|
||||
}
|
||||
|
||||
private AppUserVo loadUserByUsername(String username) {
|
||||
AppUserVo user = appUserMapper.selectVoOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getUserName, username));
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
log.info("登录用户:{} 不存在.", username);
|
||||
throw new UserException("user.not.exists", username);
|
||||
} else if (SystemConstants.DISABLE.equals(user.getStatus())) {
|
||||
log.info("登录用户:{} 已被停用.", username);
|
||||
throw new UserException("user.blocked", username);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
@ -59,7 +59,6 @@ public class AppSmsAuthStrategy implements IAuthStrategy {
|
||||
if (ObjectUtil.isNull(user)) {
|
||||
//新增Appuser
|
||||
AppUser appUser = addAppUser(tenantId, phonenumber);
|
||||
user = new AppUserVo();
|
||||
MapstructUtils.convert(appUser, user);
|
||||
// user = appUserMapper.selectVoOne(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhonenumber, phonenumber));
|
||||
// loginService.recordLogininfor(tenantId, phonenumber, Constants.LOGIN_FAIL, MessageUtils.message("user.not.exists", phonenumber));
|
||||
@ -71,7 +70,6 @@ public class AppSmsAuthStrategy implements IAuthStrategy {
|
||||
});
|
||||
loginUser.setClientKey(client.getClientKey());
|
||||
loginUser.setDeviceType(client.getDeviceType());
|
||||
loginUser.setUserType(UserType.APP_USER.getUserType());
|
||||
SaLoginParameter model = new SaLoginParameter();
|
||||
model.setDeviceType(client.getDeviceType());
|
||||
// 自定义分配 不同用户体系 不同 token 授权时间 不设置默认走全局 yml 配置
|
||||
|
@ -49,9 +49,9 @@ spring:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://47.120.79.150:3306/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://120.79.224.186:3366/fys-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: Jq_123456#
|
||||
password: 1fys@QWER..
|
||||
# # 从库数据源
|
||||
# slave:
|
||||
# lazy: true
|
||||
@ -98,13 +98,13 @@ spring:
|
||||
spring.data:
|
||||
redis:
|
||||
# 地址
|
||||
host: 47.120.79.150
|
||||
host: 120.79.224.186
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
port: 26379
|
||||
# 数据库索引
|
||||
database: 2
|
||||
# redis 密码必须配置
|
||||
password: xhYc_djkl382^#780!
|
||||
password: 1fys@QWER..
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
@ -300,9 +300,9 @@ file:
|
||||
# MQTT配置
|
||||
mqtt:
|
||||
username: admin
|
||||
password: #YtvpSfCNG
|
||||
url: tcp://47.120.79.150:2883
|
||||
password: fys123456
|
||||
url: tcp://47.107.152.87:1883
|
||||
subClientId: fys_subClient
|
||||
subTopic: A/#,worker/location/#
|
||||
pubTopic: B/#
|
||||
subTopic: worker/alert/#,worker/location/#
|
||||
pubTopic: worker/location
|
||||
pubClientId: fys_pubClient
|
@ -4,7 +4,7 @@ spring.servlet.multipart.location: /fys/server/temp
|
||||
--- # 监控中心配置
|
||||
spring.boot.admin.client:
|
||||
# 增加客户端开关
|
||||
enabled: true
|
||||
enabled: false
|
||||
url: http://localhost:9090/admin
|
||||
instance:
|
||||
service-host-type: IP
|
||||
@ -16,7 +16,7 @@ spring.boot.admin.client:
|
||||
|
||||
--- # snail-job 配置
|
||||
snail-job:
|
||||
enabled: true
|
||||
enabled: false
|
||||
# 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
|
||||
group: "fys_group"
|
||||
# SnailJob 接入验证令牌 详见 script/sql/ry_job.sql `sj_group_config`表
|
||||
|
@ -1,7 +1,7 @@
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
port: 8000
|
||||
port: 8001
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
|
@ -22,6 +22,11 @@ public interface GlobalConstants {
|
||||
*/
|
||||
String DEVICE_SHARE_CODES_KEY = GLOBAL_REDIS_KEY + "device_share_codes:";
|
||||
|
||||
/**
|
||||
* 验证码 redis key
|
||||
*/
|
||||
String APP_FORGOT_PASSWORD_SMS_KEY = GLOBAL_REDIS_KEY + "app_sms_forgotPassword:";
|
||||
|
||||
/**
|
||||
* 防重提交 redis key
|
||||
*/
|
||||
|
@ -0,0 +1,22 @@
|
||||
package com.fuyuanshen.common.core.domain.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AppLoginBody {
|
||||
|
||||
/**
|
||||
* 手机号不能为空
|
||||
*/
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 密码不能为空
|
||||
*/
|
||||
@NotBlank(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
private String tenantId;
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.fuyuanshen.common.core.domain.model;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AppSmsRegisterBody {
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phoneNumber;
|
||||
|
||||
@NotBlank(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
@NotBlank(message = "验证码不能为空")
|
||||
private String verificationCode;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
}
|
@ -18,14 +18,14 @@ public class PasswordLoginBody extends LoginBody {
|
||||
* 用户名
|
||||
*/
|
||||
@NotBlank(message = "{user.username.not.blank}")
|
||||
@Length(min = 2, max = 30, message = "{user.username.length.valid}")
|
||||
// @Length(min = 2, max = 30, message = "{user.username.length.valid}")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户密码
|
||||
*/
|
||||
@NotBlank(message = "{user.password.not.blank}")
|
||||
@Length(min = 5, max = 30, message = "{user.password.length.valid}")
|
||||
// @Length(min = 5, max = 30, message = "{user.password.length.valid}")
|
||||
private String password;
|
||||
|
||||
}
|
||||
|
@ -36,11 +36,6 @@ public class AppPersonnelInfo extends TenantEntity {
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 职位
|
||||
*/
|
||||
private String position;
|
||||
|
||||
/**
|
||||
* 单位名称
|
||||
*/
|
||||
@ -51,6 +46,5 @@ public class AppPersonnelInfo extends TenantEntity {
|
||||
*/
|
||||
private String sendMsg;
|
||||
|
||||
private String code;
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,14 @@
|
||||
package com.fuyuanshen.app.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* APP用户信息对象 app_user
|
||||
@ -95,5 +96,9 @@ public class AppUser extends TenantEntity {
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
private String region;
|
||||
|
||||
}
|
||||
|
@ -23,11 +23,13 @@ public class AppPersonnelInfoBo extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@NotNull(message = "主键不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
@NotNull(message = "设备id不能为空", groups = { AddGroup.class, EditGroup.class })
|
||||
private Long deviceId;
|
||||
|
||||
/**
|
||||
@ -35,11 +37,6 @@ public class AppPersonnelInfoBo extends BaseEntity {
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 职位
|
||||
*/
|
||||
private String position;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
@ -55,8 +52,5 @@ public class AppPersonnelInfoBo extends BaseEntity {
|
||||
*/
|
||||
private String sendMsg;
|
||||
|
||||
/**
|
||||
* ID号
|
||||
*/
|
||||
private String code;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.fuyuanshen.app.domain.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class APPForgotPasswordDTO {
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phoneNumber;
|
||||
|
||||
|
||||
@NotBlank(message = "密码不能为空")
|
||||
private String password;
|
||||
|
||||
@NotBlank(message = "验证码不能为空")
|
||||
private String verificationCode;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.fuyuanshen.app.domain.dto;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class APPForgotPasswordSmsDTO {
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
private String phoneNumber;
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package com.fuyuanshen.app.domain.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.fuyuanshen.app.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-06-1818:36
|
||||
*/
|
||||
@Data
|
||||
public class APPUpdateUserDTO {
|
||||
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 用户地区
|
||||
*/
|
||||
private String region;
|
||||
|
||||
/**
|
||||
* 用户性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private MultipartFile file;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.fuyuanshen.app.domain.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Data
|
||||
public class APPUserInfoVo {
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickName;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private String gender;
|
||||
|
||||
/**
|
||||
* 手机号码
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 头像地址
|
||||
*/
|
||||
private String avatarPath;
|
||||
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
private String region;
|
||||
|
||||
}
|
@ -69,9 +69,4 @@ public class AppDeviceDetailVo {
|
||||
* 人员信息
|
||||
*/
|
||||
private AppPersonnelInfoVo personnelInfo;
|
||||
|
||||
/**
|
||||
* 发送信息
|
||||
*/
|
||||
private String sendMsg;
|
||||
}
|
||||
|
@ -41,10 +41,6 @@ public class AppDeviceShareVo implements Serializable {
|
||||
@ExcelProperty(value = "设备ID")
|
||||
private Long deviceId;
|
||||
|
||||
/**
|
||||
* 设备IMEI
|
||||
*/
|
||||
private String deviceImei;
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
|
@ -23,4 +23,8 @@ public class AppFileVo {
|
||||
* 文件url
|
||||
*/
|
||||
private String fileUrl;
|
||||
/**
|
||||
* 文件类型(1:操作说明,2:产品参数)
|
||||
*/
|
||||
private Long fileType;
|
||||
}
|
||||
|
@ -47,10 +47,10 @@ public class AppPersonnelInfoVo implements Serializable {
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 岗位
|
||||
* 部门名称
|
||||
*/
|
||||
@ExcelProperty(value = "岗位")
|
||||
private String position;
|
||||
@ExcelProperty(value = "部门名称")
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 单位名称
|
||||
@ -59,10 +59,10 @@ public class AppPersonnelInfoVo implements Serializable {
|
||||
private String unitName;
|
||||
|
||||
/**
|
||||
* ID号
|
||||
* 发送信息
|
||||
*/
|
||||
@ExcelProperty(value = "ID号")
|
||||
private String code;
|
||||
@ExcelProperty(value = "发送信息")
|
||||
private String sendMsg;
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,8 @@
|
||||
package com.fuyuanshen.app.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.app.domain.AppDeviceShare;
|
||||
import com.fuyuanshen.app.domain.bo.AppDeviceShareBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppDeviceShareVo;
|
||||
import com.fuyuanshen.common.mybatis.core.mapper.BaseMapperPlus;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* 设备分享Mapper接口
|
||||
@ -15,5 +11,5 @@ import org.apache.ibatis.annotations.Param;
|
||||
* @date 2025-07-16
|
||||
*/
|
||||
public interface AppDeviceShareMapper extends BaseMapperPlus<AppDeviceShare, AppDeviceShareVo> {
|
||||
IPage<AppDeviceShareVo> otherDeviceShareList(@Param("bo") AppDeviceShareBo bo, Page<AppDeviceShareVo> page);
|
||||
|
||||
}
|
||||
|
@ -14,4 +14,5 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface AppUserMapper extends BaseMapperPlus<AppUser, AppUserVo> {
|
||||
|
||||
AppUser appFindByUsername(String phoneNumber);
|
||||
}
|
||||
|
@ -65,6 +65,4 @@ public interface IAppDeviceShareService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
TableDataInfo<AppDeviceShareVo> otherDeviceShareList(AppDeviceShareBo bo, PageQuery pageQuery);
|
||||
}
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.fuyuanshen.app.service;
|
||||
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordSmsDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPUpdateUserDTO;
|
||||
import com.fuyuanshen.app.domain.vo.APPUserInfoVo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -65,4 +69,12 @@ public interface IAppUserService {
|
||||
* @return 是否删除成功
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
APPUserInfoVo getUserInfo();
|
||||
|
||||
int updateUser(APPUpdateUserDTO bo);
|
||||
|
||||
int forgotPassword(APPForgotPasswordDTO bo);
|
||||
|
||||
int sendForgotPasswordSms(APPForgotPasswordSmsDTO dto);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.fuyuanshen.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
@ -69,7 +68,6 @@ public class AppDeviceShareServiceImpl implements IAppDeviceShareService {
|
||||
if(device != null){
|
||||
r.setDevicePic(device.getDevicePic());
|
||||
r.setDeviceName(device.getDeviceName());
|
||||
r.setDeviceImei(device.getDeviceImei());
|
||||
}
|
||||
});
|
||||
return TableDataInfo.build(result);
|
||||
@ -148,22 +146,4 @@ public class AppDeviceShareServiceImpl implements IAppDeviceShareService {
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<AppDeviceShareVo> otherDeviceShareList(AppDeviceShareBo bo, PageQuery pageQuery) {
|
||||
String username = AppLoginHelper.getUsername();
|
||||
bo.setPhonenumber(username);
|
||||
Page<AppDeviceShareVo> page = new Page<>(pageQuery.getPageNum(), pageQuery.getPageSize());
|
||||
IPage<AppDeviceShareVo> result = baseMapper.otherDeviceShareList(bo, page);
|
||||
List<AppDeviceShareVo> records = result.getRecords();
|
||||
records.forEach(r -> {
|
||||
Device device = deviceMapper.selectById(r.getDeviceId());
|
||||
if(device != null){
|
||||
r.setDevicePic(device.getDevicePic());
|
||||
r.setDeviceName(device.getDeviceName());
|
||||
r.setDeviceImei(device.getDeviceImei());
|
||||
}
|
||||
});
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -66,6 +67,8 @@ public class AppOperationVideoServiceImpl implements IAppOperationVideoService {
|
||||
*/
|
||||
@Override
|
||||
public List<AppOperationVideoVo> queryList(AppOperationVideoBo bo) {
|
||||
Long userId = AppLoginHelper.getUserId();
|
||||
bo.setCreateBy(userId);
|
||||
LambdaQueryWrapper<AppOperationVideo> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
@ -1,24 +1,37 @@
|
||||
package com.fuyuanshen.app.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPForgotPasswordSmsDTO;
|
||||
import com.fuyuanshen.app.domain.dto.APPUpdateUserDTO;
|
||||
import com.fuyuanshen.app.domain.vo.APPUserInfoVo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.mapper.AppUserMapper;
|
||||
import com.fuyuanshen.app.service.IAppUserService;
|
||||
import com.fuyuanshen.common.core.constant.GlobalConstants;
|
||||
import com.fuyuanshen.common.core.domain.model.AppLoginUser;
|
||||
import com.fuyuanshen.common.core.exception.BadRequestException;
|
||||
import com.fuyuanshen.common.core.utils.MapstructUtils;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.redis.utils.RedisUtils;
|
||||
import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||
import com.fuyuanshen.system.service.ISysOssService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuyuanshen.app.domain.bo.AppUserBo;
|
||||
import com.fuyuanshen.app.domain.vo.AppUserVo;
|
||||
import com.fuyuanshen.app.domain.AppUser;
|
||||
import com.fuyuanshen.app.mapper.AppUserMapper;
|
||||
import com.fuyuanshen.app.service.IAppUserService;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* Service业务层处理
|
||||
@ -33,6 +46,8 @@ public class AppUserServiceImpl implements IAppUserService {
|
||||
|
||||
private final AppUserMapper baseMapper;
|
||||
|
||||
private final ISysOssService sysOssService;
|
||||
|
||||
/**
|
||||
* 查询APP用户信息
|
||||
*
|
||||
@ -139,4 +154,75 @@ public class AppUserServiceImpl implements IAppUserService {
|
||||
}
|
||||
return baseMapper.deleteByIds(ids) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public APPUserInfoVo getUserInfo() {
|
||||
String username = AppLoginHelper.getUsername();
|
||||
QueryWrapper<AppUser> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_name", username);
|
||||
List<AppUser> appUsers = baseMapper.selectList(queryWrapper);
|
||||
if(appUsers.isEmpty()){
|
||||
throw new BadRequestException("用户不存在");
|
||||
}
|
||||
AppUser user = appUsers.get(0);
|
||||
// AppUserVo user = baseMapper.selectVoById(userId);
|
||||
|
||||
APPUserInfoVo appUserVo = new APPUserInfoVo();
|
||||
appUserVo.setId(user.getUserId());
|
||||
appUserVo.setNickName(user.getNickName());
|
||||
appUserVo.setGender(user.getSex());
|
||||
appUserVo.setPhone(user.getPhonenumber());
|
||||
appUserVo.setRegion(user.getRegion());
|
||||
if(user.getAvatar() != null){
|
||||
SysOssVo oss = sysOssService.getById(user.getAvatar());
|
||||
if(oss != null){
|
||||
appUserVo.setAvatarPath(oss.getUrl());
|
||||
}
|
||||
}
|
||||
|
||||
return appUserVo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateUser(APPUpdateUserDTO bo) {
|
||||
AppLoginUser appUser = AppLoginHelper.getLoginUser();
|
||||
AppUserVo appUserVo = baseMapper.selectVoById(appUser.getUserId());
|
||||
if(appUserVo == null){
|
||||
throw new BadRequestException("用户不存在");
|
||||
}
|
||||
AppUser updUser= new AppUser();
|
||||
updUser.setUserId(appUser.getUserId());
|
||||
updUser.setNickName(bo.getNickName());
|
||||
if(bo.getFile() != null){
|
||||
SysOssVo oss = sysOssService.upload(bo.getFile());
|
||||
updUser.setAvatar(oss.getOssId());
|
||||
}
|
||||
|
||||
updUser.setRegion(bo.getRegion());
|
||||
updUser.setSex(bo.getGender());
|
||||
return baseMapper.update(updUser, new LambdaQueryWrapper<AppUser>().eq(AppUser::getUserId, appUser.getUserId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int forgotPassword(APPForgotPasswordDTO bo) {
|
||||
AppUser appUser = baseMapper.appFindByUsername(bo.getPhoneNumber());
|
||||
if (appUser == null) {
|
||||
throw new BadRequestException("手机号不存在");
|
||||
}
|
||||
String verificationCode = RedisUtils.getCacheObject(GlobalConstants.APP_FORGOT_PASSWORD_SMS_KEY + bo.getPhoneNumber());
|
||||
if (verificationCode == null) {
|
||||
throw new BadRequestException("验证码已过期");
|
||||
}
|
||||
if(!bo.getVerificationCode().equals(verificationCode)){
|
||||
throw new BadRequestException("验证码错误");
|
||||
}
|
||||
appUser.setPassword(bo.getPassword());
|
||||
baseMapper.updateById(appUser);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int sendForgotPasswordSms(APPForgotPasswordSmsDTO dto) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="queryAppFileList" resultType="com.fuyuanshen.app.domain.vo.AppFileVo">
|
||||
select a.id,a.business_id,a.file_id,b.file_name,b.url fileUrl from app_business_file a left join sys_oss b on a.file_id = b.oss_id
|
||||
where 1=1
|
||||
<if test="createBy != null">
|
||||
a.create_by = #{createBy}
|
||||
</if>
|
||||
<if test="businessId != null">
|
||||
and a.business_id = #{businessId}
|
||||
</if>
|
||||
|
@ -4,7 +4,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuyuanshen.app.mapper.AppDeviceShareMapper">
|
||||
|
||||
<select id="otherDeviceShareList" resultType="com.fuyuanshen.app.domain.vo.AppDeviceShareVo">
|
||||
SELECT * FROM app_device_share a where a.phonenumber = #{bo.phonenumber}
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -4,4 +4,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.fuyuanshen.app.mapper.AppUserMapper">
|
||||
|
||||
<select id="appFindByUsername" resultType="com.fuyuanshen.app.domain.AppUser">
|
||||
select * from app_user where user_name = #{phoneNumber}
|
||||
</select>
|
||||
</mapper>
|
||||
|
@ -92,7 +92,7 @@ public class Customer extends TenantEntity {
|
||||
/**
|
||||
* 帐号状态(0正常 1停用)
|
||||
*/
|
||||
private String status = "0";
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 删除标志(0代表存在 1代表删除)
|
||||
|
@ -1,11 +1,9 @@
|
||||
package com.fuyuanshen.customer.service.impl;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
||||
import com.fuyuanshen.common.core.utils.StringUtils;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.customer.constant.ArrayConstants;
|
||||
@ -94,7 +92,6 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||
}
|
||||
customer.setUserLevel((byte) (loginUser.getUserLevel() + 1));
|
||||
customer.setPid(loginUser.getUserId());
|
||||
customer.setStatus("0");
|
||||
|
||||
save(customer);
|
||||
|
||||
@ -109,40 +106,18 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
|
||||
|
||||
/**
|
||||
* 修改客户
|
||||
* 不是因为寂寞才想你,只是因为想你才寂寞。
|
||||
*
|
||||
* @param customer /
|
||||
* @param resources /
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateCustomer(Customer customer) throws Exception {
|
||||
|
||||
UserQueryCriteria userQueryCriteria = new UserQueryCriteria();
|
||||
if (StringUtils.isNotEmpty(customer.getUserName())) {
|
||||
userQueryCriteria.setCustomerName(customer.getUserName());
|
||||
List<Customer> customers = customerMapper.queryCustomers(userQueryCriteria);
|
||||
if (!customers.isEmpty()) {
|
||||
throw new BadRequestException("用户名已存在!!!");
|
||||
}
|
||||
}
|
||||
|
||||
if (customer.getEnabled()) {
|
||||
customer.setStatus("0");
|
||||
public void updateCustomer(Customer resources) throws Exception {
|
||||
if (resources.getEnabled()) {
|
||||
resources.setStatus("0");
|
||||
} else {
|
||||
// 强制下线
|
||||
// StpUtil.logout(customer.getCustomerId());
|
||||
// StpUtil.kickout(customer.getCustomerId());
|
||||
customer.setStatus("1");
|
||||
// 检查目标用户是否有有效的登录状态
|
||||
if (StpUtil.isLogin(customer.getCustomerId())) {
|
||||
// 用户已登录,可以执行踢出操作
|
||||
StpUtil.kickout(customer.getCustomerId());
|
||||
} else {
|
||||
// 用户未登录,无法踢出
|
||||
System.out.println("目标用户未登录,无法执行踢出操作");
|
||||
}
|
||||
resources.setStatus("1");
|
||||
}
|
||||
saveOrUpdate(customer);
|
||||
saveOrUpdate(resources);
|
||||
}
|
||||
|
||||
|
||||
|
@ -105,6 +105,7 @@ public class Device extends TenantEntity {
|
||||
@Schema(name = "设备状态")
|
||||
private Integer deviceStatus;
|
||||
|
||||
|
||||
/**
|
||||
* 绑定状态
|
||||
* 0 未绑定
|
||||
@ -120,23 +121,7 @@ public class Device extends TenantEntity {
|
||||
|
||||
private Long bindingUserId;
|
||||
|
||||
/**
|
||||
* 绑定时间
|
||||
*/
|
||||
private Date bindingTime;
|
||||
|
||||
private String sendMsg;
|
||||
|
||||
/**
|
||||
* 发布主题(格式:A/{device_id})
|
||||
* pub_topic
|
||||
*/
|
||||
private String pubTopic;
|
||||
|
||||
/**
|
||||
* 订阅主题(格式:B/{device_id})
|
||||
* sub_topic
|
||||
*/
|
||||
private String subTopic;
|
||||
|
||||
}
|
||||
|
@ -30,5 +30,5 @@ public class AppDeviceBo {
|
||||
|
||||
private String sendMsg;
|
||||
|
||||
private Long deviceId;
|
||||
private String deviceId;
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
package com.fuyuanshen.equipment.domain.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 绑定设备参数
|
||||
*/
|
||||
@Data
|
||||
public class AppDeviceSendMsgBo {
|
||||
|
||||
private String sendMsg;
|
||||
|
||||
private List<Long> deviceIds;
|
||||
}
|
@ -1,12 +1,10 @@
|
||||
package com.fuyuanshen.equipment.domain.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
public class AppDeviceVo implements Serializable {
|
||||
public class AppDeviceVo {
|
||||
|
||||
private Long id;
|
||||
|
||||
@ -41,7 +39,7 @@ public class AppDeviceVo implements Serializable {
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 蓝牙名称
|
||||
* 蓝牙名称
|
||||
*/
|
||||
private String bluetoothName;
|
||||
|
||||
@ -51,10 +49,4 @@ public class AppDeviceVo implements Serializable {
|
||||
* 1 正常
|
||||
*/
|
||||
private Integer deviceStatus;
|
||||
|
||||
/**
|
||||
* 绑定时间
|
||||
*/
|
||||
private Date bindingTime;
|
||||
|
||||
}
|
||||
|
@ -85,14 +85,6 @@ public interface DeviceService extends IService<Device> {
|
||||
*/
|
||||
void unbindDevice(DeviceForm deviceForm);
|
||||
|
||||
|
||||
/**
|
||||
* WEB端查看APP客户设备绑定
|
||||
*
|
||||
* @param bo
|
||||
* @param pageQuery
|
||||
* @return
|
||||
*/
|
||||
TableDataInfo<AppDeviceVo> queryAppDeviceList(DeviceQueryCriteria bo, PageQuery pageQuery);
|
||||
|
||||
int bindDevice(AppDeviceBo bo);
|
||||
|
@ -186,12 +186,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
device.setCreateByName(loginUser.getNickname());
|
||||
device.setTypeName(deviceTypes.getTypeName());
|
||||
device.setDeviceType(deviceTypes.getId());
|
||||
if (device.getDeviceImei() != null) {
|
||||
device.setPubTopic("A/" + device.getDeviceImei());
|
||||
device.setSubTopic("B/" + device.getDeviceImei());
|
||||
}
|
||||
// 0 未绑定
|
||||
device.setBindingStatus(0);
|
||||
|
||||
deviceMapper.insert(device);
|
||||
|
||||
// 新增设备类型记录
|
||||
@ -298,26 +293,17 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
|
||||
for (Long id : ids) {
|
||||
DeviceAssignments deviceAssignment = deviceAssignmentsMapper.selectById(id);
|
||||
Device device = deviceMapper.selectById(deviceAssignment.getDeviceId());
|
||||
Device deviceType = deviceMapper.selectById(deviceAssignment.getDeviceId());
|
||||
|
||||
if (StringUtils.isNotEmpty(deviceAssignment.getAssigneeName())) {
|
||||
throw new BadRequestException(device.getDeviceName() + ":设备已分配,请先解绑设备!!!");
|
||||
}
|
||||
|
||||
if (device.getBindingStatus() != null && device.getBindingStatus().equals(1)) {
|
||||
throw new BadRequestException(device.getDeviceName() + ":设备已绑定,请先解绑设备!!!");
|
||||
throw new BadRequestException(deviceType.getDeviceName() + ":设备已分配,请先解绑设备!!!");
|
||||
}
|
||||
|
||||
// 接收者
|
||||
if (Objects.equals(deviceAssignment.getAssigneeId(), device.getOriginalOwnerId())) {
|
||||
if (Objects.equals(deviceAssignment.getAssigneeId(), deviceType.getOriginalOwnerId())) {
|
||||
invalidIds.add(deviceAssignment.getDeviceId());
|
||||
}
|
||||
|
||||
// 删除设备:分配记录
|
||||
deviceAssignmentsMapper.delete(new LambdaQueryWrapper<DeviceAssignments>()
|
||||
.eq(DeviceAssignments::getDeviceId, deviceAssignment.getDeviceId())
|
||||
.eq(DeviceAssignments::getAssigneeId, deviceAssignment.getAssigneeId()));
|
||||
|
||||
}
|
||||
|
||||
deviceAssignmentsMapper.deleteByIds(ids);
|
||||
@ -484,13 +470,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* WEB端查看APP客户设备绑定
|
||||
*
|
||||
* @param bo
|
||||
* @param pageQuery
|
||||
* @return
|
||||
*/
|
||||
|
||||
@Override
|
||||
public TableDataInfo<AppDeviceVo> queryAppDeviceList(DeviceQueryCriteria bo, PageQuery pageQuery) {
|
||||
if (bo.getBindingUserId() == null) {
|
||||
|
@ -179,7 +179,7 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>()
|
||||
.eq("device_type", deviceTypeGrant.getDeviceTypeId()));
|
||||
if (CollectionUtil.isNotEmpty(devices)) {
|
||||
throw new RuntimeException("该设备类型已绑定设备,无法删除!!!");
|
||||
throw new RuntimeException("该设备类型已绑定设备,无法删除");
|
||||
}
|
||||
deviceTypeId.add(deviceTypeGrant.getDeviceTypeId());
|
||||
}
|
||||
|
@ -38,19 +38,13 @@
|
||||
|
||||
<!-- 分页查询设备 -->
|
||||
<select id="findAll" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT
|
||||
da.id AS id, d.device_name, d.bluetooth_name,
|
||||
d.pub_topic, d.sub_topic, d.device_pic,
|
||||
d.device_mac, d.device_sn, d.update_by,
|
||||
d.device_imei, d.update_time, dg.id AS device_type,
|
||||
d.remark, d.binding_status, t.type_name AS typeName,
|
||||
da.assignee_id AS customerId, da.assignee_name AS customerName,
|
||||
da.active AS deviceStatus, da.create_time AS create_time,
|
||||
da.assigner_name AS createByName, da.id AS assignId,
|
||||
ROW_NUMBER() OVER (PARTITION BY d.id ORDER BY da.create_time DESC) AS rn
|
||||
FROM device d
|
||||
select
|
||||
da.id AS id,d.device_name,d.bluetooth_name,
|
||||
d.device_pic, d.device_mac, d.device_sn, d.update_by,d.device_imei,
|
||||
d.update_time, dg.id AS device_type, d.remark, d.binding_status,t.type_name AS typeName,
|
||||
da.assignee_id AS customerId, da.assignee_name AS customerName, da.active AS deviceStatus,
|
||||
da.create_time AS create_time , da.assigner_name AS createByName , da.id AS assignId
|
||||
from device d
|
||||
LEFT JOIN device_type t ON d.device_type = t.id
|
||||
LEFT JOIN device_type_grants dg ON dg.device_type_id = t.id
|
||||
LEFT JOIN device_assignments da ON da.device_id = d.id
|
||||
@ -77,12 +71,9 @@
|
||||
AND da.assignee_id = #{criteria.currentOwnerId}
|
||||
AND dg.customer_id = #{criteria.currentOwnerId}
|
||||
</where>
|
||||
) AS ranked
|
||||
WHERE rn = 1
|
||||
ORDER BY create_time DESC
|
||||
ORDER BY da.create_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
<select id="findAllDevices" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||
select
|
||||
d.id, d.customer_id, d.device_name,d.bluetooth_name,
|
||||
@ -147,8 +138,7 @@
|
||||
d.device_pic,
|
||||
dt.type_name,
|
||||
dt.communication_mode,
|
||||
d.bluetooth_name,
|
||||
d.binding_time
|
||||
d.bluetooth_name
|
||||
from device d
|
||||
inner join device_type dt on d.device_type = dt.id
|
||||
where d.binding_user_id = #{criteria.bindingUserId}
|
||||
|
@ -44,7 +44,7 @@ public class MqttOutboundConfiguration {
|
||||
mqttPahoClientFactory
|
||||
);
|
||||
mqttPahoMessageHandler.setDefaultQos(1);
|
||||
mqttPahoMessageHandler.setDefaultTopic("B/#");
|
||||
mqttPahoMessageHandler.setDefaultTopic("worker/location");
|
||||
mqttPahoMessageHandler.setAsync(true);
|
||||
return mqttPahoMessageHandler;
|
||||
}
|
||||
|
@ -1,16 +0,0 @@
|
||||
package com.fuyuanshen.system.mqtt.constants;
|
||||
|
||||
|
||||
public interface MqttConstants {
|
||||
|
||||
|
||||
/**
|
||||
* 全局发布消息的key
|
||||
*/
|
||||
String GLOBAL_PUB_KEY = "B/";
|
||||
|
||||
/**
|
||||
* 全局订阅消息的key
|
||||
*/
|
||||
String GLOBAL_SUB_KEY = "A/";
|
||||
}
|
@ -27,6 +27,5 @@ public class ReceiverMessageHandler implements MessageHandler {
|
||||
String timestamp = Objects.requireNonNull(headers.get("timestamp")).toString();
|
||||
log.info("MQTT payload= {} \n receivedTopic = {} \n receivedQos = {} \n timestamp = {}"
|
||||
,payload,receivedTopic,receivedQos,timestamp);
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user