Compare commits
12 Commits
ec03919c78
...
main
Author | SHA1 | Date | |
---|---|---|---|
bd802ab8fd | |||
e1a6642af4 | |||
b05b01b007 | |||
cb57a595aa | |||
953ffdfb28 | |||
968f1cbb16 | |||
6b9a09c9e8 | |||
6e41426faa | |||
64729a223d | |||
134c17a2bd | |||
5c2aba3d32 | |||
6a6adc5ec1 |
@ -38,4 +38,5 @@ public interface GenConfigService extends IService<GenConfig> {
|
|||||||
* @return 表配置
|
* @return 表配置
|
||||||
*/
|
*/
|
||||||
GenConfig update(String tableName, GenConfig genConfig);
|
GenConfig update(String tableName, GenConfig genConfig);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
public class LoginProperties {
|
public class LoginProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 账号单用户 登录
|
* 账号单用户
|
||||||
*/
|
*/
|
||||||
private boolean singleLogin = false;
|
private boolean singleLogin = false;
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
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.fasterxml.jackson.annotation.JsonInclude;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import com.fuyuanshen.base.BaseEntity;
|
import com.fuyuanshen.base.BaseEntity;
|
||||||
@ -20,6 +21,7 @@ import java.io.Serializable;
|
|||||||
**/
|
**/
|
||||||
@Data
|
@Data
|
||||||
@TableName("device")
|
@TableName("device")
|
||||||
|
@JsonInclude(JsonInclude.Include.ALWAYS) // 关键注解
|
||||||
public class Device extends BaseEntity implements Serializable {
|
public class Device extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
@TableId(value = "id", type = IdType.AUTO)
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
@ -16,14 +16,19 @@
|
|||||||
package com.fuyuanshen.modules.system.domain.app;
|
package com.fuyuanshen.modules.system.domain.app;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
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.Role;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
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 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
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@TableName("app_sys_role")
|
@TableName("sys_role")
|
||||||
public class APPRole extends Role {
|
public class APPRole extends BaseEntity implements Serializable {
|
||||||
|
|
||||||
@NotNull(groups = {Update.class})
|
@NotNull(groups = {Update.class})
|
||||||
@TableId(value="app_role_id", type = IdType.AUTO)
|
@TableId(value="role_id", type = IdType.AUTO)
|
||||||
@ApiModelProperty(value = "ID", hidden = true)
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
private Long id;
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,9 @@ public class DeviceForm {
|
|||||||
@ApiModelProperty(value = "ID", hidden = true)
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "设备记录ID")
|
||||||
|
private Long assignId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "设备类型")
|
@ApiModelProperty(value = "设备类型")
|
||||||
private Long deviceType;
|
private Long deviceType;
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.fuyuanshen.modules.system.domain.vo;
|
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 io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@ -8,18 +10,31 @@ import lombok.Data;
|
|||||||
* @date: 2025-06-1211:34
|
* @date: 2025-06-1211:34
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
@JsonInclude(JsonInclude.Include.ALWAYS)
|
||||||
public class APPUserVo {
|
public class APPUserVo {
|
||||||
|
|
||||||
@ApiModelProperty(value = "ID")
|
@ApiModelProperty(value = "ID")
|
||||||
|
@JsonProperty("id")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户昵称")
|
@ApiModelProperty(value = "用户昵称")
|
||||||
|
@JsonProperty("nickName")
|
||||||
private String nickName;
|
private String nickName;
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户性别")
|
@ApiModelProperty(value = "用户性别")
|
||||||
|
@JsonProperty("gender")
|
||||||
private String gender;
|
private String gender;
|
||||||
|
|
||||||
@ApiModelProperty(value = "电话号码")
|
@ApiModelProperty(value = "电话号码")
|
||||||
|
@JsonProperty("phone")
|
||||||
private Long phone;
|
private Long phone;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "头像存储的路径")
|
||||||
|
@JsonProperty("avatarPath")
|
||||||
|
private String avatarPath;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "地区")
|
||||||
|
@JsonProperty("region")
|
||||||
|
private String region;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.DeviceQueryCriteria;
|
import com.fuyuanshen.modules.system.domain.dto.DeviceQueryCriteria;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -23,6 +24,6 @@ public interface AppDeviceTypeMapper extends BaseMapper<APPDeviceType> {
|
|||||||
* @param criteria 查询条件
|
* @param criteria 查询条件
|
||||||
* @return 设备类型列表
|
* @return 设备类型列表
|
||||||
*/
|
*/
|
||||||
List<APPDeviceType> appTypeList(DeviceQueryCriteria criteria);
|
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("设备详情")
|
@ApiOperation("设备详情")
|
||||||
@GetMapping(value = "/detail/{id}")
|
@GetMapping(value = "/detail/{id}")
|
||||||
public ResponseVO<Object> getDevice(@PathVariable Long id) {
|
public ResponseVO<Object> getDevice(@PathVariable Long id) {
|
||||||
|
@ -1,56 +1,20 @@
|
|||||||
package com.fuyuanshen.modules.system.rest.app;
|
package com.fuyuanshen.modules.system.rest.app;
|
||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
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.app.APPDevice;
|
||||||
import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
import com.fuyuanshen.modules.system.domain.app.APPDeviceType;
|
||||||
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.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.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.app.APPDeviceService;
|
||||||
import com.fuyuanshen.modules.system.service.impl.DeviceExportService;
|
|
||||||
import com.fuyuanshen.modules.utils.ResponseVO;
|
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.PageResult;
|
||||||
import com.fuyuanshen.utils.SecurityUtils;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.annotations.ApiParam;
|
|
||||||
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.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.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,4 +134,5 @@ public class APPUserController {
|
|||||||
// appUserService.sendSms(phoneNumber);
|
// appUserService.sendSms(phoneNumber);
|
||||||
return ResponseVO.success("success!!!");
|
return ResponseVO.success("success!!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,8 @@ public interface DeviceService extends IService<Device> {
|
|||||||
*/
|
*/
|
||||||
void assignCustomer(CustomerVo customerVo);
|
void assignCustomer(CustomerVo customerVo);
|
||||||
|
|
||||||
|
void withdrawDevice(DeviceForm deviceForm);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选删除
|
* 多选删除
|
||||||
*
|
*
|
||||||
@ -110,5 +112,4 @@ public interface DeviceService extends IService<Device> {
|
|||||||
*/
|
*/
|
||||||
void unbindDevice(DeviceForm deviceForm);
|
void unbindDevice(DeviceForm deviceForm);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -56,10 +56,12 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PageResult<APPDevice> appDeviceList(Page<APPDevice> page, DeviceQueryCriteria criteria) {
|
public PageResult<APPDevice> appDeviceList(Page<APPDevice> page, DeviceQueryCriteria criteria) {
|
||||||
|
criteria.setCustomerId(SecurityUtils.getCurrentUserId());
|
||||||
IPage<APPDevice> devices = appDeviceMapper.appDeviceList(page, criteria);
|
IPage<APPDevice> devices = appDeviceMapper.appDeviceList(page, criteria);
|
||||||
return new PageResult<>(devices.getRecords(), devices.getTotal());
|
return new PageResult<>(devices.getRecords(), devices.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* APP用户设备类型列表
|
* APP用户设备类型列表
|
||||||
*
|
*
|
||||||
@ -68,6 +70,7 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<APPDeviceType> appTypeList(DeviceQueryCriteria criteria) {
|
public List<APPDeviceType> appTypeList(DeviceQueryCriteria criteria) {
|
||||||
|
criteria.setCustomerId(SecurityUtils.getCurrentUserId());
|
||||||
return appDeviceTypeMapper.appTypeList(criteria);
|
return appDeviceTypeMapper.appTypeList(criteria);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,6 +111,9 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
|||||||
}
|
}
|
||||||
|
|
||||||
Device device = devices.get(0);
|
Device device = devices.get(0);
|
||||||
|
device.setBindingStatus(BindingStatusEnum.BOUND.getCode());
|
||||||
|
deviceMapper.updateById( device);
|
||||||
|
|
||||||
APPDevice appDevice = new APPDevice();
|
APPDevice appDevice = new APPDevice();
|
||||||
BeanUtil.copyProperties(device, appDevice);
|
BeanUtil.copyProperties(device, appDevice);
|
||||||
appDevice.setBindingType(UserType.APP.getValue());
|
appDevice.setBindingType(UserType.APP.getValue());
|
||||||
@ -124,6 +130,7 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
|||||||
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
DeviceType deviceType = deviceTypeMapper.selectById(device.getDeviceType());
|
||||||
APPDeviceType type = new APPDeviceType();
|
APPDeviceType type = new APPDeviceType();
|
||||||
BeanUtil.copyProperties(deviceType, type);
|
BeanUtil.copyProperties(deviceType, type);
|
||||||
|
type.setCustomerId(currentUserId);
|
||||||
appDeviceTypeMapper.insert(type);
|
appDeviceTypeMapper.insert(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建并保存设备类型授权记录
|
* 创建并保存设备类型授权记录
|
||||||
*
|
*
|
||||||
@ -551,6 +575,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
* @param ids
|
* @param ids
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteAssign(List<Long> ids) {
|
public void deleteAssign(List<Long> ids) {
|
||||||
// Step 1: 查询所有传入的设备(根据 ID)
|
// Step 1: 查询所有传入的设备(根据 ID)
|
||||||
List<DeviceAssignments> deviceAssignments = deviceAssignmentsMapper.selectBatchIds(ids);
|
List<DeviceAssignments> deviceAssignments = deviceAssignmentsMapper.selectBatchIds(ids);
|
||||||
@ -562,7 +587,8 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
|||||||
throw new BadRequestException("已分配的设备不允许删除!!!");
|
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;
|
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.core.conditions.query.QueryWrapper;
|
||||||
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.exception.BadRequestException;
|
||||||
|
import com.fuyuanshen.modules.system.domain.Device;
|
||||||
import com.fuyuanshen.modules.system.domain.DeviceTypeGrants;
|
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.system.mapper.DeviceTypeGrantsMapper;
|
||||||
import com.fuyuanshen.modules.utils.NanoId;
|
import com.fuyuanshen.modules.utils.NanoId;
|
||||||
import com.fuyuanshen.utils.enums.NanoIdLengthEnum;
|
import com.fuyuanshen.utils.enums.NanoIdLengthEnum;
|
||||||
@ -41,6 +45,7 @@ import java.util.stream.Collectors;
|
|||||||
public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceType> implements DeviceTypeService {
|
public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceType> implements DeviceTypeService {
|
||||||
|
|
||||||
private final DeviceTypeMapper deviceTypeMapper;
|
private final DeviceTypeMapper deviceTypeMapper;
|
||||||
|
private final DeviceMapper deviceMapper;
|
||||||
private final UserMapper userMapper;
|
private final UserMapper userMapper;
|
||||||
private final UserCacheManager userCacheManager;
|
private final UserCacheManager userCacheManager;
|
||||||
private final DeviceTypeGrantsMapper deviceTypeGrantsMapper;
|
private final DeviceTypeGrantsMapper deviceTypeGrantsMapper;
|
||||||
@ -142,9 +147,20 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改设备类型
|
||||||
|
*
|
||||||
|
* @param resources /
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(DeviceType resources) {
|
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 deviceType = getById(resources.getId());
|
||||||
deviceType.copy(resources);
|
deviceType.copy(resources);
|
||||||
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
|
||||||
@ -153,10 +169,32 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除设备类型
|
||||||
|
*
|
||||||
|
* @param ids /
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void deleteAll(List<Long> ids) {
|
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 cn.hutool.core.collection.CollectionUtil;
|
||||||
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.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.domain.app.APPUser;
|
||||||
|
import com.fuyuanshen.modules.system.mapper.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import com.fuyuanshen.exception.BadRequestException;
|
import com.fuyuanshen.exception.BadRequestException;
|
||||||
import com.fuyuanshen.modules.security.service.UserCacheManager;
|
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.modules.system.domain.Role;
|
||||||
import com.fuyuanshen.exception.EntityExistException;
|
import com.fuyuanshen.exception.EntityExistException;
|
||||||
import com.fuyuanshen.modules.system.domain.User;
|
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.service.RoleService;
|
||||||
import com.fuyuanshen.modules.system.domain.dto.RoleQueryCriteria;
|
import com.fuyuanshen.modules.system.domain.dto.RoleQueryCriteria;
|
||||||
import com.fuyuanshen.utils.*;
|
import com.fuyuanshen.utils.*;
|
||||||
@ -53,6 +52,7 @@ import java.util.stream.Collectors;
|
|||||||
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
|
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements RoleService {
|
||||||
|
|
||||||
private final RoleMapper roleMapper;
|
private final RoleMapper roleMapper;
|
||||||
|
private final APPRoleMapper appRoleMapper;
|
||||||
private final RoleDeptMapper roleDeptMapper;
|
private final RoleDeptMapper roleDeptMapper;
|
||||||
private final RoleMenuMapper roleMenuMapper;
|
private final RoleMenuMapper roleMenuMapper;
|
||||||
private final RedisUtils redisUtils;
|
private final RedisUtils redisUtils;
|
||||||
@ -206,8 +206,8 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
|||||||
permissions.add("admin");
|
permissions.add("admin");
|
||||||
return permissions.stream().map(AuthorityDto::new).collect(Collectors.toList());
|
return permissions.stream().map(AuthorityDto::new).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
List<Role> roles = roleMapper.findByUserId(user.getId());
|
List<APPRole> roles = appRoleMapper.findByUserId(user.getId());
|
||||||
permissions = roles.stream().flatMap(role -> role.getMenus().stream()).map(Menu::getPermission).filter(StringUtils::isNotBlank).collect(Collectors.toSet());
|
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());
|
authorityDtos = permissions.stream().map(AuthorityDto::new).collect(Collectors.toList());
|
||||||
redisUtils.set(key, authorityDtos, 1, TimeUnit.HOURS);
|
redisUtils.set(key, authorityDtos, 1, TimeUnit.HOURS);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ spring:
|
|||||||
max-file-size: 5MB # 设置单个上传文件的最大大小为10MB
|
max-file-size: 5MB # 设置单个上传文件的最大大小为10MB
|
||||||
max-request-size: 5MB
|
max-request-size: 5MB
|
||||||
jackson:
|
jackson:
|
||||||
default-property-inclusion: non_null
|
default-property-inclusion: always
|
||||||
# pid:
|
# pid:
|
||||||
# file: /自行指定位置/eladmin.pid
|
# file: /自行指定位置/eladmin.pid
|
||||||
|
|
||||||
|
@ -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>
|
@ -19,7 +19,8 @@
|
|||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
id,type_name,is_support_ble,locate_mode,network_way,create_by,
|
id
|
||||||
|
,type_name,is_support_ble,locate_mode,network_way,create_by,
|
||||||
update_by,create_time,update_time,customer_id,communication_mode
|
update_by,create_time,update_time,customer_id,communication_mode
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
@ -27,31 +28,6 @@
|
|||||||
<select id="appTypeList" resultType="com.fuyuanshen.modules.system.domain.app.APPDeviceType">
|
<select id="appTypeList" resultType="com.fuyuanshen.modules.system.domain.app.APPDeviceType">
|
||||||
select d.* from app_device_type as d
|
select d.* from app_device_type as d
|
||||||
<where>
|
<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}
|
and d.customer_id = #{criteria.customerId}
|
||||||
</where>
|
</where>
|
||||||
order by d.create_time desc
|
order by d.create_time desc
|
||||||
|
@ -61,6 +61,6 @@
|
|||||||
and dt.create_by = #{criteria.createBy}
|
and dt.create_by = #{criteria.createBy}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by create_time desc
|
ORDER BY create_time DESC
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
Reference in New Issue
Block a user