Compare commits
20 Commits
401d6752cf
...
main
Author | SHA1 | Date | |
---|---|---|---|
bd802ab8fd | |||
e1a6642af4 | |||
b05b01b007 | |||
cb57a595aa | |||
953ffdfb28 | |||
968f1cbb16 | |||
6b9a09c9e8 | |||
6e41426faa | |||
64729a223d | |||
134c17a2bd | |||
5c2aba3d32 | |||
6a6adc5ec1 | |||
ec03919c78 | |||
c61f2a7265 | |||
ae88cc16cc | |||
b467e02ff6 | |||
d64216ee5f | |||
a7bb1d8e84 | |||
1f7f4bf537 | |||
9a975b36c5 |
@ -0,0 +1,8 @@
|
||||
package com.fuyuanshen.constants;
|
||||
|
||||
public class RedisConstants {
|
||||
|
||||
public static final String APP_FORGOT_PASSWORD_SMS_TOKEN = "app_sms_forgotPassword:";
|
||||
|
||||
public static final String APP_REGISTER_SMS_TOKEN = "app_sms_register:";
|
||||
}
|
@ -38,4 +38,5 @@ public interface GenConfigService extends IService<GenConfig> {
|
||||
* @return 表配置
|
||||
*/
|
||||
GenConfig update(String tableName, GenConfig genConfig);
|
||||
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class LoginProperties {
|
||||
|
||||
/**
|
||||
* 账号单用户 登录
|
||||
* 账号单用户
|
||||
*/
|
||||
private boolean singleLogin = false;
|
||||
|
||||
|
@ -146,7 +146,7 @@ public class AuthController {
|
||||
@Log("app用户登录")
|
||||
@ApiOperation("app用户登录")
|
||||
@AnonymousPostMapping(value = "/app/login")
|
||||
public ResponseEntity<Object> APPLogin(@Validated @RequestBody AppAuthUserDto authUser, HttpServletRequest request) throws Exception {
|
||||
public ResponseVO<Object> APPLogin(@Validated @RequestBody AppAuthUserDto authUser, HttpServletRequest request) throws Exception {
|
||||
|
||||
// 1. 构建查询参数
|
||||
APPUserQuery appUserQuery = new APPUserQuery();
|
||||
@ -196,7 +196,7 @@ public class AuthController {
|
||||
onlineUserService.saveAppOnlineUser(jwtUser, token, request);
|
||||
|
||||
// 11. 返回结果
|
||||
return ResponseEntity.ok(authInfo);
|
||||
return ResponseVO.success(authInfo);
|
||||
}
|
||||
|
||||
|
||||
|
@ -70,6 +70,7 @@ public class AppTokenProvider implements InitializingBean {
|
||||
/**
|
||||
* 创建Token 设置永不过期,
|
||||
* Token 的时间有效性转到Redis 维护
|
||||
*
|
||||
* @param user /
|
||||
* @return /
|
||||
*/
|
||||
@ -77,7 +78,7 @@ public class AppTokenProvider implements InitializingBean {
|
||||
// 设置参数
|
||||
Map<String, Object> claims = new HashMap<>(6);
|
||||
// 设置用户ID
|
||||
// claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
||||
claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
||||
// if (user.getAppUser() != null){
|
||||
// claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
||||
// }else {
|
||||
@ -94,6 +95,7 @@ public class AppTokenProvider implements InitializingBean {
|
||||
/**
|
||||
* APP创建Token 设置永不过期,
|
||||
* Token 的时间有效性转到Redis 维护
|
||||
*
|
||||
* @param user /
|
||||
* @return /
|
||||
*/
|
||||
@ -102,7 +104,7 @@ public class AppTokenProvider implements InitializingBean {
|
||||
Map<String, Object> claims = new HashMap<>(6);
|
||||
|
||||
// 设置用户ID
|
||||
// claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
||||
claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
||||
// if (user.getAppUser() != null){
|
||||
// claims.put(AUTHORITIES_UID_KEY, user.getAppUser().getId());
|
||||
// }else {
|
||||
@ -110,7 +112,7 @@ public class AppTokenProvider implements InitializingBean {
|
||||
// }
|
||||
// 设置UUID,确保每次Token不一样
|
||||
claims.put(AUTHORITIES_UUID_KEY, IdUtil.simpleUUID());
|
||||
claims.put("userType","1");//0 系统登录 1 APP登录
|
||||
claims.put("userType", "1");// 0 系统登录 1 APP登录
|
||||
return jwtBuilder
|
||||
.setClaims(claims)
|
||||
.setSubject(user.getAppUser().getUsername())
|
||||
@ -162,6 +164,7 @@ public class AppTokenProvider implements InitializingBean {
|
||||
|
||||
/**
|
||||
* 获取登录用户RedisKey
|
||||
*
|
||||
* @param token /
|
||||
* @return key
|
||||
*/
|
||||
@ -172,6 +175,7 @@ public class AppTokenProvider implements InitializingBean {
|
||||
|
||||
/**
|
||||
* 获取会话编号
|
||||
*
|
||||
* @param token /
|
||||
* @return /
|
||||
*/
|
||||
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import com.fuyuanshen.base.BaseEntity;
|
||||
@ -20,6 +21,7 @@ import java.io.Serializable;
|
||||
**/
|
||||
@Data
|
||||
@TableName("device")
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS) // 关键注解
|
||||
public class Device extends BaseEntity implements Serializable {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
|
@ -50,6 +50,9 @@ public class APPDevice extends BaseEntity implements Serializable {
|
||||
@ApiModelProperty(value = "设备MAC")
|
||||
private String deviceMac;
|
||||
|
||||
@ApiModelProperty(value = "设备IMEI")
|
||||
private String deviceImei;
|
||||
|
||||
@ApiModelProperty(value = "设备SN")
|
||||
private String deviceSn;
|
||||
|
||||
|
@ -3,10 +3,13 @@ package com.fuyuanshen.modules.system.domain.app;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fuyuanshen.modules.system.domain.DeviceType;
|
||||
import com.fuyuanshen.base.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: 设备类型
|
||||
* @Author: WY
|
||||
@ -14,11 +17,40 @@ import lombok.Data;
|
||||
**/
|
||||
@Data
|
||||
@TableName("app_device_type")
|
||||
public class APPDeviceType extends DeviceType {
|
||||
public class APPDeviceType extends BaseEntity implements Serializable {
|
||||
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
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;
|
||||
|
||||
|
||||
}
|
||||
|
@ -16,14 +16,19 @@
|
||||
package com.fuyuanshen.modules.system.domain.app;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fuyuanshen.modules.system.domain.Role;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import com.fuyuanshen.base.BaseEntity;
|
||||
import com.fuyuanshen.utils.enums.DataScopeEnum;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
@ -32,12 +37,49 @@ import javax.validation.constraints.NotNull;
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("app_sys_role")
|
||||
public class APPRole extends Role {
|
||||
@TableName("sys_role")
|
||||
public class APPRole extends BaseEntity implements Serializable {
|
||||
|
||||
@NotNull(groups = {Update.class})
|
||||
@TableId(value="app_role_id", type = IdType.AUTO)
|
||||
@TableId(value="role_id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "用户", hidden = true)
|
||||
private Set<APPUser> users;
|
||||
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "菜单", hidden = true)
|
||||
private Set<APPMenu> menus;
|
||||
|
||||
@NotBlank
|
||||
@ApiModelProperty(value = "名称", hidden = true)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "数据权限,全部 、 本级 、 自定义")
|
||||
private String dataScope = DataScopeEnum.THIS_LEVEL.getValue();
|
||||
|
||||
@ApiModelProperty(value = "级别,数值越小,级别越大")
|
||||
private Integer level = 3;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
private String description;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
APPRole role = (APPRole) o;
|
||||
return Objects.equals(id, role.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(id);
|
||||
}
|
||||
}
|
||||
|
@ -133,4 +133,8 @@ public class APPUser extends BaseEntity implements Serializable {
|
||||
@ApiModelProperty(hidden = true)
|
||||
private Integer userType;
|
||||
|
||||
/**
|
||||
* 地区
|
||||
*/
|
||||
private String region;
|
||||
}
|
@ -17,6 +17,9 @@ public class DeviceForm {
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "设备记录ID")
|
||||
private Long assignId;
|
||||
|
||||
@ApiModelProperty(value = "设备类型")
|
||||
private Long deviceType;
|
||||
|
||||
|
@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ -58,4 +57,7 @@ public class DeviceQueryCriteria {
|
||||
@ApiModelProperty(value = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
@ApiModelProperty(value = "通讯方式", example = "0:4G;1:蓝牙")
|
||||
private Integer communicationMode;
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.fuyuanshen.modules.system.domain.dto.app;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-06-1818:36
|
||||
*/
|
||||
@Data
|
||||
public class APPForgotPasswordDTO {
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
@ApiModelProperty(value = "手机号(APP登录)")
|
||||
private String phoneNumber;
|
||||
|
||||
|
||||
@NotBlank(message = "密码不能为空")
|
||||
@ApiModelProperty(value = "密码")
|
||||
private String password;
|
||||
|
||||
@ApiModelProperty(value = "验证码")
|
||||
@NotBlank(message = "验证码不能为空")
|
||||
private String verificationCode;
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.fuyuanshen.modules.system.domain.dto.app;
|
||||
|
||||
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
/**
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-06-1818:36
|
||||
*/
|
||||
@Data
|
||||
public class APPUpdateUserDTO {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty(value = "地区")
|
||||
private String region;
|
||||
|
||||
@ApiModelProperty(value = "用户性别")
|
||||
private String gender;
|
||||
|
||||
@ApiModelProperty(value = "头像图片")
|
||||
private MultipartFile file;
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.fuyuanshen.modules.system.domain.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author: 默苍璃
|
||||
* @date: 2025-06-1211:34
|
||||
*/
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||
public class APPUserVo {
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
@JsonProperty("id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "用户昵称")
|
||||
@JsonProperty("nickName")
|
||||
private String nickName;
|
||||
|
||||
@ApiModelProperty(value = "用户性别")
|
||||
@JsonProperty("gender")
|
||||
private String gender;
|
||||
|
||||
@ApiModelProperty(value = "电话号码")
|
||||
@JsonProperty("phone")
|
||||
private Long phone;
|
||||
|
||||
@ApiModelProperty(value = "头像存储的路径")
|
||||
@JsonProperty("avatarPath")
|
||||
private String avatarPath;
|
||||
|
||||
@ApiModelProperty(value = "地区")
|
||||
@JsonProperty("region")
|
||||
private String region;
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2019-2025 Zheng Jie
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.fuyuanshen.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.fuyuanshen.modules.system.domain.Role;
|
||||
import com.fuyuanshen.modules.system.domain.app.APPRole;
|
||||
import com.fuyuanshen.modules.system.domain.dto.RoleQueryCriteria;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2023-06-20
|
||||
*/
|
||||
@Mapper
|
||||
public interface APPRoleMapper extends BaseMapper<APPRole> {
|
||||
|
||||
|
||||
List<APPRole> findByUserId(@Param("userId") Long userId);
|
||||
|
||||
|
||||
}
|
@ -19,6 +19,15 @@ import java.util.List;
|
||||
@Mapper
|
||||
public interface APPDeviceMapper extends BaseMapper<APPDevice> {
|
||||
|
||||
/**
|
||||
* APP用户设备列表
|
||||
*
|
||||
* @param page
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
IPage<APPDevice> appDeviceList(Page<APPDevice> page,@Param("criteria") DeviceQueryCriteria criteria);
|
||||
|
||||
|
||||
/**
|
||||
* 分页查询APP/小程序设备
|
||||
@ -27,6 +36,7 @@ public interface APPDeviceMapper extends BaseMapper<APPDevice> {
|
||||
* @param page
|
||||
* @return
|
||||
*/
|
||||
IPage<APPDevice> queryAll(Page<APPDevice> page, @Param("criteria")DeviceQueryCriteria criteria );
|
||||
IPage<APPDevice> queryAll(Page<APPDevice> page, @Param("criteria") DeviceQueryCriteria criteria);
|
||||
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,29 @@
|
||||
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 org.apache.ibatis.annotations.Param;
|
||||
|
||||
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(@Param("criteria")DeviceQueryCriteria criteria);
|
||||
|
||||
}
|
@ -146,6 +146,20 @@ public class DeviceController {
|
||||
}
|
||||
|
||||
|
||||
@Log("撤回设备")
|
||||
@ApiOperation("撤回设备")
|
||||
@PostMapping(value = "/withdraw")
|
||||
public ResponseVO<Object> withdrawDevice(@Validated @ModelAttribute DeviceForm deviceForm) {
|
||||
try {
|
||||
deviceService.withdrawDevice(deviceForm);
|
||||
} catch (Exception e) {
|
||||
log.error("updateDevice error: " + e.getMessage());
|
||||
return ResponseVO.fail("出错了");
|
||||
}
|
||||
return ResponseVO.success(null);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("设备详情")
|
||||
@GetMapping(value = "/detail/{id}")
|
||||
public ResponseVO<Object> getDevice(@PathVariable Long id) {
|
||||
|
@ -1,55 +1,20 @@
|
||||
package com.fuyuanshen.modules.system.rest.app;
|
||||
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.annotation.Log;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.modules.system.constant.UserConstants;
|
||||
import com.fuyuanshen.modules.system.domain.Device;
|
||||
import com.fuyuanshen.modules.system.domain.User;
|
||||
import com.fuyuanshen.modules.system.domain.app.APPDevice;
|
||||
import com.fuyuanshen.modules.system.domain.dto.CustomerVo;
|
||||
import com.fuyuanshen.modules.system.domain.dto.DeviceExcelImportDTO;
|
||||
import com.fuyuanshen.modules.system.domain.dto.DeviceForm;
|
||||
import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
||||
import com.fuyuanshen.modules.system.domain.dto.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.modules.system.domain.dto.app.APPUnbindDTO;
|
||||
import com.fuyuanshen.modules.system.listener.excel.DeviceImportParams;
|
||||
import com.fuyuanshen.modules.system.listener.excel.UploadDeviceDataListener;
|
||||
import com.fuyuanshen.modules.system.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.modules.system.mapper.DeviceTypeMapper;
|
||||
import com.fuyuanshen.modules.system.mapper.UserMapper;
|
||||
import com.fuyuanshen.modules.system.service.DeviceService;
|
||||
import com.fuyuanshen.modules.system.service.UserService;
|
||||
import com.fuyuanshen.modules.system.service.app.APPDeviceService;
|
||||
import com.fuyuanshen.modules.system.service.impl.DeviceExportService;
|
||||
import com.fuyuanshen.modules.utils.ResponseVO;
|
||||
import com.fuyuanshen.modules.utils.excel.ImportResult;
|
||||
import com.fuyuanshen.utils.FileUtil;
|
||||
import com.fuyuanshen.utils.PageResult;
|
||||
import com.fuyuanshen.utils.SecurityUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -67,10 +32,33 @@ public class APPDeviceController {
|
||||
private final APPDeviceService appDeviceService;
|
||||
|
||||
|
||||
@GetMapping(value = "/bind")
|
||||
@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(@ApiParam("设备MAC地址") String mac) {
|
||||
appDeviceService.appBindDevice(mac);
|
||||
public ResponseVO<String> appBindDevice(@RequestBody DeviceQueryCriteria criteria) {
|
||||
appDeviceService.appBindDevice(criteria);
|
||||
return ResponseVO.success("绑定成功!");
|
||||
}
|
||||
|
||||
|
@ -15,54 +15,30 @@
|
||||
*/
|
||||
package com.fuyuanshen.modules.system.rest.app;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fuyuanshen.annotation.Log;
|
||||
import com.fuyuanshen.annotation.rest.AnonymousPostMapping;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.modules.security.service.UserCacheManager;
|
||||
import com.fuyuanshen.modules.security.service.dto.JwtUserDto;
|
||||
import com.fuyuanshen.modules.system.constant.UserConstants;
|
||||
import com.fuyuanshen.modules.system.domain.Dept;
|
||||
import com.fuyuanshen.modules.system.domain.Role;
|
||||
import com.fuyuanshen.modules.system.domain.User;
|
||||
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
||||
import com.fuyuanshen.modules.system.domain.dto.UserPassVo;
|
||||
import com.fuyuanshen.modules.system.domain.dto.DeviceForm;
|
||||
import com.fuyuanshen.modules.system.domain.dto.UserQueryCriteria;
|
||||
import com.fuyuanshen.modules.system.domain.dto.app.APPForgotPasswordDTO;
|
||||
import com.fuyuanshen.modules.system.domain.dto.app.APPUpdateUserDTO;
|
||||
import com.fuyuanshen.modules.system.domain.dto.app.APPUserDTO;
|
||||
import com.fuyuanshen.modules.system.domain.query.APPUserQuery;
|
||||
import com.fuyuanshen.modules.system.domain.vo.ConsumerVo;
|
||||
import com.fuyuanshen.modules.system.domain.vo.APPUserVo;
|
||||
import com.fuyuanshen.modules.system.enums.UserType;
|
||||
import com.fuyuanshen.modules.system.mapper.UserMapper;
|
||||
import com.fuyuanshen.modules.system.service.*;
|
||||
import com.fuyuanshen.modules.system.service.app.APPUserService;
|
||||
import com.fuyuanshen.modules.utils.ResponseVO;
|
||||
import com.fuyuanshen.utils.PageResult;
|
||||
import com.fuyuanshen.utils.SecurityUtils;
|
||||
import com.fuyuanshen.utils.StringUtils;
|
||||
import com.fuyuanshen.utils.enums.CodeEnum;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
@ -91,10 +67,17 @@ public class APPUserController {
|
||||
@ApiOperation("用户中心")
|
||||
@GetMapping(value = "/get")
|
||||
@PreAuthorize("@el.check('appUser:get')")
|
||||
public ResponseVO<APPUser> getAPPUser(UserQueryCriteria criteria) {
|
||||
public ResponseVO<APPUserVo> getAPPUser() {
|
||||
String userName = SecurityUtils.getCurrentUsername();
|
||||
return null;
|
||||
// return ResponseVO.success(appUserService.getAPPUser(criteria));
|
||||
APPUser appUser = appUserService.getLoginData(userName);
|
||||
|
||||
APPUserVo appUserVo = new APPUserVo();
|
||||
appUserVo.setId(appUser.getId());
|
||||
appUserVo.setNickName(appUser.getNickName());
|
||||
appUserVo.setGender(appUser.getGender());
|
||||
appUserVo.setPhone(appUser.getPhone());
|
||||
|
||||
return ResponseVO.success(appUserVo);
|
||||
}
|
||||
|
||||
@Log("app用户注册")
|
||||
@ -103,21 +86,53 @@ public class APPUserController {
|
||||
public ResponseVO<String> APPRegister(@Validated @RequestBody APPUserDTO user) throws Exception {
|
||||
|
||||
//暫定0000
|
||||
if (user.getVerificationCode() == null || !"0000".equals(user.getVerificationCode())) {
|
||||
if (!"0000".equals(user.getVerificationCode())) {
|
||||
throw new BadRequestException("验证码错误");
|
||||
}
|
||||
appUserService.addUser(user);
|
||||
return ResponseVO.success("success!!!");
|
||||
}
|
||||
|
||||
@Log("发送用户注册验证码")
|
||||
@ApiOperation("发送用户注册验证码")
|
||||
@AnonymousPostMapping(value = "/sendRegisterSms")
|
||||
public ResponseVO<String> sendRegisterSms(@Param("phoneNumber") String phoneNumber) throws Exception {
|
||||
// appUserService.sendSms(phoneNumber);
|
||||
return ResponseVO.success("success!!!");
|
||||
}
|
||||
|
||||
@Log("修改APP用户")
|
||||
@ApiOperation("修改APP用户")
|
||||
@PutMapping
|
||||
@PreAuthorize("@el.check('appUser:edit')")
|
||||
public ResponseVO<String> updateUser(@Validated(APPUser.Update.class) @RequestBody APPUser appUser) throws Exception {
|
||||
appUserService.updateById(appUser);
|
||||
public ResponseVO<String> updateUser(@Validated @ModelAttribute APPUpdateUserDTO appUser) throws Exception {
|
||||
Long userId = SecurityUtils.getCurrentUserId();
|
||||
if(!userId.equals(appUser.getId())){
|
||||
throw new BadRequestException("不能修改他人资料");
|
||||
}
|
||||
|
||||
appUserService.updateUser(appUser);
|
||||
return ResponseVO.success("success!!!");
|
||||
}
|
||||
|
||||
|
||||
@Log("忘记密码")
|
||||
@ApiOperation("忘记密码")
|
||||
@AnonymousPostMapping(value = "/forgotPassword")
|
||||
public ResponseVO<String> forgotPassword(@RequestBody APPForgotPasswordDTO appForgotPasswordDTO) throws Exception {
|
||||
if (!"0000".equals(appForgotPasswordDTO.getVerificationCode())) {
|
||||
throw new BadRequestException("验证码错误");
|
||||
}
|
||||
appUserService.forgotPassword(appForgotPasswordDTO);
|
||||
return ResponseVO.success("success!!!");
|
||||
}
|
||||
|
||||
@Log("发送忘记密码验证码")
|
||||
@ApiOperation("发送忘记密码验证码")
|
||||
@AnonymousPostMapping(value = "/sendForgotPasswordSms")
|
||||
public ResponseVO<String> sendForgotPasswordSms(@Param("phoneNumber") String phoneNumber) throws Exception {
|
||||
// appUserService.sendSms(phoneNumber);
|
||||
return ResponseVO.success("success!!!");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -73,6 +73,8 @@ public interface DeviceService extends IService<Device> {
|
||||
*/
|
||||
void assignCustomer(CustomerVo customerVo);
|
||||
|
||||
void withdrawDevice(DeviceForm deviceForm);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
*
|
||||
@ -110,5 +112,4 @@ public interface DeviceService extends IService<Device> {
|
||||
*/
|
||||
void unbindDevice(DeviceForm deviceForm);
|
||||
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.fuyuanshen.modules.system.domain.Device;
|
||||
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.DeviceForm;
|
||||
import com.fuyuanshen.modules.system.domain.dto.DeviceQueryCriteria;
|
||||
@ -22,13 +23,28 @@ import java.util.List;
|
||||
**/
|
||||
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 mac
|
||||
* @param criteria
|
||||
*/
|
||||
void appBindDevice(String mac);
|
||||
|
||||
void appBindDevice(DeviceQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 分页查询APP/小程序设备绑定
|
||||
|
@ -14,10 +14,12 @@ import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
||||
import com.fuyuanshen.modules.system.domain.dto.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.modules.system.domain.dto.app.APPUnbindDTO;
|
||||
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.DeviceTypeMapper;
|
||||
import com.fuyuanshen.modules.system.mapper.app.APPDeviceMapper;
|
||||
import com.fuyuanshen.modules.system.mapper.app.AppDeviceTypeMapper;
|
||||
import com.fuyuanshen.utils.PageResult;
|
||||
import com.fuyuanshen.utils.SecurityUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -25,7 +27,11 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
@ -40,39 +46,93 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
||||
private final APPDeviceMapper appDeviceMapper;
|
||||
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) {
|
||||
criteria.setCustomerId(SecurityUtils.getCurrentUserId());
|
||||
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) {
|
||||
criteria.setCustomerId(SecurityUtils.getCurrentUserId());
|
||||
return appDeviceTypeMapper.appTypeList(criteria);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* APP/小程序用户设备绑定
|
||||
*
|
||||
* @param mac
|
||||
* @param criteria
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void appBindDevice(String mac) {
|
||||
List<Device> devices = deviceMapper.selectList(new QueryWrapper<Device>().eq("device_mac", mac));
|
||||
if (CollectionUtil.isEmpty(devices)) {
|
||||
throw new BadRequestException("请先将设备入库!!!");
|
||||
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("该设备已绑定!!!");
|
||||
}
|
||||
}
|
||||
List<APPDevice> appDevices = appDeviceMapper.selectList(new QueryWrapper<APPDevice>()
|
||||
.eq("device_mac", mac).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);
|
||||
device.setBindingStatus(BindingStatusEnum.BOUND.getCode());
|
||||
deviceMapper.updateById( device);
|
||||
|
||||
APPDevice appDevice = new APPDevice();
|
||||
BeanUtil.copyProperties(appDevice, device);
|
||||
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);
|
||||
|
||||
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
||||
APPDeviceType appDeviceType = new APPDeviceType();
|
||||
BeanUtil.copyProperties(appDeviceType, deviceType);
|
||||
deviceTypeMapper.insert(appDeviceType);
|
||||
APPDeviceType appDeviceType = appDeviceTypeMapper.selectById(device.getDeviceType());
|
||||
if (appDeviceType == null) {
|
||||
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
||||
APPDeviceType type = new APPDeviceType();
|
||||
BeanUtil.copyProperties(deviceType, type);
|
||||
type.setCustomerId(currentUserId);
|
||||
appDeviceTypeMapper.insert(type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -100,7 +160,12 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
||||
@Transactional
|
||||
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.setId(deviceForm.getCustomerId());
|
||||
device.setBindingStatus(BindingStatusEnum.UNBOUND.getCode());
|
||||
|
@ -21,6 +21,8 @@ import com.fuyuanshen.modules.security.service.dto.app.AppRoleDto;
|
||||
import com.fuyuanshen.modules.system.domain.Role;
|
||||
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
||||
import com.fuyuanshen.modules.system.domain.dto.UserQueryCriteria;
|
||||
import com.fuyuanshen.modules.system.domain.dto.app.APPForgotPasswordDTO;
|
||||
import com.fuyuanshen.modules.system.domain.dto.app.APPUpdateUserDTO;
|
||||
import com.fuyuanshen.modules.system.domain.dto.app.APPUserDTO;
|
||||
import com.fuyuanshen.modules.utils.ResponseVO;
|
||||
import com.fuyuanshen.utils.PageResult;
|
||||
@ -54,4 +56,10 @@ public interface APPUserService extends IService<APPUser> {
|
||||
ResponseVO<Object> addUser(APPUserDTO user);
|
||||
|
||||
Integer selectRoleByUserLevel(Set<Role> roles);
|
||||
|
||||
void forgotPassword(APPForgotPasswordDTO appForgotPasswordDTO);
|
||||
|
||||
void sendSms(String phoneNumber);
|
||||
|
||||
void updateUser(APPUpdateUserDTO appUser);
|
||||
}
|
||||
|
@ -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.modules.security.service.UserCacheManager;
|
||||
import com.fuyuanshen.modules.system.constant.UserConstants;
|
||||
import com.fuyuanshen.modules.system.domain.Device;
|
||||
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.*;
|
||||
import com.fuyuanshen.modules.system.domain.app.APPDevice;
|
||||
import com.fuyuanshen.modules.system.domain.dto.CustomerVo;
|
||||
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.setCurrentOwnerId(currentUser.getId());
|
||||
device.setOriginalOwnerId(currentUser.getId());
|
||||
DeviceType deviceType = deviceTypeMapper.selectById(deviceForm.getDeviceType());
|
||||
device.setTypeName(deviceType.getTypeName());
|
||||
|
||||
deviceMapper.insert(device);
|
||||
|
||||
@ -457,6 +456,30 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 撤回设备
|
||||
*
|
||||
* @param deviceForm
|
||||
*/
|
||||
@Override
|
||||
public void withdrawDevice(DeviceForm deviceForm) {
|
||||
DeviceAssignments assignment = deviceAssignmentsMapper.selectById(deviceForm.getAssignId());
|
||||
// 接收者
|
||||
assignment.setAssigneeName("");
|
||||
deviceAssignmentsMapper.updateById(assignment);
|
||||
|
||||
LambdaQueryWrapper<DeviceAssignments> q1 = new LambdaQueryWrapper<>();
|
||||
q1.eq(DeviceAssignments::getAssignerId, assignment.getAssigneeId())
|
||||
.like(DeviceAssignments::getLever, assignment.getLever())
|
||||
.ne(DeviceAssignments::getId, assignment.getId());
|
||||
|
||||
DeviceAssignments d1 = new DeviceAssignments();
|
||||
d1.setActive(DeviceActiveStatusEnum.INACTIVE.getCode());
|
||||
deviceAssignmentsMapper.update(d1, q1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建并保存设备类型授权记录
|
||||
*
|
||||
@ -552,6 +575,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
* @param ids
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAssign(List<Long> ids) {
|
||||
// Step 1: 查询所有传入的设备(根据 ID)
|
||||
List<DeviceAssignments> deviceAssignments = deviceAssignmentsMapper.selectBatchIds(ids);
|
||||
@ -563,7 +587,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
throw new BadRequestException("已分配的设备不允许删除!!!");
|
||||
}
|
||||
|
||||
deviceAssignmentsMapper.deleteBatchIds(ids);
|
||||
deviceAssignmentsMapper.deleteBatchIds(nonNullCustomerIds);
|
||||
deviceTypeGrantsMapper.delete(new QueryWrapper<DeviceTypeGrants>().in("assignment_id", nonNullCustomerIds));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,9 +1,13 @@
|
||||
package com.fuyuanshen.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.modules.system.domain.Device;
|
||||
import com.fuyuanshen.modules.system.domain.DeviceTypeGrants;
|
||||
import com.fuyuanshen.modules.system.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.modules.system.mapper.DeviceTypeGrantsMapper;
|
||||
import com.fuyuanshen.modules.utils.NanoId;
|
||||
import com.fuyuanshen.utils.enums.NanoIdLengthEnum;
|
||||
@ -41,6 +45,7 @@ import java.util.stream.Collectors;
|
||||
public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceType> implements DeviceTypeService {
|
||||
|
||||
private final DeviceTypeMapper deviceTypeMapper;
|
||||
private final DeviceMapper deviceMapper;
|
||||
private final UserMapper userMapper;
|
||||
private final UserCacheManager userCacheManager;
|
||||
private final DeviceTypeGrantsMapper deviceTypeGrantsMapper;
|
||||
@ -142,9 +147,20 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改设备类型
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(DeviceType resources) {
|
||||
|
||||
List<Device> deviceList = deviceMapper.selectList(new QueryWrapper<Device>().eq("device_type", resources.getId()));
|
||||
if (CollectionUtil.isNotEmpty(deviceList)) {
|
||||
throw new BadRequestException("该设备类型下已有设备,请先解绑设备!!!");
|
||||
}
|
||||
|
||||
DeviceType deviceType = getById(resources.getId());
|
||||
deviceType.copy(resources);
|
||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||
@ -153,10 +169,32 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除设备类型
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(List<Long> ids) {
|
||||
deviceTypeMapper.deleteBatchIds(ids);
|
||||
// 查询所有与 device 关联的 deviceType IDs
|
||||
List<Device> deviceList = deviceMapper.selectList(new QueryWrapper<Device>().in("device_type", ids));
|
||||
// 提取与 device 关联的 deviceType IDs
|
||||
List<Long> filteredIds = deviceList.stream()
|
||||
.map(Device::getDeviceType)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
// 从原始 ids 中移除已关联 device 的 id(即过滤掉能查到结果的 id)
|
||||
List<Long> idsToBeDeleted = ids.stream()
|
||||
.filter(id -> !filteredIds.contains(id))
|
||||
.collect(Collectors.toList());
|
||||
if (idsToBeDeleted.isEmpty()) {
|
||||
throw new BadRequestException("选中设备类型已绑定设备,请先解绑设备!!!");
|
||||
}
|
||||
// 删除过滤后的 id 列表
|
||||
deviceTypeMapper.deleteBatchIds(idsToBeDeleted);
|
||||
deviceTypeGrantsMapper.delete(new QueryWrapper<DeviceTypeGrants>().in("device_type_id", idsToBeDeleted));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,7 +19,10 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuyuanshen.modules.system.domain.app.APPMenu;
|
||||
import com.fuyuanshen.modules.system.domain.app.APPRole;
|
||||
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
||||
import com.fuyuanshen.modules.system.mapper.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.modules.security.service.UserCacheManager;
|
||||
@ -28,10 +31,6 @@ import com.fuyuanshen.modules.system.domain.Menu;
|
||||
import com.fuyuanshen.modules.system.domain.Role;
|
||||
import com.fuyuanshen.exception.EntityExistException;
|
||||
import com.fuyuanshen.modules.system.domain.User;
|
||||
import com.fuyuanshen.modules.system.mapper.RoleDeptMapper;
|
||||
import com.fuyuanshen.modules.system.mapper.RoleMapper;
|
||||
import com.fuyuanshen.modules.system.mapper.RoleMenuMapper;
|
||||
import com.fuyuanshen.modules.system.mapper.UserMapper;
|
||||
import com.fuyuanshen.modules.system.service.RoleService;
|
||||
import com.fuyuanshen.modules.system.domain.dto.RoleQueryCriteria;
|
||||
import com.fuyuanshen.utils.*;
|
||||
@ -53,6 +52,7 @@ import java.util.stream.Collectors;
|
||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
|
||||
|
||||
private final RoleMapper roleMapper;
|
||||
private final APPRoleMapper appRoleMapper;
|
||||
private final RoleDeptMapper roleDeptMapper;
|
||||
private final RoleMenuMapper roleMenuMapper;
|
||||
private final RedisUtils redisUtils;
|
||||
@ -206,8 +206,8 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
permissions.add("admin");
|
||||
return permissions.stream().map(AuthorityDto::new).collect(Collectors.toList());
|
||||
}
|
||||
List<Role> roles = roleMapper.findByUserId(user.getId());
|
||||
permissions = roles.stream().flatMap(role -> role.getMenus().stream()).map(Menu::getPermission).filter(StringUtils::isNotBlank).collect(Collectors.toSet());
|
||||
List<APPRole> roles = appRoleMapper.findByUserId(user.getId());
|
||||
permissions = roles.stream().flatMap(role -> role.getMenus().stream()).map(APPMenu::getPermission).filter(StringUtils::isNotBlank).collect(Collectors.toSet());
|
||||
authorityDtos = permissions.stream().map(AuthorityDto::new).collect(Collectors.toList());
|
||||
redisUtils.set(key, authorityDtos, 1, TimeUnit.HOURS);
|
||||
}
|
||||
|
@ -15,24 +15,35 @@
|
||||
*/
|
||||
package com.fuyuanshen.modules.system.service.impl.app;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.crypto.digest.MD5;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.fuyuanshen.constants.DeviceConstants;
|
||||
import com.fuyuanshen.exception.BadRequestException;
|
||||
import com.fuyuanshen.modules.system.domain.Role;
|
||||
import com.fuyuanshen.modules.system.domain.app.APPUser;
|
||||
import com.fuyuanshen.modules.system.domain.dto.UserQueryCriteria;
|
||||
import com.fuyuanshen.modules.system.domain.dto.app.APPForgotPasswordDTO;
|
||||
import com.fuyuanshen.modules.system.domain.dto.app.APPUpdateUserDTO;
|
||||
import com.fuyuanshen.modules.system.domain.dto.app.APPUserDTO;
|
||||
import com.fuyuanshen.modules.system.mapper.app.APPUserMapper;
|
||||
import com.fuyuanshen.modules.system.service.app.APPUserService;
|
||||
import com.fuyuanshen.modules.utils.ResponseVO;
|
||||
import com.fuyuanshen.utils.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.fuyuanshen.constants.RedisConstants.*;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2018-11-23
|
||||
@ -45,6 +56,19 @@ public class APPUserServiceImpl extends ServiceImpl<APPUserMapper, APPUser> impl
|
||||
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
@Autowired
|
||||
private final RedisUtils redisUtils;
|
||||
|
||||
@Value("${file.app_avatar.pic}")
|
||||
private String filePath;
|
||||
@Value("${file.app_avatar.ip}")
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 文件访问路径前缀
|
||||
*/
|
||||
public static final String FILE_ACCESS_PREFIX = "images";
|
||||
public static final String FILE_AVATAR_PREFIX = "avatar";
|
||||
/**
|
||||
* 查询APP/小程序用户
|
||||
*
|
||||
@ -73,6 +97,14 @@ public class APPUserServiceImpl extends ServiceImpl<APPUserMapper, APPUser> impl
|
||||
if (appUserMapper.getByUsername(username) != null) {
|
||||
throw new BadRequestException("该手机号已被注册");
|
||||
}
|
||||
|
||||
/* Object verificationCode = redisUtils.get(APP_REGISTER_SMS_TOKEN + username);
|
||||
if (verificationCode == null) {
|
||||
throw new BadRequestException("验证码已过期");
|
||||
}
|
||||
if(!user.getVerificationCode().equals(verificationCode.toString())){
|
||||
throw new BadRequestException("验证码错误");
|
||||
}*/
|
||||
APPUser appUser = new APPUser();
|
||||
appUser.setUsername(user.getPhoneNumber());
|
||||
|
||||
@ -96,4 +128,67 @@ public class APPUserServiceImpl extends ServiceImpl<APPUserMapper, APPUser> impl
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forgotPassword(APPForgotPasswordDTO appForgotPasswordDTO) {
|
||||
String phoneNumber = appForgotPasswordDTO.getPhoneNumber();
|
||||
APPUser appUser = appUserMapper.appFindByUsername(phoneNumber);
|
||||
if (appUser == null) {
|
||||
throw new BadRequestException("手机号不存在");
|
||||
}
|
||||
/*Object verificationCode = redisUtils.get(APP_FORGOT_PASSWORD_SMS_TOKEN + phoneNumber);
|
||||
if (verificationCode == null) {
|
||||
throw new BadRequestException("验证码已过期");
|
||||
}
|
||||
if(!appForgotPasswordDTO.getVerificationCode().equals(verificationCode.toString())){
|
||||
throw new BadRequestException("验证码错误");
|
||||
}*/
|
||||
appUser.setPassword(appForgotPasswordDTO.getPassword());
|
||||
appUserMapper.updateById(appUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSms(String phoneNumber) {
|
||||
if (appUserMapper.appFindByUsername(phoneNumber) == null) {
|
||||
throw new BadRequestException("手机号不存在");
|
||||
}
|
||||
// todo 发送验证码
|
||||
|
||||
redisUtils.set(APP_FORGOT_PASSWORD_SMS_TOKEN + phoneNumber, RandomUtil.randomNumbers(4), 5 * 60);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUser(APPUpdateUserDTO appUser) {
|
||||
APPUser updUser= new APPUser();
|
||||
updUser.setId(appUser.getId());
|
||||
updUser.setNickName(appUser.getNickName());
|
||||
try {
|
||||
updUser.setAvatarPath(saveUserAvatarImage(appUser.getFile()));
|
||||
}catch (IOException e){
|
||||
throw new BadRequestException("上传头像失败");
|
||||
}
|
||||
updUser.setRegion(appUser.getRegion());
|
||||
updUser.setGender(appUser.getGender());
|
||||
appUserMapper.updateById(updUser);
|
||||
}
|
||||
|
||||
private String saveUserAvatarImage(MultipartFile file) throws IOException {
|
||||
if (file == null || file.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String originalFileName = file.getOriginalFilename();
|
||||
String fileExtension = originalFileName.substring(originalFileName.lastIndexOf(".") + 1);
|
||||
String newFileName = "PS_" + RandomUtil.randomNumbers(8) + "." + fileExtension;
|
||||
|
||||
File newFile = new File(filePath + FILE_AVATAR_PREFIX + File.separator + newFileName);
|
||||
|
||||
if (!newFile.getParentFile().exists()) {
|
||||
newFile.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
file.transferTo(newFile);
|
||||
|
||||
return ip + DeviceConstants.FILE_ACCESS_PREFIX + "/" + FILE_AVATAR_PREFIX + "/" + newFileName;
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
||||
}
|
@ -141,6 +141,10 @@ file:
|
||||
device:
|
||||
pic: C:\eladmin\file\ #设备图片存储路径
|
||||
ip: http://fuyuanshen.com:81/ #服务器地址
|
||||
app_avatar:
|
||||
pic: C:\eladmin\file\ #设备图片存储路径
|
||||
#ip: http://fuyuanshen.com:81/ #服务器地址
|
||||
ip: https://fuyuanshen.com/ #服务器地址
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
@ -151,3 +151,7 @@ file:
|
||||
pic: /home/eladmin/file/ #设备图片存储路径
|
||||
#ip: http://fuyuanshen.com:81/ #服务器地址
|
||||
ip: https://fuyuanshen.com/ #服务器地址
|
||||
app_avatar:
|
||||
pic: /home/eladmin/app_avatar/ #设备图片存储路径
|
||||
#ip: http://fuyuanshen.com:81/ #服务器地址
|
||||
ip: https://fuyuanshen.com/ #服务器地址
|
||||
|
@ -43,6 +43,8 @@ spring:
|
||||
multipart:
|
||||
max-file-size: 5MB # 设置单个上传文件的最大大小为10MB
|
||||
max-request-size: 5MB
|
||||
jackson:
|
||||
default-property-inclusion: always
|
||||
# pid:
|
||||
# file: /自行指定位置/eladmin.pid
|
||||
|
||||
|
@ -19,17 +19,20 @@
|
||||
<result column="binding_status" property="bindingStatus"/>
|
||||
</resultMap>
|
||||
|
||||
<!-- 分页查询APP/小程序设备 -->
|
||||
<select id="queryAll" resultType="com.fuyuanshen.modules.system.domain.app.APPDevice">
|
||||
<!-- APP用户设备列表 -->
|
||||
<select id="appDeviceList" 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.deviceName.trim() != ''">
|
||||
<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>
|
||||
@ -42,13 +45,47 @@
|
||||
<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.app_device_id desc
|
||||
order by d.create_time desc
|
||||
</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>
|
@ -0,0 +1,61 @@
|
||||
<?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.APPRoleMapper">
|
||||
<resultMap id="BaseResultMap" type="com.fuyuanshen.modules.system.domain.app.APPRole">
|
||||
<id column="role_role_id" property="id"/>
|
||||
<result column="role_name" property="name"/>
|
||||
<result column="role_data_scope" property="dataScope"/>
|
||||
<result column="role_level" property="level"/>
|
||||
<result column="role_description" property="description"/>
|
||||
<result column="role_create_by" property="createBy"/>
|
||||
<result column="role_update_by" property="updateBy"/>
|
||||
<result column="role_create_time" property="createTime"/>
|
||||
<result column="role_update_time" property="updateTime"/>
|
||||
<collection property="menus" ofType="com.fuyuanshen.modules.system.domain.app.APPMenu">
|
||||
<id column="menu_id" property="id"/>
|
||||
<result column="menu_title" property="title"/>
|
||||
<result column="menu_permission" property="permission"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
role.role_id as role_role_id, role.name as role_name, role.data_scope as role_data_scope,
|
||||
role.level as role_level, role.description as role_description, role.create_by as role_create_by,
|
||||
role.update_by as role_update_by, role.create_time as role_create_time, role.update_time as role_update_time
|
||||
</sql>
|
||||
|
||||
<sql id="Menu_Column_List">
|
||||
menu.menu_id as menu_id, menu.title as menu_title, menu.permission as menu_permission
|
||||
</sql>
|
||||
|
||||
<sql id="Dept_Column_List">
|
||||
dept.dept_id as dept_id, dept.name as dept_name
|
||||
</sql>
|
||||
|
||||
<sql id="Where_sql">
|
||||
<where>
|
||||
<if test="criteria.blurry != null and criteria.blurry != ''">
|
||||
and (
|
||||
role.name like concat('%', #{criteria.blurry}, '%')
|
||||
or role.description like concat('%', #{criteria.blurry}, '%')
|
||||
)
|
||||
</if>
|
||||
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||
and role.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
|
||||
<select id="findByUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>,
|
||||
<include refid="Menu_Column_List"/>
|
||||
from app_role role
|
||||
left join app_roles_menus srm on role.role_id = srm.role_id
|
||||
left join app_menu menu on menu.menu_id = srm.menu_id
|
||||
left join app_users_roles ur on role.role_id = ur.role_id
|
||||
WHERE role.role_id = ur.role_id AND ur.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,35 @@
|
||||
<?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>
|
||||
and d.customer_id = #{criteria.customerId}
|
||||
</where>
|
||||
order by d.create_time desc
|
||||
</select>
|
||||
</mapper>
|
@ -61,6 +61,6 @@
|
||||
and dt.create_by = #{criteria.createBy}
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
</mapper>
|
Reference in New Issue
Block a user