Compare commits
6 Commits
1438178f70
...
b467e02ff6
| Author | SHA1 | Date | |
|---|---|---|---|
| b467e02ff6 | |||
| d64216ee5f | |||
| 9a975b36c5 | |||
| 401d6752cf | |||
| 3e0394eaea | |||
| d91012ee1b |
@ -63,7 +63,7 @@ public class MPController {
|
|||||||
List<AuthorityDto> authorityDtos = new ArrayList<>();
|
List<AuthorityDto> authorityDtos = new ArrayList<>();
|
||||||
authorityDtos.add(authorityDto);
|
authorityDtos.add(authorityDto);
|
||||||
user.setPhone(authUser.getPhoneNumber());
|
user.setPhone(authUser.getPhoneNumber());
|
||||||
JwtUserDto jwtUser = new JwtUserDto(user, null, authorityDtos);
|
JwtUserDto jwtUser = new JwtUserDto(null, user, null, authorityDtos);
|
||||||
|
|
||||||
Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, authorityDtos);
|
Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, authorityDtos);
|
||||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||||
|
|||||||
@ -164,14 +164,12 @@ public class AuthController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证密码
|
// 3. 验证密码
|
||||||
// String enPassword = passwordEncoder.encode(authUser.getPassword());
|
if (!appUser.getPassword().equals(authUser.getPassword())) {
|
||||||
String enPassword = MD5.create().digestHex(authUser.getPassword());
|
|
||||||
if (!appUser.getPassword().equals(enPassword)) {
|
|
||||||
throw new BadRequestException("登录密码错误");
|
throw new BadRequestException("登录密码错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. 加载用户详情
|
// 4. 加载用户详情
|
||||||
JwtUserDto jwtUser = userDetailsService.loadAppUserByUsername(appUser.getUsername());
|
JwtUserDto jwtUser = userDetailsService.loadUserByAppUsername(appUser.getUsername());
|
||||||
|
|
||||||
// 5. 创建认证信息
|
// 5. 创建认证信息
|
||||||
Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
|
Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
|
||||||
|
|||||||
@ -70,6 +70,7 @@ public class AppTokenProvider implements InitializingBean {
|
|||||||
/**
|
/**
|
||||||
* 创建Token 设置永不过期,
|
* 创建Token 设置永不过期,
|
||||||
* Token 的时间有效性转到Redis 维护
|
* Token 的时间有效性转到Redis 维护
|
||||||
|
*
|
||||||
* @param user /
|
* @param user /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
@ -77,7 +78,7 @@ public class AppTokenProvider implements InitializingBean {
|
|||||||
// 设置参数
|
// 设置参数
|
||||||
Map<String, Object> claims = new HashMap<>(6);
|
Map<String, Object> claims = new HashMap<>(6);
|
||||||
// 设置用户ID
|
// 设置用户ID
|
||||||
// claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
||||||
// if (user.getAppUser() != null){
|
// if (user.getAppUser() != null){
|
||||||
// claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
// claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
||||||
// }else {
|
// }else {
|
||||||
@ -94,6 +95,7 @@ public class AppTokenProvider implements InitializingBean {
|
|||||||
/**
|
/**
|
||||||
* APP创建Token 设置永不过期,
|
* APP创建Token 设置永不过期,
|
||||||
* Token 的时间有效性转到Redis 维护
|
* Token 的时间有效性转到Redis 维护
|
||||||
|
*
|
||||||
* @param user /
|
* @param user /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
@ -102,7 +104,7 @@ public class AppTokenProvider implements InitializingBean {
|
|||||||
Map<String, Object> claims = new HashMap<>(6);
|
Map<String, Object> claims = new HashMap<>(6);
|
||||||
|
|
||||||
// 设置用户ID
|
// 设置用户ID
|
||||||
// claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
||||||
// if (user.getAppUser() != null){
|
// if (user.getAppUser() != null){
|
||||||
// claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
// claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
||||||
// }else {
|
// }else {
|
||||||
@ -110,7 +112,7 @@ public class AppTokenProvider implements InitializingBean {
|
|||||||
// }
|
// }
|
||||||
// 设置UUID,确保每次Token不一样
|
// 设置UUID,确保每次Token不一样
|
||||||
claims.put(AUTHORITIES_UUID_KEY, IdUtil.simpleUUID());
|
claims.put(AUTHORITIES_UUID_KEY, IdUtil.simpleUUID());
|
||||||
claims.put("userType","1");//0 系统登录 1 APP登录
|
claims.put("userType", "1");// 0 系统登录 1 APP登录
|
||||||
return jwtBuilder
|
return jwtBuilder
|
||||||
.setClaims(claims)
|
.setClaims(claims)
|
||||||
.setSubject(user.getAppUser().getUsername())
|
.setSubject(user.getAppUser().getUsername())
|
||||||
@ -162,6 +164,7 @@ public class AppTokenProvider implements InitializingBean {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取登录用户RedisKey
|
* 获取登录用户RedisKey
|
||||||
|
*
|
||||||
* @param token /
|
* @param token /
|
||||||
* @return key
|
* @return key
|
||||||
*/
|
*/
|
||||||
@ -172,6 +175,7 @@ public class AppTokenProvider implements InitializingBean {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取会话编号
|
* 获取会话编号
|
||||||
|
*
|
||||||
* @param token /
|
* @param token /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -17,18 +17,17 @@ package com.fuyuanshen.modules.security.service;
|
|||||||
|
|
||||||
import cn.hutool.jwt.JWT;
|
import cn.hutool.jwt.JWT;
|
||||||
import cn.hutool.jwt.JWTUtil;
|
import cn.hutool.jwt.JWTUtil;
|
||||||
import com.fuyuanshen.modules.security.service.dto.app.AppJwtUserDto;
|
|
||||||
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
|
||||||
import com.fuyuanshen.utils.SecurityUtils;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import com.fuyuanshen.exception.BadRequestException;
|
import com.fuyuanshen.exception.BadRequestException;
|
||||||
import com.fuyuanshen.modules.security.service.dto.AuthorityDto;
|
import com.fuyuanshen.modules.security.service.dto.AuthorityDto;
|
||||||
import com.fuyuanshen.modules.security.service.dto.JwtUserDto;
|
import com.fuyuanshen.modules.security.service.dto.JwtUserDto;
|
||||||
import com.fuyuanshen.modules.system.domain.User;
|
import com.fuyuanshen.modules.system.domain.User;
|
||||||
|
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
||||||
import com.fuyuanshen.modules.system.service.DataService;
|
import com.fuyuanshen.modules.system.service.DataService;
|
||||||
import com.fuyuanshen.modules.system.service.RoleService;
|
import com.fuyuanshen.modules.system.service.RoleService;
|
||||||
import com.fuyuanshen.modules.system.service.UserService;
|
import com.fuyuanshen.modules.system.service.UserService;
|
||||||
|
import com.fuyuanshen.utils.SecurityUtils;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@ -48,58 +47,59 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
|||||||
private final DataService dataService;
|
private final DataService dataService;
|
||||||
private final UserCacheManager userCacheManager;
|
private final UserCacheManager userCacheManager;
|
||||||
|
|
||||||
|
private final static String APP_USER_TYPE = "1"; // app用户类型
|
||||||
|
|
||||||
|
private final static String SYSTEM_USER_TYPE = "0"; // 系统用户类型
|
||||||
@Override
|
@Override
|
||||||
public JwtUserDto loadUserByUsername(String username) {
|
public JwtUserDto loadUserByUsername(String username) {
|
||||||
JWT jwt = JWTUtil.parseToken(SecurityUtils.getToken());
|
if(SecurityUtils.getToken() != null){
|
||||||
String userType = jwt.getPayload("userType").toString();
|
JWT jwt = JWTUtil.parseToken(SecurityUtils.getToken());
|
||||||
|
String userType = jwt.getPayload("userType").toString();
|
||||||
if("1".equals(userType)){
|
if(APP_USER_TYPE.equals(userType)){
|
||||||
JwtUserDto jwtUserDto = userCacheManager.getAppUserCache(username);
|
return loadUserByAppUsername(username);
|
||||||
if (jwtUserDto == null) {
|
}else{
|
||||||
APPUser user = userService.appGetLoginData(username);
|
return loadSystemUserByUsername(username);
|
||||||
if (user == null) {
|
|
||||||
throw new BadRequestException("用户不存在");
|
|
||||||
} else {
|
|
||||||
if (!user.getEnabled()) {
|
|
||||||
throw new BadRequestException("账号未激活!");
|
|
||||||
}
|
|
||||||
// 获取用户的权限
|
|
||||||
List<AuthorityDto> authorities = roleService.appBuildPermissions(user);
|
|
||||||
// 初始化JwtUserDto
|
|
||||||
jwtUserDto = new JwtUserDto(user,null, dataService.getDeptIds(user), authorities);
|
|
||||||
// 添加缓存数据
|
|
||||||
userCacheManager.addAppUserCache(username, jwtUserDto);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return jwtUserDto;
|
|
||||||
}else{
|
}else{
|
||||||
JwtUserDto jwtUserDto = userCacheManager.getUserCache(username);
|
return loadSystemUserByUsername(username);
|
||||||
if (jwtUserDto == null) {
|
|
||||||
User user = userService.getLoginData(username);
|
|
||||||
if (user == null) {
|
|
||||||
throw new BadRequestException("用户不存在");
|
|
||||||
} else {
|
|
||||||
if (!user.getEnabled()) {
|
|
||||||
throw new BadRequestException("账号未激活!");
|
|
||||||
}
|
|
||||||
// 获取用户的权限
|
|
||||||
List<AuthorityDto> authorities = roleService.buildPermissions(user);
|
|
||||||
// 初始化JwtUserDto
|
|
||||||
jwtUserDto = new JwtUserDto(null,user, dataService.getDeptIds(user), authorities);
|
|
||||||
// 添加缓存数据
|
|
||||||
userCacheManager.addUserCache(username, jwtUserDto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return jwtUserDto;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public JwtUserDto loadAppUserByUsername(String username) {
|
/**
|
||||||
|
* 加载系统用户详情信息
|
||||||
|
* @param username
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
private JwtUserDto loadSystemUserByUsername(String username) {
|
||||||
JwtUserDto jwtUserDto = userCacheManager.getUserCache(username);
|
JwtUserDto jwtUserDto = userCacheManager.getUserCache(username);
|
||||||
if (jwtUserDto == null) {
|
if (jwtUserDto == null) {
|
||||||
username = username.replace("APP_", "");
|
User user = userService.getLoginData(username);
|
||||||
|
if (user == null) {
|
||||||
|
throw new BadRequestException("用户不存在");
|
||||||
|
} else {
|
||||||
|
if (!user.getEnabled()) {
|
||||||
|
throw new BadRequestException("账号未激活!");
|
||||||
|
}
|
||||||
|
// 获取用户的权限
|
||||||
|
List<AuthorityDto> authorities = roleService.buildPermissions(user);
|
||||||
|
// 初始化JwtUserDto
|
||||||
|
jwtUserDto = new JwtUserDto(null,user, dataService.getDeptIds(user), authorities);
|
||||||
|
// 添加缓存数据
|
||||||
|
userCacheManager.addUserCache(username, jwtUserDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return jwtUserDto;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载app用户详情信息
|
||||||
|
* @param username
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public JwtUserDto loadUserByAppUsername(String username) {
|
||||||
|
|
||||||
|
JwtUserDto jwtUserDto = userCacheManager.getAppUserCache(username);
|
||||||
|
if (jwtUserDto == null) {
|
||||||
APPUser user = userService.appGetLoginData(username);
|
APPUser user = userService.appGetLoginData(username);
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
throw new BadRequestException("用户不存在");
|
throw new BadRequestException("用户不存在");
|
||||||
@ -118,9 +118,5 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
|||||||
return jwtUserDto;
|
return jwtUserDto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isAppUser(String username) {
|
|
||||||
// 实现你的判断逻辑,比如前缀、数据库查询等
|
|
||||||
return username.startsWith("APP_");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,6 @@ public class APPDevice extends BaseEntity implements Serializable {
|
|||||||
@ApiModelProperty(value = "ID")
|
@ApiModelProperty(value = "ID")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
|
||||||
@ApiModelProperty(value = "设备类型")
|
@ApiModelProperty(value = "设备类型")
|
||||||
private Long deviceType;
|
private Long deviceType;
|
||||||
|
|
||||||
@ -51,6 +50,9 @@ public class APPDevice extends BaseEntity implements Serializable {
|
|||||||
@ApiModelProperty(value = "设备MAC")
|
@ApiModelProperty(value = "设备MAC")
|
||||||
private String deviceMac;
|
private String deviceMac;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "设备IMEI")
|
||||||
|
private String deviceImei;
|
||||||
|
|
||||||
@ApiModelProperty(value = "设备SN")
|
@ApiModelProperty(value = "设备SN")
|
||||||
private String deviceSn;
|
private String deviceSn;
|
||||||
|
|
||||||
@ -90,6 +92,14 @@ public class APPDevice extends BaseEntity implements Serializable {
|
|||||||
@ApiModelProperty(value = "绑定状态")
|
@ApiModelProperty(value = "绑定状态")
|
||||||
private Integer bindingStatus;
|
private Integer bindingStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 绑定类型
|
||||||
|
* 0 APP
|
||||||
|
* 1 小程序
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "绑定类型")
|
||||||
|
private Integer bindingType;
|
||||||
|
|
||||||
|
|
||||||
public void copy(Device source) {
|
public void copy(Device source) {
|
||||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
|||||||
@ -3,10 +3,13 @@ package com.fuyuanshen.modules.system.domain.app;
|
|||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import com.fuyuanshen.modules.system.domain.DeviceType;
|
import com.fuyuanshen.base.BaseEntity;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotBlank;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 设备类型
|
* @Description: 设备类型
|
||||||
* @Author: WY
|
* @Author: WY
|
||||||
@ -14,11 +17,40 @@ import lombok.Data;
|
|||||||
**/
|
**/
|
||||||
@Data
|
@Data
|
||||||
@TableName("app_device_type")
|
@TableName("app_device_type")
|
||||||
public class APPDeviceType extends DeviceType {
|
public class APPDeviceType extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
@ApiModelProperty(value = "ID", hidden = true)
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "客户号")
|
||||||
|
private Long customerId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建该类型的客户")
|
||||||
|
private Long ownerCustomerId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户ID
|
||||||
|
*/
|
||||||
|
// @TableField(value = "tenant_id")
|
||||||
|
// @ApiModelProperty(hidden = true)
|
||||||
|
// private Long tenantId;
|
||||||
|
|
||||||
|
@NotBlank(message = "设备类型名称不能为空")
|
||||||
|
@ApiModelProperty(value = "类型名称", required = true)
|
||||||
|
private String typeName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否支持蓝牙")
|
||||||
|
private Boolean isSupportBle;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "定位方式", example = "0:无;1:GPS;2:基站;3:wifi;4:北斗")
|
||||||
|
private String locateMode;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "联网方式", example = "0:无;1:4G;2:WIFI")
|
||||||
|
private String networkWay;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "通讯方式", example = "0:4G;1:蓝牙")
|
||||||
|
private String communicationMode;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,4 +58,7 @@ public class DeviceQueryCriteria {
|
|||||||
@ApiModelProperty(value = "租户ID")
|
@ApiModelProperty(value = "租户ID")
|
||||||
private Long tenantId;
|
private Long tenantId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "通讯方式", example = "0:4G;1:蓝牙")
|
||||||
|
private Integer communicationMode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,45 @@
|
|||||||
|
package com.fuyuanshen.modules.system.enums;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通讯方式枚举
|
||||||
|
*
|
||||||
|
* @author: 默苍璃
|
||||||
|
* @date: 2025-06-2414:11
|
||||||
|
*/
|
||||||
|
public enum CommunicationModeEnum {
|
||||||
|
|
||||||
|
FOUR_G(0, "4G"),
|
||||||
|
BLUETOOTH(1, "蓝牙");
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
private final String label;
|
||||||
|
|
||||||
|
CommunicationModeEnum(int value, String label) {
|
||||||
|
this.value = value;
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonValue
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据值获取标签
|
||||||
|
*/
|
||||||
|
public static String getLabelByValue(int value) {
|
||||||
|
for (CommunicationModeEnum mode : values()) {
|
||||||
|
if (mode.getValue() == value) {
|
||||||
|
return mode.getLabel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -19,6 +19,15 @@ import java.util.List;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface APPDeviceMapper extends BaseMapper<APPDevice> {
|
public interface APPDeviceMapper extends BaseMapper<APPDevice> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP用户设备列表
|
||||||
|
*
|
||||||
|
* @param page
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
IPage<APPDevice> appDeviceList(Page<APPDevice> page,@Param("criteria") DeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询APP/小程序设备
|
* 分页查询APP/小程序设备
|
||||||
@ -27,6 +36,7 @@ public interface APPDeviceMapper extends BaseMapper<APPDevice> {
|
|||||||
* @param page
|
* @param page
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
IPage<APPDevice> queryAll(Page<APPDevice> page, @Param("criteria")DeviceQueryCriteria criteria );
|
IPage<APPDevice> queryAll(Page<APPDevice> page, @Param("criteria") DeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
package com.fuyuanshen.modules.system.mapper.app;
|
||||||
|
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
||||||
|
import com.fuyuanshen.modules.system.domain.dto.DeviceQueryCriteria;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 97433
|
||||||
|
* @description 针对表【app_device_type(设备类型表)】的数据库操作Mapper
|
||||||
|
* @createDate 2025-06-24 11:16:18
|
||||||
|
* @Entity system.domain.AppDeviceType
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface AppDeviceTypeMapper extends BaseMapper<APPDeviceType> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备类型列表
|
||||||
|
*
|
||||||
|
* @param criteria 查询条件
|
||||||
|
* @return 设备类型列表
|
||||||
|
*/
|
||||||
|
List<APPDeviceType> appTypeList(DeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
}
|
||||||
@ -8,6 +8,7 @@ import com.fuyuanshen.modules.system.constant.UserConstants;
|
|||||||
import com.fuyuanshen.modules.system.domain.Device;
|
import com.fuyuanshen.modules.system.domain.Device;
|
||||||
import com.fuyuanshen.modules.system.domain.User;
|
import com.fuyuanshen.modules.system.domain.User;
|
||||||
import com.fuyuanshen.modules.system.domain.app.APPDevice;
|
import com.fuyuanshen.modules.system.domain.app.APPDevice;
|
||||||
|
import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.CustomerVo;
|
import com.fuyuanshen.modules.system.domain.dto.CustomerVo;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.DeviceExcelImportDTO;
|
import com.fuyuanshen.modules.system.domain.dto.DeviceExcelImportDTO;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.DeviceForm;
|
import com.fuyuanshen.modules.system.domain.dto.DeviceForm;
|
||||||
@ -67,8 +68,39 @@ public class APPDeviceController {
|
|||||||
private final APPDeviceService appDeviceService;
|
private final APPDeviceService appDeviceService;
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/list")
|
||||||
|
@ApiOperation("APP用户设备列表")
|
||||||
|
public ResponseVO<PageResult<APPDevice>> appDeviceList(@RequestBody DeviceQueryCriteria criteria) {
|
||||||
|
Page<APPDevice> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
|
PageResult<APPDevice> devices = null;
|
||||||
|
try {
|
||||||
|
devices = appDeviceService.appDeviceList(page, criteria);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("queryDevice error: " + e.getMessage());
|
||||||
|
return ResponseVO.fail("");
|
||||||
|
}
|
||||||
|
return ResponseVO.success(devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/typeList")
|
||||||
|
@ApiOperation("APP用户设备类型列表")
|
||||||
|
public ResponseVO<List<APPDeviceType>> appTypeList(@RequestBody DeviceQueryCriteria criteria) {
|
||||||
|
List<APPDeviceType> typeList = appDeviceService.appTypeList(criteria);
|
||||||
|
return ResponseVO.success(typeList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/bind")
|
||||||
|
@ApiOperation("APP用户设备绑定")
|
||||||
|
public ResponseVO<String> appBindDevice(@RequestBody DeviceQueryCriteria criteria) {
|
||||||
|
appDeviceService.appBindDevice(criteria);
|
||||||
|
return ResponseVO.success("绑定成功!");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("查看APP用户设备绑定")
|
@ApiOperation("WEB端查看APP用户设备绑定")
|
||||||
public ResponseVO<PageResult<APPDevice>> queryAPPDevice(DeviceQueryCriteria criteria) {
|
public ResponseVO<PageResult<APPDevice>> queryAPPDevice(DeviceQueryCriteria criteria) {
|
||||||
Page<APPDevice> page = new Page<>(criteria.getPage(), criteria.getSize());
|
Page<APPDevice> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
PageResult<APPDevice> devices = null;
|
PageResult<APPDevice> devices = null;
|
||||||
@ -83,7 +115,7 @@ public class APPDeviceController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping(value = "/unbind")
|
@PostMapping(value = "/unbind")
|
||||||
@ApiOperation("APP用户设备解绑")
|
@ApiOperation("WEB端APP用户设备解绑")
|
||||||
public ResponseVO<String> unbindAPPDevice(@Validated @ModelAttribute APPUnbindDTO deviceForm) {
|
public ResponseVO<String> unbindAPPDevice(@Validated @ModelAttribute APPUnbindDTO deviceForm) {
|
||||||
appDeviceService.unbindAPPDevice(deviceForm);
|
appDeviceService.unbindAPPDevice(deviceForm);
|
||||||
return ResponseVO.success("解绑成功!!!");
|
return ResponseVO.success("解绑成功!!!");
|
||||||
|
|||||||
@ -87,9 +87,19 @@ public class APPUserController {
|
|||||||
return ResponseVO.success(appUserService.queryAPPUser(criteria, page));
|
return ResponseVO.success(appUserService.queryAPPUser(criteria, page));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("app")
|
|
||||||
|
@ApiOperation("用户中心")
|
||||||
|
@GetMapping(value = "/get")
|
||||||
|
@PreAuthorize("@el.check('appUser:get')")
|
||||||
|
public ResponseVO<APPUser> getAPPUser(UserQueryCriteria criteria) {
|
||||||
|
String userName = SecurityUtils.getCurrentUsername();
|
||||||
|
return null;
|
||||||
|
// return ResponseVO.success(appUserService.getAPPUser(criteria));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log("app用户注册")
|
||||||
@ApiOperation("app用户注册")
|
@ApiOperation("app用户注册")
|
||||||
@AnonymousPostMapping(value = "/app/register")
|
@AnonymousPostMapping(value = "/register")
|
||||||
public ResponseVO<String> APPRegister(@Validated @RequestBody APPUserDTO user) throws Exception {
|
public ResponseVO<String> APPRegister(@Validated @RequestBody APPUserDTO user) throws Exception {
|
||||||
|
|
||||||
//暫定0000
|
//暫定0000
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.fuyuanshen.modules.system.domain.Device;
|
import com.fuyuanshen.modules.system.domain.Device;
|
||||||
import com.fuyuanshen.modules.system.domain.app.APPDevice;
|
import com.fuyuanshen.modules.system.domain.app.APPDevice;
|
||||||
|
import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.CustomerVo;
|
import com.fuyuanshen.modules.system.domain.dto.CustomerVo;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.DeviceForm;
|
import com.fuyuanshen.modules.system.domain.dto.DeviceForm;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.DeviceQueryCriteria;
|
import com.fuyuanshen.modules.system.domain.dto.DeviceQueryCriteria;
|
||||||
@ -22,6 +23,29 @@ import java.util.List;
|
|||||||
**/
|
**/
|
||||||
public interface APPDeviceService extends IService<APPDevice> {
|
public interface APPDeviceService extends IService<APPDevice> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP用户设备列表
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
*/
|
||||||
|
PageResult<APPDevice> appDeviceList(Page<APPDevice> page, DeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP用户设备类型列表
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<APPDeviceType> appTypeList(DeviceQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP/小程序用户设备绑定
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
*/
|
||||||
|
void appBindDevice(DeviceQueryCriteria criteria);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询APP/小程序设备绑定
|
* 分页查询APP/小程序设备绑定
|
||||||
*
|
*
|
||||||
@ -38,4 +62,5 @@ public interface APPDeviceService extends IService<APPDevice> {
|
|||||||
*/
|
*/
|
||||||
void unbindAPPDevice(APPUnbindDTO deviceForm);
|
void unbindAPPDevice(APPUnbindDTO deviceForm);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,48 +2,35 @@ package com.fuyuanshen.modules.system.service.app;
|
|||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.fuyuanshen.constants.DeviceConstants;
|
|
||||||
import com.fuyuanshen.constants.ExceptionMessages;
|
|
||||||
import com.fuyuanshen.exception.BadRequestException;
|
import com.fuyuanshen.exception.BadRequestException;
|
||||||
import com.fuyuanshen.modules.security.service.UserCacheManager;
|
|
||||||
import com.fuyuanshen.modules.system.constant.UserConstants;
|
|
||||||
import com.fuyuanshen.modules.system.domain.Device;
|
import com.fuyuanshen.modules.system.domain.Device;
|
||||||
import com.fuyuanshen.modules.system.domain.DeviceType;
|
import com.fuyuanshen.modules.system.domain.DeviceType;
|
||||||
import com.fuyuanshen.modules.system.domain.User;
|
|
||||||
import com.fuyuanshen.modules.system.domain.app.APPDevice;
|
import com.fuyuanshen.modules.system.domain.app.APPDevice;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.CustomerVo;
|
import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.DeviceForm;
|
|
||||||
import com.fuyuanshen.modules.system.domain.dto.DeviceQueryCriteria;
|
import com.fuyuanshen.modules.system.domain.dto.DeviceQueryCriteria;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.app.APPUnbindDTO;
|
import com.fuyuanshen.modules.system.domain.dto.app.APPUnbindDTO;
|
||||||
import com.fuyuanshen.modules.system.enums.BindingStatusEnum;
|
import com.fuyuanshen.modules.system.enums.BindingStatusEnum;
|
||||||
|
import com.fuyuanshen.modules.system.enums.CommunicationModeEnum;
|
||||||
|
import com.fuyuanshen.modules.system.enums.UserType;
|
||||||
import com.fuyuanshen.modules.system.mapper.DeviceMapper;
|
import com.fuyuanshen.modules.system.mapper.DeviceMapper;
|
||||||
import com.fuyuanshen.modules.system.mapper.DeviceTypeMapper;
|
import com.fuyuanshen.modules.system.mapper.DeviceTypeMapper;
|
||||||
import com.fuyuanshen.modules.system.mapper.UserMapper;
|
|
||||||
import com.fuyuanshen.modules.system.mapper.app.APPDeviceMapper;
|
import com.fuyuanshen.modules.system.mapper.app.APPDeviceMapper;
|
||||||
import com.fuyuanshen.modules.system.service.DeviceService;
|
import com.fuyuanshen.modules.system.mapper.app.AppDeviceTypeMapper;
|
||||||
import com.fuyuanshen.modules.system.service.UserService;
|
import com.fuyuanshen.utils.PageResult;
|
||||||
import com.fuyuanshen.modules.system.service.impl.DeviceTypeServiceImpl;
|
import com.fuyuanshen.utils.SecurityUtils;
|
||||||
import com.fuyuanshen.modules.utils.NanoId;
|
|
||||||
import com.fuyuanshen.utils.*;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
|
||||||
import org.springframework.security.core.Authentication;
|
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.*;
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -58,6 +45,89 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
|||||||
|
|
||||||
private final APPDeviceMapper appDeviceMapper;
|
private final APPDeviceMapper appDeviceMapper;
|
||||||
private final DeviceMapper deviceMapper;
|
private final DeviceMapper deviceMapper;
|
||||||
|
private final DeviceTypeMapper deviceTypeMapper;
|
||||||
|
private final AppDeviceTypeMapper appDeviceTypeMapper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP用户设备列表
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageResult<APPDevice> appDeviceList(Page<APPDevice> page, DeviceQueryCriteria criteria) {
|
||||||
|
IPage<APPDevice> devices = appDeviceMapper.appDeviceList(page, criteria);
|
||||||
|
return new PageResult<>(devices.getRecords(), devices.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP用户设备类型列表
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<APPDeviceType> appTypeList(DeviceQueryCriteria criteria) {
|
||||||
|
return appDeviceTypeMapper.appTypeList(criteria);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* APP/小程序用户设备绑定
|
||||||
|
*
|
||||||
|
* @param criteria
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void appBindDevice(DeviceQueryCriteria criteria) {
|
||||||
|
|
||||||
|
List<Device> devices = new ArrayList<>();
|
||||||
|
|
||||||
|
if (criteria.getCommunicationMode().equals(CommunicationModeEnum.BLUETOOTH.getValue())) {
|
||||||
|
devices = deviceMapper.selectList(new QueryWrapper<Device>().eq("device_mac", criteria.getDeviceMac()));
|
||||||
|
if (CollectionUtil.isEmpty(devices)) {
|
||||||
|
throw new BadRequestException("请先将设备入库!!!");
|
||||||
|
}
|
||||||
|
List<APPDevice> appDevices = appDeviceMapper.selectList(new QueryWrapper<APPDevice>()
|
||||||
|
.eq("device_mac", criteria.getDeviceMac()).eq("binding_type", UserType.APP.getValue()));
|
||||||
|
if (CollectionUtil.isNotEmpty(appDevices)) {
|
||||||
|
throw new BadRequestException("该设备已绑定!!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (criteria.getCommunicationMode().equals(CommunicationModeEnum.FOUR_G.getValue())) {
|
||||||
|
devices = deviceMapper.selectList(new QueryWrapper<Device>().eq("device_imei", criteria.getDeviceImei()));
|
||||||
|
if (CollectionUtil.isEmpty(devices)) {
|
||||||
|
throw new BadRequestException("请先将设备入库!!!");
|
||||||
|
}
|
||||||
|
List<APPDevice> appDevices = appDeviceMapper.selectList(new QueryWrapper<APPDevice>()
|
||||||
|
.eq("device_imei", criteria.getDeviceImei()).eq("binding_type", UserType.APP.getValue()));
|
||||||
|
if (CollectionUtil.isNotEmpty(appDevices)) {
|
||||||
|
throw new BadRequestException("该设备已绑定!!!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Device device = devices.get(0);
|
||||||
|
APPDevice appDevice = new APPDevice();
|
||||||
|
BeanUtil.copyProperties(device, appDevice);
|
||||||
|
appDevice.setBindingType(UserType.APP.getValue());
|
||||||
|
appDevice.setBindingStatus(BindingStatusEnum.BOUND.getCode());
|
||||||
|
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||||
|
appDevice.setCustomerId(currentUserId);
|
||||||
|
appDevice.setCreateTime(new Timestamp(System.currentTimeMillis()));
|
||||||
|
// 设备类型名称
|
||||||
|
appDevice.setDeviceTypeName(device.getTypeName());
|
||||||
|
appDeviceMapper.insert(appDevice);
|
||||||
|
|
||||||
|
APPDeviceType appDeviceType = appDeviceTypeMapper.selectById(device.getDeviceType());
|
||||||
|
if (appDeviceType == null) {
|
||||||
|
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
||||||
|
APPDeviceType type = new APPDeviceType();
|
||||||
|
BeanUtil.copyProperties(deviceType, type);
|
||||||
|
appDeviceTypeMapper.insert(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,11 +153,17 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
|||||||
@Transactional
|
@Transactional
|
||||||
public void unbindAPPDevice(APPUnbindDTO deviceForm) {
|
public void unbindAPPDevice(APPUnbindDTO deviceForm) {
|
||||||
|
|
||||||
appDeviceMapper.delete(new QueryWrapper<APPDevice>().eq("device_mac", deviceForm.getDeviceMac()));
|
appDeviceMapper.delete(new QueryWrapper<APPDevice>().eq("device_mac", deviceForm.getDeviceMac()).eq("binding_type", UserType.APP.getValue()));
|
||||||
|
List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>().eq("device_mac", deviceForm.getDeviceMac()));
|
||||||
|
List<Long> ids = devices.stream()
|
||||||
|
.map(Device::getId)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
appDeviceTypeMapper.deleteBatchIds(ids);
|
||||||
Device device = new Device();
|
Device device = new Device();
|
||||||
device.setId(deviceForm.getCustomerId());
|
device.setId(deviceForm.getCustomerId());
|
||||||
device.setBindingStatus(BindingStatusEnum.UNBOUND.getCode());
|
device.setBindingStatus(BindingStatusEnum.UNBOUND.getCode());
|
||||||
deviceMapper.updateById(device);
|
deviceMapper.updateById(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.fuyuanshen.modules.system.service.app;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 97433
|
||||||
|
* @description 针对表【app_device_type(设备类型表)】的数据库操作Service
|
||||||
|
* @createDate 2025-06-24 11:16:18
|
||||||
|
*/
|
||||||
|
public interface AppDeviceTypeService extends IService<APPDeviceType> {
|
||||||
|
|
||||||
|
}
|
||||||
@ -12,10 +12,7 @@ import com.fuyuanshen.constants.ExceptionMessages;
|
|||||||
import com.fuyuanshen.exception.BadRequestException;
|
import com.fuyuanshen.exception.BadRequestException;
|
||||||
import com.fuyuanshen.modules.security.service.UserCacheManager;
|
import com.fuyuanshen.modules.security.service.UserCacheManager;
|
||||||
import com.fuyuanshen.modules.system.constant.UserConstants;
|
import com.fuyuanshen.modules.system.constant.UserConstants;
|
||||||
import com.fuyuanshen.modules.system.domain.Device;
|
import com.fuyuanshen.modules.system.domain.*;
|
||||||
import com.fuyuanshen.modules.system.domain.DeviceAssignments;
|
|
||||||
import com.fuyuanshen.modules.system.domain.DeviceTypeGrants;
|
|
||||||
import com.fuyuanshen.modules.system.domain.User;
|
|
||||||
import com.fuyuanshen.modules.system.domain.app.APPDevice;
|
import com.fuyuanshen.modules.system.domain.app.APPDevice;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.CustomerVo;
|
import com.fuyuanshen.modules.system.domain.dto.CustomerVo;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.DeviceForm;
|
import com.fuyuanshen.modules.system.domain.dto.DeviceForm;
|
||||||
@ -195,6 +192,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
// device.setId(snowflakeGenerator.next());
|
// device.setId(snowflakeGenerator.next());
|
||||||
device.setCurrentOwnerId(currentUser.getId());
|
device.setCurrentOwnerId(currentUser.getId());
|
||||||
device.setOriginalOwnerId(currentUser.getId());
|
device.setOriginalOwnerId(currentUser.getId());
|
||||||
|
DeviceType deviceType = deviceTypeMapper.selectById(deviceForm.getDeviceType());
|
||||||
|
device.setTypeName(deviceType.getTypeName());
|
||||||
|
|
||||||
deviceMapper.insert(device);
|
deviceMapper.insert(device);
|
||||||
|
|
||||||
|
|||||||
@ -76,9 +76,7 @@ public class APPUserServiceImpl extends ServiceImpl<APPUserMapper, APPUser> impl
|
|||||||
APPUser appUser = new APPUser();
|
APPUser appUser = new APPUser();
|
||||||
appUser.setUsername(user.getPhoneNumber());
|
appUser.setUsername(user.getPhoneNumber());
|
||||||
|
|
||||||
// String enPassword = passwordEncoder.encode(user.getPassword());
|
appUser.setPassword(user.getPassword());
|
||||||
String enPassword = MD5.create().digestHex(user.getPassword());
|
|
||||||
appUser.setPassword(enPassword);
|
|
||||||
appUser.setNickName(user.getPhoneNumber());
|
appUser.setNickName(user.getPhoneNumber());
|
||||||
appUser.setUserLevel((byte) 1);
|
appUser.setUserLevel((byte) 1);
|
||||||
appUser.setPhone(Long.valueOf(user.getPhoneNumber()));
|
appUser.setPhone(Long.valueOf(user.getPhoneNumber()));
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
package com.fuyuanshen.modules.system.service.impl.app;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
||||||
|
import com.fuyuanshen.modules.system.mapper.app.AppDeviceTypeMapper;
|
||||||
|
import com.fuyuanshen.modules.system.service.app.AppDeviceTypeService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author 97433
|
||||||
|
* @description 针对表【app_device_type(设备类型表)】的数据库操作Service实现
|
||||||
|
* @createDate 2025-06-24 11:16:18
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class AppDeviceTypeServiceImpl extends ServiceImpl<AppDeviceTypeMapper, APPDeviceType>
|
||||||
|
implements AppDeviceTypeService {
|
||||||
|
|
||||||
|
}
|
||||||
@ -19,17 +19,20 @@
|
|||||||
<result column="binding_status" property="bindingStatus"/>
|
<result column="binding_status" property="bindingStatus"/>
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<!-- 分页查询APP/小程序设备 -->
|
<!-- APP用户设备列表 -->
|
||||||
<select id="queryAll" resultType="com.fuyuanshen.modules.system.domain.app.APPDevice">
|
<select id="appDeviceList" resultType="com.fuyuanshen.modules.system.domain.app.APPDevice">
|
||||||
select d.* from app_device as d
|
select d.* from app_device as d
|
||||||
<where>
|
<where>
|
||||||
<!-- 时间范围等其他条件保持原样 -->
|
<!-- 时间范围等其他条件保持原样 -->
|
||||||
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||||
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
||||||
</if>
|
</if>
|
||||||
<if test="criteria.deviceMac != null and criteria.deviceName.trim() != ''">
|
<if test="criteria.deviceMac != null and criteria.deviceMac.trim() != ''">
|
||||||
and d.device_mac = #{criteria.deviceMac}
|
and d.device_mac = #{criteria.deviceMac}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="criteria.deviceImei != null and criteria.deviceImei.trim() != ''">
|
||||||
|
and d.device_imei = #{criteria.deviceImei}
|
||||||
|
</if>
|
||||||
<if test="criteria.deviceSn != null">
|
<if test="criteria.deviceSn != null">
|
||||||
and d.device_sn = #{criteria.deviceSn}
|
and d.device_sn = #{criteria.deviceSn}
|
||||||
</if>
|
</if>
|
||||||
@ -42,13 +45,47 @@
|
|||||||
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||||
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="criteria.tenantId != null">
|
<if test="criteria.tenantId != null">
|
||||||
AND tenant_id = #{criteria.tenantId}
|
AND tenant_id = #{criteria.tenantId}
|
||||||
</if>
|
</if>
|
||||||
and d.customer_id = #{criteria.customerId}
|
and d.customer_id = #{criteria.customerId}
|
||||||
</where>
|
</where>
|
||||||
order by d.app_device_id desc
|
order by d.create_time desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 分页查询APP/小程序设备 -->
|
||||||
|
<select id="queryAll" resultType="com.fuyuanshen.modules.system.domain.app.APPDevice">
|
||||||
|
select d.* from app_device as d
|
||||||
|
<where>
|
||||||
|
<!-- 时间范围等其他条件保持原样 -->
|
||||||
|
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||||
|
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceMac != null and criteria.deviceMac.trim() != ''">
|
||||||
|
and d.device_mac = #{criteria.deviceMac}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceImei != null and criteria.deviceImei.trim() != ''">
|
||||||
|
and d.device_imei = #{criteria.deviceImei}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceSn != null">
|
||||||
|
and d.device_sn = #{criteria.deviceSn}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceType != null">
|
||||||
|
and d.device_type = #{criteria.deviceType}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceStatus != null">
|
||||||
|
and d.device_status = #{criteria.deviceStatus}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||||
|
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.tenantId != null">
|
||||||
|
AND tenant_id = #{criteria.tenantId}
|
||||||
|
</if>
|
||||||
|
and d.customer_id = #{criteria.customerId}
|
||||||
|
</where>
|
||||||
|
order by d.create_time desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
@ -0,0 +1,59 @@
|
|||||||
|
<?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.fuyuanshen.modules.system.mapper.app.AppDeviceTypeMapper">
|
||||||
|
|
||||||
|
<resultMap id="BaseResultMap" type="com.fuyuanshen.modules.system.domain.app.APPDeviceType">
|
||||||
|
<id property="id" column="id"/>
|
||||||
|
<result property="typeName" column="type_name"/>
|
||||||
|
<result property="isSupportBle" column="is_support_ble"/>
|
||||||
|
<result property="locateMode" column="locate_mode"/>
|
||||||
|
<result property="networkWay" column="network_way"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="createTime" column="create_time"/>
|
||||||
|
<result property="updateTime" column="update_time"/>
|
||||||
|
<result property="customerId" column="customer_id"/>
|
||||||
|
<result property="communicationMode" column="communication_mode"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id,type_name,is_support_ble,locate_mode,network_way,create_by,
|
||||||
|
update_by,create_time,update_time,customer_id,communication_mode
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 查询设备类型列表 -->
|
||||||
|
<select id="appTypeList" resultType="com.fuyuanshen.modules.system.domain.app.APPDeviceType">
|
||||||
|
select d.* from app_device_type as d
|
||||||
|
<where>
|
||||||
|
<!-- 时间范围等其他条件保持原样 -->
|
||||||
|
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||||
|
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceMac != null and criteria.deviceMac.trim() != ''">
|
||||||
|
and d.device_mac = #{criteria.deviceMac}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceImei != null and criteria.deviceImei.trim() != ''">
|
||||||
|
and d.device_imei = #{criteria.deviceImei}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceSn != null">
|
||||||
|
and d.device_sn = #{criteria.deviceSn}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceType != null">
|
||||||
|
and d.device_type = #{criteria.deviceType}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.deviceStatus != null">
|
||||||
|
and d.device_status = #{criteria.deviceStatus}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||||
|
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||||
|
</if>
|
||||||
|
<if test="criteria.tenantId != null">
|
||||||
|
AND tenant_id = #{criteria.tenantId}
|
||||||
|
</if>
|
||||||
|
and d.customer_id = #{criteria.customerId}
|
||||||
|
</where>
|
||||||
|
order by d.create_time desc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user