Merge branch 'dev-V0.4.5' of https://gitee.com/iotkit-open-source/iotkit-parent into dev-V0.4.5
commit
7e48dfd5a3
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.common.api;
|
||||
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
@ -38,4 +39,7 @@ public class BaseDto {
|
|||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public <T> T to(Class<T> tClass) {
|
||||
return MapstructUtils.convert(this, tClass);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package cc.iotkit.common.api;
|
||||
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.SnowflakeIdGeneratorUtil;
|
||||
import jakarta.validation.constraints.Max;
|
||||
import jakarta.validation.constraints.Min;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
@ -18,6 +19,9 @@ import java.io.Serializable;
|
|||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class PageRequest<T> extends Request<T> implements Serializable {
|
||||
|
||||
/**
|
||||
|
@ -71,13 +75,14 @@ public class PageRequest<T> extends Request<T> implements Serializable {
|
|||
return pageRequest;
|
||||
}
|
||||
|
||||
public static <DTO> PageRequest<DTO> copyPageRequest(PageRequest query,DTO data) {
|
||||
public <DTO> PageRequest<DTO> to(Class<DTO> dtoClass) {
|
||||
DTO dto = MapstructUtils.convert(getData(), dtoClass);
|
||||
PageRequest<DTO> pageRequest = new PageRequest<>();
|
||||
pageRequest.setData(data);
|
||||
pageRequest.setPageNum(query.getPageNum());
|
||||
pageRequest.setPageSize(query.getPageSize());
|
||||
pageRequest.setRequestId(query.getRequestId());
|
||||
pageRequest.setSortMap(query.getSortMap());
|
||||
pageRequest.setData(dto);
|
||||
pageRequest.setPageNum(this.getPageNum());
|
||||
pageRequest.setPageSize(this.getPageSize());
|
||||
pageRequest.setRequestId(this.getRequestId());
|
||||
pageRequest.setSortMap(this.getSortMap());
|
||||
return pageRequest;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
package cc.iotkit.common.api;
|
||||
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
@ -24,4 +25,7 @@ public class Paging<T> {
|
|||
|
||||
private List<T> data;
|
||||
|
||||
public <VO> Paging<VO> to(Class<VO> voClass) {
|
||||
return MapstructUtils.convert(this, voClass);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.model;
|
||||
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -40,4 +41,7 @@ public class BaseModel implements Serializable {
|
|||
*/
|
||||
private Date updateTime;
|
||||
|
||||
public <T> T to(Class<T> tClass) {
|
||||
return MapstructUtils.convert(this, tClass);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package cc.iotkit.model.system;
|
||||
|
||||
import cc.iotkit.model.BaseModel;
|
||||
import cc.iotkit.model.Id;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
@ -13,8 +15,9 @@ import java.util.Date;
|
|||
* @author Michelle.Chung
|
||||
* @date 2023-02-07
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class SysOperLog implements Id<Long>,Serializable {
|
||||
public class SysOperLog extends BaseModel implements Id<Long>, Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package cc.iotkit.data.system;
|
||||
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.model.system.SysOss;
|
||||
|
||||
/**
|
||||
* 操作日志数据接口
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
public interface ISysOssData {
|
||||
public interface ISysOssData extends ICommonData<SysOss, Long> {
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package cc.iotkit.data.system;
|
||||
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.model.system.SysPost;
|
||||
|
||||
/**
|
||||
* 操作日志数据接口
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
public interface ISysPostData {
|
||||
public interface ISysPostData extends ICommonData<SysPost, Long> {
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package cc.iotkit.data.system;
|
||||
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.model.system.SysTenantPackage;
|
||||
|
||||
/**
|
||||
* 操作日志数据接口
|
||||
*
|
||||
* @author sjg
|
||||
*/
|
||||
public interface ISysTenantPackageData {
|
||||
public interface ISysTenantPackageData extends ICommonData<SysTenantPackage, Long> {
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.data.manager.ICategoryData;
|
||||
import cc.iotkit.data.cache.CategoryCacheEvict;
|
||||
|
@ -10,6 +11,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -27,6 +29,11 @@ public class CategoryDataCache implements ICategoryData {
|
|||
return categoryData.findById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Category> findByIds(Collection<String> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category save(Category data) {
|
||||
data = categoryData.save(data);
|
||||
|
@ -34,13 +41,18 @@ public class CategoryDataCache implements ICategoryData {
|
|||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchSave(List<Category> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String s) {
|
||||
categoryData.deleteById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(String[] strings) {
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -55,7 +67,18 @@ public class CategoryDataCache implements ICategoryData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Paging<Category> findAll(int page, int size) {
|
||||
return categoryData.findAll(page, size);
|
||||
public Paging<Category> findAll(PageRequest<Category> pageRequest) {
|
||||
return categoryData.findAll(pageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Category> findAllByCondition(Category data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Category findOneByCondition(Category data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.common.utils.JsonUtils;
|
||||
import cc.iotkit.data.manager.IDeviceInfoData;
|
||||
|
@ -60,7 +61,11 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi
|
|||
int page = 1;
|
||||
Paging<DeviceInfo> paged;
|
||||
List<String> parentIds = new ArrayList<>();
|
||||
while ((paged = deviceInfoData.findAll(page++, 1000)).getData().size() > 0) {
|
||||
PageRequest<DeviceInfo> pageRequest = new PageRequest<>();
|
||||
pageRequest.setPageSize(1000);
|
||||
|
||||
while ((paged = deviceInfoData.findAll(pageRequest)).getData().size() > 0) {
|
||||
pageRequest.setPageNum(page++);
|
||||
List<DeviceInfo> devices = paged.getData();
|
||||
for (DeviceInfo device : devices) {
|
||||
//装载设备信息缓存
|
||||
|
@ -207,6 +212,11 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi
|
|||
return deviceInfoData.findById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceInfo> findByIds(Collection<String> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceInfo save(DeviceInfo data) {
|
||||
DeviceInfo r = deviceInfoData.save(data);
|
||||
|
@ -218,8 +228,8 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi
|
|||
}
|
||||
|
||||
@Override
|
||||
public DeviceInfo add(DeviceInfo data) {
|
||||
return save(data);
|
||||
public void batchSave(List<DeviceInfo> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -236,8 +246,7 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(String[] strings) {
|
||||
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -251,8 +260,18 @@ public class DeviceInfoDataCache implements IDeviceInfoData, SmartInitializingSi
|
|||
}
|
||||
|
||||
@Override
|
||||
public Paging<DeviceInfo> findAll(int page, int size) {
|
||||
return deviceInfoData.findAll(page, size);
|
||||
public Paging<DeviceInfo> findAll(PageRequest<DeviceInfo> pageRequest) {
|
||||
return deviceInfoData.findAll(pageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceInfo> findAllByCondition(DeviceInfo data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceInfo findOneByCondition(DeviceInfo data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.data.manager.IDeviceInfoData;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
|
@ -17,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -37,14 +39,19 @@ public class DeviceInfoPropertyDataCache implements IDeviceInfoData {
|
|||
return deviceInfoData.findById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceInfo> findByIds(Collection<String> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceInfo save(DeviceInfo data) {
|
||||
return deviceInfoData.save(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceInfo add(DeviceInfo data) {
|
||||
return deviceInfoData.add(data);
|
||||
public void batchSave(List<DeviceInfo> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,7 +60,7 @@ public class DeviceInfoPropertyDataCache implements IDeviceInfoData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(String[] strings) {
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -68,8 +75,18 @@ public class DeviceInfoPropertyDataCache implements IDeviceInfoData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Paging<DeviceInfo> findAll(int page, int size) {
|
||||
return deviceInfoData.findAll(page, size);
|
||||
public Paging<DeviceInfo> findAll(PageRequest<DeviceInfo> pageRequest) {
|
||||
return deviceInfoData.findAll(pageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceInfo> findAllByCondition(DeviceInfo data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceInfo findOneByCondition(DeviceInfo data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.data.manager.IOauthClientData;
|
||||
import cc.iotkit.data.cache.OauthClientCacheEvict;
|
||||
|
@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -41,6 +43,11 @@ public class OauthClientDataCache implements IOauthClientData {
|
|||
return oauthClientData.findById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OauthClient> findByIds(Collection<String> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OauthClient save(OauthClient data) {
|
||||
OauthClient oauthClient = oauthClientData.save(data);
|
||||
|
@ -50,8 +57,8 @@ public class OauthClientDataCache implements IOauthClientData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public OauthClient add(OauthClient data) {
|
||||
return oauthClientData.add(data);
|
||||
public void batchSave(List<OauthClient> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -60,7 +67,7 @@ public class OauthClientDataCache implements IOauthClientData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(String[] strings) {
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -75,7 +82,18 @@ public class OauthClientDataCache implements IOauthClientData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Paging<OauthClient> findAll(int page, int size) {
|
||||
return oauthClientData.findAll(page, size);
|
||||
public Paging<OauthClient> findAll(PageRequest<OauthClient> pageRequest) {
|
||||
return oauthClientData.findAll(pageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<OauthClient> findAllByCondition(OauthClient data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OauthClient findOneByCondition(OauthClient data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.data.manager.IProductData;
|
||||
import cc.iotkit.data.cache.ProductCacheEvict;
|
||||
|
@ -10,6 +11,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -47,6 +49,11 @@ public class ProductDataCache implements IProductData {
|
|||
return productData.findById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Product> findByIds(Collection<String> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Product save(Product data) {
|
||||
Product p = productData.save(data);
|
||||
|
@ -56,8 +63,8 @@ public class ProductDataCache implements IProductData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Product add(Product data) {
|
||||
return productData.add(data);
|
||||
public void batchSave(List<Product> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,7 +75,7 @@ public class ProductDataCache implements IProductData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(String[] strings) {
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -83,7 +90,17 @@ public class ProductDataCache implements IProductData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Paging<Product> findAll(int page, int size) {
|
||||
return productData.findAll(page, size);
|
||||
public Paging<Product> findAll(PageRequest<Product> pageRequest) {
|
||||
return productData.findAll(pageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Product> findAllByCondition(Product data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Product findOneByCondition(Product data) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.data.manager.IProductModelData;
|
||||
import cc.iotkit.data.cache.ProductModelCacheEvict;
|
||||
|
@ -10,6 +11,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -37,6 +39,11 @@ public class ProductModelDataCache implements IProductModelData {
|
|||
return productModelData.findById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductModel> findByIds(Collection<String> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductModel save(ProductModel data) {
|
||||
ProductModel productModel = productModelData.save(data);
|
||||
|
@ -45,8 +52,8 @@ public class ProductModelDataCache implements IProductModelData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProductModel add(ProductModel data) {
|
||||
return productModelData.add(data);
|
||||
public void batchSave(List<ProductModel> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +62,7 @@ public class ProductModelDataCache implements IProductModelData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(String[] strings) {
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -70,7 +77,18 @@ public class ProductModelDataCache implements IProductModelData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Paging<ProductModel> findAll(int page, int size) {
|
||||
return productModelData.findAll(page, size);
|
||||
public Paging<ProductModel> findAll(PageRequest<ProductModel> pageRequest) {
|
||||
return productModelData.findAll(pageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductModel> findAllByCondition(ProductModel data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductModel findOneByCondition(ProductModel data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.data.manager.ISpaceData;
|
||||
import cc.iotkit.data.cache.SpaceCacheEvict;
|
||||
|
@ -10,6 +11,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -57,6 +59,11 @@ public class SpaceDataCache implements ISpaceData {
|
|||
return spaceData.findById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Space> findByIds(Collection<String> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Space save(Space data) {
|
||||
data = spaceData.save(data);
|
||||
|
@ -65,8 +72,8 @@ public class SpaceDataCache implements ISpaceData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Space add(Space data) {
|
||||
return spaceData.add(data);
|
||||
public void batchSave(List<Space> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -75,7 +82,7 @@ public class SpaceDataCache implements ISpaceData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(String[] strings) {
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -90,7 +97,18 @@ public class SpaceDataCache implements ISpaceData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Paging<Space> findAll(int page, int size) {
|
||||
return spaceData.findAll(page, size);
|
||||
public Paging<Space> findAll(PageRequest<Space> pageRequest) {
|
||||
return spaceData.findAll(pageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Space> findAllByCondition(Space data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Space findOneByCondition(Space data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.data.manager.IThingModelData;
|
||||
import cc.iotkit.data.cache.ThingModelCacheEvict;
|
||||
|
@ -10,6 +11,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -27,6 +29,11 @@ public class ThingModelDataCache implements IThingModelData {
|
|||
return thingModelData.findById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThingModel> findByIds(Collection<String> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThingModel save(ThingModel data) {
|
||||
data = thingModelData.save(data);
|
||||
|
@ -35,8 +42,8 @@ public class ThingModelDataCache implements IThingModelData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ThingModel add(ThingModel data) {
|
||||
return thingModelData.add(data);
|
||||
public void batchSave(List<ThingModel> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,7 +52,7 @@ public class ThingModelDataCache implements IThingModelData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(String[] strings) {
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -60,8 +67,18 @@ public class ThingModelDataCache implements IThingModelData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Paging<ThingModel> findAll(int page, int size) {
|
||||
return thingModelData.findAll(page, size);
|
||||
public Paging<ThingModel> findAll(PageRequest<ThingModel> pageRequest) {
|
||||
return thingModelData.findAll(pageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThingModel> findAllByCondition(ThingModel data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThingModel findOneByCondition(ThingModel data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.data.manager.IUserInfoData;
|
||||
import cc.iotkit.data.cache.UserInfoCacheEvict;
|
||||
|
@ -10,6 +11,7 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
|||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
|
@ -42,6 +44,11 @@ public class UserInfoDataCache implements IUserInfoData {
|
|||
return userInfoData.findById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserInfo> findByIds(Collection<String> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo save(UserInfo data) {
|
||||
UserInfo userInfo = userInfoData.save(data);
|
||||
|
@ -51,8 +58,8 @@ public class UserInfoDataCache implements IUserInfoData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserInfo add(UserInfo data) {
|
||||
return userInfoData.add(data);
|
||||
public void batchSave(List<UserInfo> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +68,7 @@ public class UserInfoDataCache implements IUserInfoData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(String[] strings) {
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -76,7 +83,18 @@ public class UserInfoDataCache implements IUserInfoData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Paging<UserInfo> findAll(int page, int size) {
|
||||
return userInfoData.findAll(page, size);
|
||||
public Paging<UserInfo> findAll(PageRequest<UserInfo> pageRequest) {
|
||||
return userInfoData.findAll(pageRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserInfo> findAllByCondition(UserInfo data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo findOneByCondition(UserInfo data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.data.manager.IProductModelData;
|
||||
import cc.iotkit.data.dao.ProductModelRepository;
|
||||
|
@ -12,6 +13,7 @@ import org.springframework.context.annotation.Primary;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -37,6 +39,11 @@ public class ProductModelDataImpl implements IProductModelData {
|
|||
return MapstructUtils.convert(productModelRepository.findById(s).orElse(null), ProductModel.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductModel> findByIds(Collection<String> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductModel save(ProductModel data) {
|
||||
if (StringUtils.isBlank(data.getId())) {
|
||||
|
@ -47,6 +54,11 @@ public class ProductModelDataImpl implements IProductModelData {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchSave(List<ProductModel> data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void deleteById(String s) {
|
||||
|
@ -54,7 +66,7 @@ public class ProductModelDataImpl implements IProductModelData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(String[] strings) {
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -69,7 +81,18 @@ public class ProductModelDataImpl implements IProductModelData {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Paging<ProductModel> findAll(int page, int size) {
|
||||
return new Paging<>();
|
||||
public Paging<ProductModel> findAll(PageRequest<ProductModel> pageRequest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ProductModel> findAllByCondition(ProductModel data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProductModel findOneByCondition(ProductModel data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.data.manager.IUserInfoData;
|
||||
import cc.iotkit.data.dao.UserInfoRepository;
|
||||
import cc.iotkit.data.model.TbUserInfo;
|
||||
|
@ -22,6 +23,7 @@ import org.springframework.data.domain.Page;
|
|||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -52,6 +54,11 @@ public class UserInfoDataImpl implements IUserInfoData {
|
|||
return UserInfoMapper.toDtoFix(userInfoRepository.findById(s).orElse(null));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserInfo> findByIds(Collection<String> id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo save(UserInfo data) {
|
||||
if (StringUtils.isBlank(data.getId())) {
|
||||
|
@ -62,11 +69,21 @@ public class UserInfoDataImpl implements IUserInfoData {
|
|||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchSave(List<UserInfo> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteById(String s) {
|
||||
userInfoRepository.deleteById(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(Collection<String> strings) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByIds(String[] strings) {
|
||||
|
||||
|
@ -82,6 +99,21 @@ public class UserInfoDataImpl implements IUserInfoData {
|
|||
return UserInfoMapper.toDto(userInfoRepository.findAll());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<UserInfo> findAll(PageRequest<UserInfo> pageRequest) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserInfo> findAllByCondition(UserInfo data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserInfo findOneByCondition(UserInfo data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<UserInfo> findAll(int page, int size) {
|
||||
Page<TbUserInfo> paged = userInfoRepository.findAll(Pageable.ofSize(size).withPage(page - 1));
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.springframework.validation.annotation.Validated;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -95,7 +96,7 @@ public class SysDictTypeController extends BaseController {
|
|||
@SaCheckPermission("system:dict:remove")
|
||||
@Log(title = "字典类型", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{dictIds}")
|
||||
public void remove(@PathVariable Long[] dictIds) {
|
||||
public void remove(@PathVariable Collection<Long> dictIds) {
|
||||
dictTypeService.deleteDictTypeByIds(dictIds);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ import lombok.RequiredArgsConstructor;
|
|||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* 公告 信息操作处理
|
||||
*
|
||||
|
@ -74,7 +76,7 @@ public class SysNoticeController extends BaseController {
|
|||
@SaCheckPermission("system:notice:remove")
|
||||
@Log(title = "通知公告", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{noticeIds}")
|
||||
public void remove(@PathVariable Long[] noticeIds) {
|
||||
public void remove(@PathVariable Collection<Long> noticeIds) {
|
||||
noticeService.deleteNoticeByIds(noticeIds);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.system.dto.bo;
|
||||
|
||||
import cc.iotkit.common.api.BaseDto;
|
||||
import cc.iotkit.common.log.event.OperLogEvent;
|
||||
import cc.iotkit.model.system.SysOperLog;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
|
@ -22,7 +23,7 @@ import java.util.Map;
|
|||
@AutoMapper(target = SysOperLog.class, reverseConvertGenerate = false),
|
||||
@AutoMapper(target = OperLogEvent.class)
|
||||
})
|
||||
public class SysOperLogBo {
|
||||
public class SysOperLogBo extends BaseDto {
|
||||
|
||||
/**
|
||||
* 日志主键
|
||||
|
|
|
@ -29,7 +29,7 @@ public class SysRoleBo extends BaseDto {
|
|||
* 角色ID
|
||||
*/
|
||||
@NotNull(message = "角色ID不能为空", groups = { EditGroup.class })
|
||||
private Long roleId;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cc.iotkit.system.dto.vo;
|
||||
|
||||
import cc.iotkit.common.api.BaseDto;
|
||||
import cc.iotkit.common.excel.annotation.ExcelDictFormat;
|
||||
import cc.iotkit.common.excel.convert.ExcelDictConvert;
|
||||
import cc.iotkit.model.system.SysOperLog;
|
||||
|
@ -21,7 +22,7 @@ import java.util.Date;
|
|||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
@AutoMapper(target = SysOperLog.class)
|
||||
public class SysOperLogVo implements Serializable {
|
||||
public class SysOperLogVo extends BaseDto implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,7 +27,7 @@ public class SysRoleVo implements Serializable {
|
|||
* 角色ID
|
||||
*/
|
||||
@ExcelProperty(value = "角色序号")
|
||||
private Long roleId;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 角色名称
|
||||
|
|
|
@ -26,7 +26,7 @@ public class SysTenantPackageVo implements Serializable {
|
|||
* 租户套餐id
|
||||
*/
|
||||
@ExcelProperty(value = "租户套餐id")
|
||||
private Long packageId;
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 套餐名称
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
package cc.iotkit.system.mapper;
|
||||
|
||||
import cc.iotkit.common.constant.UserConstants;
|
||||
import cc.iotkit.model.system.SysMenu;
|
||||
import cc.iotkit.system.dto.vo.SysMenuVo;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 菜单表 数据层
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo> {
|
||||
|
||||
/**
|
||||
* 根据用户所有权限
|
||||
*
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<String> selectMenuPerms();
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SysMenu> selectMenuListByUserId(@Param(Constants.WRAPPER) Wrapper<SysMenu> queryWrapper);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询权限
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<String> selectMenuPermsByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询权限
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 权限列表
|
||||
*/
|
||||
List<String> selectMenuPermsByRoleId(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
*
|
||||
* @return 菜单列表
|
||||
*/
|
||||
default List<SysMenu> selectMenuTreeAll() {
|
||||
LambdaQueryWrapper<SysMenu> lqw = new LambdaQueryWrapper<SysMenu>()
|
||||
.in(SysMenu::getMenuType, UserConstants.TYPE_DIR, UserConstants.TYPE_MENU)
|
||||
.eq(SysMenu::getStatus, UserConstants.MENU_NORMAL)
|
||||
.orderByAsc(SysMenu::getParentId)
|
||||
.orderByAsc(SysMenu::getOrderNum);
|
||||
return this.selectList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户ID查询菜单
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 菜单列表
|
||||
*/
|
||||
List<SysMenu> selectMenuTreeByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据角色ID查询菜单树信息
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @param menuCheckStrictly 菜单树选择项是否关联显示
|
||||
* @return 选中菜单列表
|
||||
*/
|
||||
List<Long> selectMenuListByRoleId(@Param("roleId") Long roleId, @Param("menuCheckStrictly") boolean menuCheckStrictly);
|
||||
|
||||
}
|
|
@ -1,60 +0,0 @@
|
|||
package cc.iotkit.system.mapper;
|
||||
|
||||
import cc.iotkit.system.dto.vo.SysRoleVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 角色表 数据层
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysRoleMapper extends BaseMapperPlus<SysRole, SysRoleVo> {
|
||||
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id")
|
||||
})
|
||||
Page<SysRoleVo> selectPageRoleList(@Param("page") Page<SysRole> page, @Param(Constants.WRAPPER) Wrapper<SysRole> queryWrapper);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询角色数据
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 角色数据集合信息
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id")
|
||||
})
|
||||
List<SysRoleVo> selectRoleList(@Param(Constants.WRAPPER) Wrapper<SysRole> queryWrapper);
|
||||
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id")
|
||||
})
|
||||
SysRoleVo selectRoleById(Long roleId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 角色列表
|
||||
*/
|
||||
List<SysRoleVo> selectRolePermissionByUserId(Long userId);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID获取角色选择框列表
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 选中角色ID列表
|
||||
*/
|
||||
List<Long> selectRoleListByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询角色
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 角色列表
|
||||
*/
|
||||
List<SysRoleVo> selectRolesByUserName(String userName);
|
||||
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
package cc.iotkit.system.mapper;
|
||||
|
||||
import cc.iotkit.system.dto.vo.SysUserVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户表 数据层
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
|
||||
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
@DataColumn(key = "userName", value = "u.user_id")
|
||||
})
|
||||
Page<SysUserVo> selectPageUserList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
@DataColumn(key = "userName", value = "u.user_id")
|
||||
})
|
||||
List<SysUserVo> selectUserList(@Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已配用户角色列表
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
@DataColumn(key = "userName", value = "u.user_id")
|
||||
})
|
||||
Page<SysUserVo> selectAllocatedList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
|
||||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
* @param queryWrapper 查询条件
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
@DataColumn(key = "userName", value = "u.user_id")
|
||||
})
|
||||
Page<SysUserVo> selectUnallocatedList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
SysUserVo selectUserByUserName(String userName);
|
||||
|
||||
/**
|
||||
* 通过手机号查询用户
|
||||
*
|
||||
* @param phonenumber 手机号
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
SysUserVo selectUserByPhonenumber(String phonenumber);
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
SysUserVo selectUserByEmail(String email);
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户(不走租户插件)
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @param tenantId 租户id
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
SysUserVo selectTenantUserByUserName(String userName, String tenantId);
|
||||
|
||||
/**
|
||||
* 通过手机号查询用户(不走租户插件)
|
||||
*
|
||||
* @param phonenumber 手机号
|
||||
* @param tenantId 租户id
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
SysUserVo selectTenantUserByPhonenumber(String phonenumber, String tenantId);
|
||||
|
||||
/**
|
||||
* 通过邮箱查询用户(不走租户插件)
|
||||
*
|
||||
* @param email 邮箱
|
||||
* @param tenantId 租户id
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
SysUserVo selectTenantUserByEmail(String email, String tenantId);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "d.dept_id"),
|
||||
@DataColumn(key = "userName", value = "u.user_id")
|
||||
})
|
||||
SysUserVo selectUserById(Long userId);
|
||||
|
||||
@Override
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "dept_id"),
|
||||
@DataColumn(key = "userName", value = "user_id")
|
||||
})
|
||||
int update(@Param(Constants.ENTITY) SysUser user, @Param(Constants.WRAPPER) Wrapper<SysUser> updateWrapper);
|
||||
|
||||
@Override
|
||||
@DataPermission({
|
||||
@DataColumn(key = "deptName", value = "dept_id"),
|
||||
@DataColumn(key = "userName", value = "user_id")
|
||||
})
|
||||
int updateById(@Param(Constants.ENTITY) SysUser user);
|
||||
|
||||
}
|
|
@ -1,15 +0,0 @@
|
|||
package cc.iotkit.system.mapper;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户与角色关联表 数据层
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysUserRoleMapper extends BaseMapperPlus<SysUserRole, SysUserRole> {
|
||||
|
||||
List<Long> selectUserIdsByRoleId(Long roleId);
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ import cc.iotkit.system.dto.bo.SysDictTypeBo;
|
|||
import cc.iotkit.system.dto.vo.SysDictDataVo;
|
||||
import cc.iotkit.system.dto.vo.SysDictTypeVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -62,7 +63,7 @@ public interface ISysDictTypeService {
|
|||
*
|
||||
* @param dictIds 需要删除的字典ID
|
||||
*/
|
||||
void deleteDictTypeByIds(Long[] dictIds);
|
||||
void deleteDictTypeByIds(Collection<Long> dictIds);
|
||||
|
||||
/**
|
||||
* 重置字典缓存数据
|
||||
|
|
|
@ -5,6 +5,7 @@ import cc.iotkit.common.api.Paging;
|
|||
import cc.iotkit.system.dto.bo.SysLogininforBo;
|
||||
import cc.iotkit.system.dto.vo.SysLogininforVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -38,7 +39,7 @@ public interface ISysLogininforService {
|
|||
* @param infoIds 需要删除的登录日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
void deleteLogininforByIds(Long[] infoIds);
|
||||
void deleteLogininforByIds(Collection<Long> infoIds);
|
||||
|
||||
/**
|
||||
* 清空系统登录日志
|
||||
|
|
|
@ -119,7 +119,7 @@ public interface ISysMenuService {
|
|||
* @param bo 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertMenu(SysMenuBo bo);
|
||||
void insertMenu(SysMenuBo bo);
|
||||
|
||||
/**
|
||||
* 修改保存菜单信息
|
||||
|
@ -127,7 +127,7 @@ public interface ISysMenuService {
|
|||
* @param bo 菜单信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateMenu(SysMenuBo bo);
|
||||
void updateMenu(SysMenuBo bo);
|
||||
|
||||
/**
|
||||
* 删除菜单管理信息
|
||||
|
|
|
@ -6,6 +6,7 @@ import cc.iotkit.common.api.Paging;
|
|||
import cc.iotkit.system.dto.bo.SysNoticeBo;
|
||||
import cc.iotkit.system.dto.vo.SysNoticeVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -48,7 +49,7 @@ public interface ISysNoticeService {
|
|||
* @param bo 公告信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateNotice(SysNoticeBo bo);
|
||||
void updateNotice(SysNoticeBo bo);
|
||||
|
||||
/**
|
||||
* 删除公告信息
|
||||
|
@ -56,7 +57,7 @@ public interface ISysNoticeService {
|
|||
* @param noticeId 公告ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteNoticeById(Long noticeId);
|
||||
void deleteNoticeById(Long noticeId);
|
||||
|
||||
/**
|
||||
* 批量删除公告信息
|
||||
|
@ -64,5 +65,5 @@ public interface ISysNoticeService {
|
|||
* @param noticeIds 需要删除的公告ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteNoticeByIds(Long[] noticeIds);
|
||||
void deleteNoticeByIds(Collection<Long> noticeIds);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import cc.iotkit.common.api.Paging;
|
|||
import cc.iotkit.system.dto.bo.SysOperLogBo;
|
||||
import cc.iotkit.system.dto.vo.SysOperLogVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -37,7 +38,7 @@ public interface ISysOperLogService {
|
|||
* @param operIds 需要删除的操作日志ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteOperLogByIds(Long[] operIds);
|
||||
void deleteOperLogByIds(Collection<Long> operIds);
|
||||
|
||||
/**
|
||||
* 查询操作日志详细
|
||||
|
|
|
@ -26,8 +26,8 @@ public interface ISysOssService {
|
|||
|
||||
SysOssVo upload(MultipartFile file);
|
||||
|
||||
void download(Long ossId, HttpServletResponse response) throws IOException;
|
||||
void download(Long ossId) throws IOException;
|
||||
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
void deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import cc.iotkit.common.api.Paging;
|
|||
import cc.iotkit.system.dto.bo.SysPostBo;
|
||||
import cc.iotkit.system.dto.vo.SysPostVo;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -78,7 +79,7 @@ public interface ISysPostService {
|
|||
* @param postId 岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deletePostById(Long postId);
|
||||
void deletePostById(Long postId);
|
||||
|
||||
/**
|
||||
* 批量删除岗位信息
|
||||
|
@ -86,7 +87,7 @@ public interface ISysPostService {
|
|||
* @param postIds 需要删除的岗位ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deletePostByIds(Long[] postIds);
|
||||
void deletePostByIds(Collection<Long> postIds);
|
||||
|
||||
/**
|
||||
* 新增保存岗位信息
|
||||
|
@ -94,7 +95,7 @@ public interface ISysPostService {
|
|||
* @param bo 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertPost(SysPostBo bo);
|
||||
void insertPost(SysPostBo bo);
|
||||
|
||||
/**
|
||||
* 修改保存岗位信息
|
||||
|
@ -102,5 +103,5 @@ public interface ISysPostService {
|
|||
* @param bo 岗位信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updatePost(SysPostBo bo);
|
||||
void updatePost(SysPostBo bo);
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ public interface ISysRoleService {
|
|||
* @param bo 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
int insertRole(SysRoleBo bo);
|
||||
void insertRole(SysRoleBo bo);
|
||||
|
||||
/**
|
||||
* 修改保存角色信息
|
||||
|
@ -118,7 +118,7 @@ public interface ISysRoleService {
|
|||
* @param bo 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
int updateRole(SysRoleBo bo);
|
||||
void updateRole(SysRoleBo bo);
|
||||
|
||||
/**
|
||||
* 修改角色状态
|
||||
|
@ -127,7 +127,7 @@ public interface ISysRoleService {
|
|||
* @param status 角色状态
|
||||
* @return 结果
|
||||
*/
|
||||
int updateRoleStatus(Long roleId, String status);
|
||||
void updateRoleStatus(Long roleId, String status);
|
||||
|
||||
/**
|
||||
* 修改数据权限信息
|
||||
|
@ -135,7 +135,7 @@ public interface ISysRoleService {
|
|||
* @param bo 角色信息
|
||||
* @return 结果
|
||||
*/
|
||||
int authDataScope(SysRoleBo bo);
|
||||
void authDataScope(SysRoleBo bo);
|
||||
|
||||
/**
|
||||
* 通过角色ID删除角色
|
||||
|
@ -143,7 +143,7 @@ public interface ISysRoleService {
|
|||
* @param roleId 角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteRoleById(Long roleId);
|
||||
void deleteRoleById(Long roleId);
|
||||
|
||||
/**
|
||||
* 批量删除角色信息
|
||||
|
@ -151,7 +151,7 @@ public interface ISysRoleService {
|
|||
* @param roleIds 需要删除的角色ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteRoleByIds(Long[] roleIds);
|
||||
void deleteRoleByIds(Long[] roleIds);
|
||||
|
||||
/**
|
||||
* 取消授权用户角色
|
||||
|
@ -159,7 +159,7 @@ public interface ISysRoleService {
|
|||
* @param userRole 用户和角色关联信息
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteAuthUser(SysUserRole userRole);
|
||||
void deleteAuthUser(SysUserRole userRole);
|
||||
|
||||
/**
|
||||
* 批量取消授权用户角色
|
||||
|
@ -168,7 +168,7 @@ public interface ISysRoleService {
|
|||
* @param userIds 需要取消授权的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteAuthUsers(Long roleId, Long[] userIds);
|
||||
void deleteAuthUsers(Long roleId, Long[] userIds);
|
||||
|
||||
/**
|
||||
* 批量选择授权用户角色
|
||||
|
@ -177,7 +177,7 @@ public interface ISysRoleService {
|
|||
* @param userIds 需要删除的用户数据ID
|
||||
* @return 结果
|
||||
*/
|
||||
int insertAuthUsers(Long roleId, Long[] userIds);
|
||||
void insertAuthUsers(Long roleId, Long[] userIds);
|
||||
|
||||
void cleanOnlineUserByRole(Long roleId);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public interface ISysTenantPackageService {
|
|||
/**
|
||||
* 修改套餐状态
|
||||
*/
|
||||
int updatePackageStatus(SysTenantPackageBo bo);
|
||||
void updatePackageStatus(SysTenantPackageBo bo);
|
||||
|
||||
/**
|
||||
* 校验并批量删除租户套餐信息
|
||||
|
|
|
@ -16,8 +16,10 @@ import cc.iotkit.system.dto.bo.SysConfigBo;
|
|||
import cc.iotkit.system.dto.vo.SysConfigVo;
|
||||
import cc.iotkit.system.service.ISysConfigService;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -36,8 +38,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
|||
|
||||
@Override
|
||||
public Paging<SysConfigVo> selectPageConfigList(PageRequest<SysConfigBo> query) {
|
||||
PageRequest<SysConfig> pageRequest = PageRequest.copyPageRequest(query,MapstructUtils.convert(query.getData(), SysConfig.class));
|
||||
return MapstructUtils.convert(sysConfigData.findAll(pageRequest), SysConfigVo.class);
|
||||
return sysConfigData.findAll(query.to(SysConfig.class)).to(SysConfigVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +49,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
|||
*/
|
||||
@Override
|
||||
public SysConfigVo selectConfigById(Long configId) {
|
||||
return MapstructUtils.convert(sysConfigData.findById(configId), SysConfigVo.class);
|
||||
return sysConfigData.findById(configId).to(SysConfigVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,22 +95,9 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
|||
*/
|
||||
@Override
|
||||
public List<SysConfigVo> selectConfigList(SysConfigBo config) {
|
||||
// LambdaQueryWrapper<SysConfig> lqw = buildQueryWrapper(config);
|
||||
// return baseMapper.selectVoList(lqw);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
// private LambdaQueryWrapper<SysConfig> buildQueryWrapper(SysConfigBo bo) {
|
||||
// Map<String, Object> params = bo.getParams();
|
||||
// LambdaQueryWrapper<SysConfig> lqw = Wrappers.lambdaQuery();
|
||||
// lqw.like(StringUtils.isNotBlank(bo.getConfigName()), SysConfig::getConfigName, bo.getConfigName());
|
||||
// lqw.eq(StringUtils.isNotBlank(bo.getConfigType()), SysConfig::getConfigType, bo.getConfigType());
|
||||
// lqw.like(StringUtils.isNotBlank(bo.getConfigKey()), SysConfig::getConfigKey, bo.getConfigKey());
|
||||
// lqw.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
// SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime"));
|
||||
// return lqw;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 新增参数配置
|
||||
*
|
||||
|
@ -118,11 +106,6 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
|||
*/
|
||||
@Override
|
||||
public String insertConfig(SysConfigBo bo) {
|
||||
// SysConfig config = MapstructUtils.convert(bo, SysConfig.class);
|
||||
// int row = baseMapper.insert(config);
|
||||
// if (row > 0) {
|
||||
// return config.getConfigValue();
|
||||
// }
|
||||
throw new BizException("操作失败");
|
||||
}
|
||||
|
||||
|
@ -135,33 +118,18 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
|||
// @CachePut(cacheNames = CacheNames.SYS_CONFIG, key = "#bo.configKey")
|
||||
@Override
|
||||
public String updateConfig(SysConfigBo bo) {
|
||||
// int row = 0;
|
||||
// SysConfig config = MapstructUtils.convert(bo, SysConfig.class);
|
||||
// if (config.getId() != null) {
|
||||
// SysConfig temp = sysConfigData.selectById(config.getConfigId());
|
||||
// if (!StringUtils.equals(temp.getConfigKey(), config.getConfigKey())) {
|
||||
// CacheUtils.evict(CacheNames.SYS_CONFIG, temp.getConfigKey());
|
||||
// if (config.getId() == null) {
|
||||
// SysConfig old = sysConfigData.findByConfigKey(bo.getConfigKey());
|
||||
// if (old == null) {
|
||||
// throw new BizException("操作失败,key不存在");
|
||||
// }
|
||||
// row = baseMapper.updateById(config);
|
||||
// } else {
|
||||
// row = baseMapper.update(config, new LambdaQueryWrapper<SysConfig>()
|
||||
// .eq(SysConfig::getConfigKey, config.getConfigKey()));
|
||||
// config.setId(old.getId());
|
||||
// }
|
||||
// if (row > 0) {
|
||||
//
|
||||
// sysConfigData.save(config);
|
||||
// return config.getConfigValue();
|
||||
// }
|
||||
// throw new BizException("操作失败");
|
||||
SysConfig config = MapstructUtils.convert(bo, SysConfig.class);
|
||||
if (config.getId() == null) {
|
||||
SysConfig old = sysConfigData.findByConfigKey(bo.getConfigKey());
|
||||
if (old == null) {
|
||||
throw new BizException("操作失败,key不存在");
|
||||
}
|
||||
config.setId(old.getId());
|
||||
}
|
||||
|
||||
sysConfigData.save(config);
|
||||
return config.getConfigValue();
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,9 +165,10 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
|
|||
*/
|
||||
@Override
|
||||
public boolean checkConfigKeyUnique(SysConfigBo config) {
|
||||
long configId = ObjectUtil.isNull(config.getId()) ? -1L : config.getId();
|
||||
SysConfig old = sysConfigData.findByConfigKey(config.getConfigKey());
|
||||
return !ObjectUtil.isNotNull(old) || old.getId() == configId;
|
||||
// long configId = ObjectUtil.isNull(config.getId()) ? -1L : config.getId();
|
||||
// SysConfig old = sysConfigData.findByConfigKey(config.getConfigKey());
|
||||
// return !ObjectUtil.isNotNull(old) || old.getId() == configId;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -51,7 +51,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||
@Override
|
||||
public List<SysDeptVo> selectDeptList(SysDeptBo dept) {
|
||||
return MapstructUtils.convert(
|
||||
sysDeptData.findDepts(MapstructUtils.convert(dept, SysDept.class))
|
||||
sysDeptData.findDepts(dept.to(SysDept.class))
|
||||
, SysDeptVo.class);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
|
|||
*/
|
||||
@Override
|
||||
public List<Tree<Long>> selectDeptTreeList(SysDeptBo bo) {
|
||||
List<SysDept> depts = sysDeptData.findDepts(MapstructUtils.convert(bo, SysDept.class));
|
||||
List<SysDept> depts = sysDeptData.findDepts(bo.to(SysDept.class));
|
||||
return buildDeptTreeSelect(depts);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
|
|||
public Paging<SysDictDataVo> selectPageDictDataList(SysDictDataBo dictData, PageRequest<?> query) {
|
||||
return MapstructUtils.convert(
|
||||
sysDictData.findByConditions(
|
||||
MapstructUtils.convert(dictData, SysDictData.class),
|
||||
dictData.to(SysDictData.class),
|
||||
query.getPageNum(),
|
||||
query.getPageSize()
|
||||
), SysDictDataVo.class);
|
||||
|
|
|
@ -23,10 +23,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
@ -45,7 +42,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
|||
public Paging<SysDictTypeVo> selectPageDictTypeList(SysDictTypeBo dictType, PageRequest<?> query) {
|
||||
return MapstructUtils.convert(
|
||||
sysDictTypeData.findByConditions(
|
||||
MapstructUtils.convert(dictType, SysDictType.class),
|
||||
dictType.to(SysDictType.class),
|
||||
query.getPageNum(), query.getPageSize()),
|
||||
SysDictTypeVo.class);
|
||||
}
|
||||
|
@ -60,7 +57,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
|||
public List<SysDictTypeVo> selectDictTypeList(SysDictTypeBo dictType) {
|
||||
return MapstructUtils.convert(
|
||||
sysDictTypeData.findByConditions(
|
||||
MapstructUtils.convert(dictType, SysDictType.class)),
|
||||
dictType.to(SysDictType.class)),
|
||||
SysDictTypeVo.class);
|
||||
}
|
||||
|
||||
|
@ -115,7 +112,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
|
|||
* @param dictIds 需要删除的字典ID
|
||||
*/
|
||||
@Override
|
||||
public void deleteDictTypeByIds(Long[] dictIds) {
|
||||
public void deleteDictTypeByIds(Collection<Long> dictIds) {
|
||||
for (Long dictId : dictIds) {
|
||||
SysDictType dictType = sysDictTypeData.findById(dictId);
|
||||
if (sysDictData.countByDicType(dictType.getDictType()) > 0) {
|
||||
|
|
|
@ -19,6 +19,7 @@ import org.springframework.context.event.EventListener;
|
|||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -128,7 +129,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public void deleteLogininforByIds(Long[] infoIds) {
|
||||
public void deleteLogininforByIds(Collection<Long> infoIds) {
|
||||
sysLogininforData.deleteByIds(infoIds);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,30 +1,22 @@
|
|||
package cc.iotkit.system.service.impl;
|
||||
|
||||
import cc.iotkit.common.constant.UserConstants;
|
||||
import cc.iotkit.common.satoken.utils.LoginHelper;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.StreamUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.common.utils.TreeBuildUtils;
|
||||
import cc.iotkit.data.system.ISysLogininforData;
|
||||
import cc.iotkit.data.system.ISysMenuData;
|
||||
import cc.iotkit.model.system.SysMenu;
|
||||
import cc.iotkit.model.system.SysRole;
|
||||
import cc.iotkit.model.system.SysTenantPackage;
|
||||
import cc.iotkit.system.dto.SysRoleMenu;
|
||||
import cc.iotkit.system.dto.bo.SysMenuBo;
|
||||
import cc.iotkit.system.dto.vo.MetaVo;
|
||||
import cc.iotkit.system.dto.vo.RouterVo;
|
||||
import cc.iotkit.system.dto.vo.SysMenuVo;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cc.iotkit.system.service.ISysMenuService;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.lang.tree.Tree;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 菜单 业务层处理
|
||||
|
@ -35,7 +27,7 @@ import java.util.*;
|
|||
@Service
|
||||
public class SysMenuServiceImpl implements ISysMenuService {
|
||||
|
||||
private final ISysMenuData iSysMenuData;
|
||||
private final ISysMenuData sysMenuData;
|
||||
|
||||
/**
|
||||
* 根据用户查询系统菜单列表
|
||||
|
@ -56,27 +48,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public List<SysMenuVo> selectMenuList(SysMenuBo menu, Long userId) {
|
||||
List<SysMenuVo> menuList;
|
||||
// 管理员显示所有菜单信息
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
menuList = baseMapper.selectVoList(new LambdaQueryWrapper<SysMenu>()
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus())
|
||||
.orderByAsc(SysMenu::getParentId)
|
||||
.orderByAsc(SysMenu::getOrderNum));
|
||||
} else {
|
||||
QueryWrapper<SysMenu> wrapper = Wrappers.query();
|
||||
wrapper.eq("sur.user_id", userId)
|
||||
.like(StringUtils.isNotBlank(menu.getMenuName()), "m.menu_name", menu.getMenuName())
|
||||
.eq(StringUtils.isNotBlank(menu.getVisible()), "m.visible", menu.getVisible())
|
||||
.eq(StringUtils.isNotBlank(menu.getStatus()), "m.status", menu.getStatus())
|
||||
.orderByAsc("m.parent_id")
|
||||
.orderByAsc("m.order_num");
|
||||
List<SysMenu> list = baseMapper.selectMenuListByUserId(wrapper);
|
||||
menuList = MapstructUtils.convert(list, SysMenuVo.class);
|
||||
}
|
||||
return menuList;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,14 +59,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByUserId(Long userId) {
|
||||
List<String> perms = baseMapper.selectMenuPermsByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
if (StringUtils.isNotEmpty(perm)) {
|
||||
permsSet.addAll(StringUtils.splitList(perm.trim()));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -105,14 +70,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public Set<String> selectMenuPermsByRoleId(Long roleId) {
|
||||
List<String> perms = baseMapper.selectMenuPermsByRoleId(roleId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (String perm : perms) {
|
||||
if (StringUtils.isNotEmpty(perm)) {
|
||||
permsSet.addAll(StringUtils.splitList(perm.trim()));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,13 +81,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public List<SysMenu> selectMenuTreeByUserId(Long userId) {
|
||||
List<SysMenu> menus;
|
||||
if (LoginHelper.isSuperAdmin(userId)) {
|
||||
menus = baseMapper.selectMenuTreeAll();
|
||||
} else {
|
||||
menus = baseMapper.selectMenuTreeByUserId(userId);
|
||||
}
|
||||
return getChildPerms(menus, 0);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,8 +92,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public List<Long> selectMenuListByRoleId(Long roleId) {
|
||||
SysRole role = roleMapper.selectById(roleId);
|
||||
return baseMapper.selectMenuListByRoleId(roleId, role.getMenuCheckStrictly());
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -152,20 +103,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public List<Long> selectMenuListByPackageId(Long packageId) {
|
||||
SysTenantPackage tenantPackage = tenantPackageMapper.selectById(packageId);
|
||||
List<Long> menuIds = StringUtils.splitTo(tenantPackage.getMenuIds(), Convert::toLong);
|
||||
if (CollUtil.isEmpty(menuIds)) {
|
||||
return List.of();
|
||||
}
|
||||
List<Long> parentIds = null;
|
||||
if (tenantPackage.getMenuCheckStrictly()) {
|
||||
parentIds = baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
|
||||
.select(SysMenu::getParentId)
|
||||
.in(SysMenu::getMenuId, menuIds), Convert::toLong);
|
||||
}
|
||||
return baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
|
||||
.in(SysMenu::getMenuId, menuIds)
|
||||
.notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds), Convert::toLong);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,47 +114,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public List<RouterVo> buildMenus(List<SysMenu> menus) {
|
||||
List<RouterVo> routers = new LinkedList<>();
|
||||
for (SysMenu menu : menus) {
|
||||
RouterVo router = new RouterVo();
|
||||
router.setHidden("1".equals(menu.getVisible()));
|
||||
router.setName(menu.getRouteName());
|
||||
router.setPath(menu.getRouterPath());
|
||||
router.setComponent(menu.getComponentInfo());
|
||||
router.setQuery(menu.getQueryParam());
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||
List<SysMenu> cMenus = menu.getChildren();
|
||||
if (CollUtil.isNotEmpty(cMenus) && UserConstants.TYPE_DIR.equals(menu.getMenuType())) {
|
||||
router.setAlwaysShow(true);
|
||||
router.setRedirect("noRedirect");
|
||||
router.setChildren(buildMenus(cMenus));
|
||||
} else if (menu.isMenuFrame()) {
|
||||
router.setMeta(null);
|
||||
List<RouterVo> childrenList = new ArrayList<>();
|
||||
RouterVo children = new RouterVo();
|
||||
children.setPath(menu.getPath());
|
||||
children.setComponent(menu.getComponentInfo());
|
||||
children.setName(StringUtils.capitalize(menu.getPath()));
|
||||
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), StringUtils.equals("1", menu.getIsCache()), menu.getPath()));
|
||||
children.setQuery(menu.getQueryParam());
|
||||
childrenList.add(children);
|
||||
router.setChildren(childrenList);
|
||||
} else if (menu.getParentId().intValue() == 0 && menu.isInnerLink()) {
|
||||
router.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon()));
|
||||
router.setPath("/");
|
||||
List<RouterVo> childrenList = new ArrayList<>();
|
||||
RouterVo children = new RouterVo();
|
||||
String routerPath = SysMenu.innerLinkReplaceEach(menu.getPath());
|
||||
children.setPath(routerPath);
|
||||
children.setComponent(UserConstants.INNER_LINK);
|
||||
children.setName(StringUtils.capitalize(routerPath));
|
||||
children.setMeta(new MetaVo(menu.getMenuName(), menu.getIcon(), menu.getPath()));
|
||||
childrenList.add(children);
|
||||
router.setChildren(childrenList);
|
||||
}
|
||||
routers.add(router);
|
||||
}
|
||||
return routers;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -245,7 +143,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public SysMenuVo selectMenuById(Long menuId) {
|
||||
return baseMapper.selectVoById(menuId);
|
||||
return sysMenuData.findById(menuId).to(SysMenuVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -256,7 +154,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public boolean hasChildByMenuId(Long menuId) {
|
||||
return baseMapper.exists(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId));
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -267,7 +165,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public boolean checkMenuExistRole(Long menuId) {
|
||||
return roleMenuMapper.exists(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getMenuId, menuId));
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -277,9 +175,8 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertMenu(SysMenuBo bo) {
|
||||
SysMenu menu = MapstructUtils.convert(bo, SysMenu.class);
|
||||
return baseMapper.insert(menu);
|
||||
public void insertMenu(SysMenuBo bo) {
|
||||
sysMenuData.save(bo.to(SysMenu.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -289,9 +186,8 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateMenu(SysMenuBo bo) {
|
||||
SysMenu menu = MapstructUtils.convert(bo, SysMenu.class);
|
||||
return baseMapper.updateById(menu);
|
||||
public void updateMenu(SysMenuBo bo) {
|
||||
sysMenuData.save(bo.to(SysMenu.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -302,7 +198,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public void deleteMenuById(Long menuId) {
|
||||
iSysMenuData.deleteById(menuId);
|
||||
sysMenuData.deleteById(menuId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -313,11 +209,7 @@ public class SysMenuServiceImpl implements ISysMenuService {
|
|||
*/
|
||||
@Override
|
||||
public boolean checkMenuNameUnique(SysMenuBo menu) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysMenu>()
|
||||
.eq(SysMenu::getMenuName, menu.getMenuName())
|
||||
.eq(SysMenu::getParentId, menu.getParentId())
|
||||
.ne(ObjectUtil.isNotNull(menu.getMenuId()), SysMenu::getMenuId, menu.getMenuId()));
|
||||
return !exist;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,9 @@ import cc.iotkit.system.service.ISysNoticeService;
|
|||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -25,13 +27,11 @@ import java.util.List;
|
|||
@Service
|
||||
public class SysNoticeServiceImpl implements ISysNoticeService {
|
||||
|
||||
private ISysNoticeData iSysNoticeData;
|
||||
private ISysNoticeData sysNoticeData;
|
||||
|
||||
@Override
|
||||
public Paging<SysNoticeVo> selectPageNoticeList(SysNoticeBo notice, PageRequest<?> query) {
|
||||
LambdaQueryWrapper<SysNotice> lqw = buildQueryWrapper(notice);
|
||||
Page<SysNoticeVo> page = baseMapper.selectVoPage(query.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
return new Paging<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
|||
*/
|
||||
@Override
|
||||
public SysNoticeVo selectNoticeById(Long noticeId) {
|
||||
return baseMapper.selectVoById(noticeId);
|
||||
return sysNoticeData.findById(noticeId).to(SysNoticeVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -53,19 +53,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
|||
*/
|
||||
@Override
|
||||
public List<SysNoticeVo> selectNoticeList(SysNoticeBo notice) {
|
||||
LambdaQueryWrapper<SysNotice> lqw = buildQueryWrapper(notice);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SysNotice> buildQueryWrapper(SysNoticeBo bo) {
|
||||
LambdaQueryWrapper<SysNotice> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getNoticeTitle()), SysNotice::getNoticeTitle, bo.getNoticeTitle());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getNoticeType()), SysNotice::getNoticeType, bo.getNoticeType());
|
||||
if (StringUtils.isNotBlank(bo.getCreateByName())) {
|
||||
SysUserVo sysUser = userMapper.selectUserByUserName(bo.getCreateByName());
|
||||
lqw.eq(SysNotice::getCreateBy, ObjectUtil.isNotNull(sysUser) ? sysUser.getUserId() : null);
|
||||
}
|
||||
return lqw;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,9 +64,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
|||
*/
|
||||
@Override
|
||||
public Long insertNotice(SysNoticeBo bo) {
|
||||
SysNotice notice = MapstructUtils.convert(bo, SysNotice.class);
|
||||
iSysNoticeData.save(notice);
|
||||
return notice.getId();
|
||||
return sysNoticeData.save(bo.to(SysNotice.class)).getId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,9 +74,8 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateNotice(SysNoticeBo bo) {
|
||||
SysNotice notice = MapstructUtils.convert(bo, SysNotice.class);
|
||||
return baseMapper.updateById(notice);
|
||||
public void updateNotice(SysNoticeBo bo) {
|
||||
sysNoticeData.save(bo.to(SysNotice.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,8 +85,8 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteNoticeById(Long noticeId) {
|
||||
return baseMapper.deleteById(noticeId);
|
||||
public void deleteNoticeById(Long noticeId) {
|
||||
sysNoticeData.deleteById(noticeId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -111,7 +96,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteNoticeByIds(Long[] noticeIds) {
|
||||
return baseMapper.deleteBatchIds(Arrays.asList(noticeIds));
|
||||
public void deleteNoticeByIds(Collection<Long> noticeIds) {
|
||||
sysNoticeData.deleteByIds(noticeIds);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import cc.iotkit.common.log.event.OperLogEvent;
|
|||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.common.utils.ip.AddressUtils;
|
||||
import cc.iotkit.data.system.ISysOperLogData;
|
||||
import cc.iotkit.model.system.SysOperLog;
|
||||
import cc.iotkit.system.dto.bo.SysOperLogBo;
|
||||
import cc.iotkit.system.dto.vo.SysOperLogVo;
|
||||
|
@ -16,10 +17,7 @@ import org.springframework.context.event.EventListener;
|
|||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 操作日志 服务层处理
|
||||
|
@ -30,7 +28,7 @@ import java.util.Map;
|
|||
@Service
|
||||
public class SysOperLogServiceImpl implements ISysOperLogService {
|
||||
|
||||
private final SysOperLogMapper baseMapper;
|
||||
private final ISysOperLogData sysOperLogData;
|
||||
|
||||
/**
|
||||
* 操作日志记录
|
||||
|
@ -48,27 +46,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
|||
|
||||
@Override
|
||||
public Paging<SysOperLogVo> selectPageOperLogList(SysOperLogBo operLog, PageRequest<?> query) {
|
||||
Map<String, Object> params = operLog.getParams();
|
||||
LambdaQueryWrapper<SysOperLog> lqw = new LambdaQueryWrapper<SysOperLog>()
|
||||
.like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle())
|
||||
.eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
|
||||
SysOperLog::getBusinessType, operLog.getBusinessType())
|
||||
.func(f -> {
|
||||
if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) {
|
||||
f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes()));
|
||||
}
|
||||
})
|
||||
.eq(operLog.getStatus() != null,
|
||||
SysOperLog::getStatus, operLog.getStatus())
|
||||
.like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime"));
|
||||
if (StringUtils.isBlank(query.getOrderByColumn())) {
|
||||
pageQuery.setOrderByColumn("oper_id");
|
||||
pageQuery.setIsAsc("desc");
|
||||
}
|
||||
Page<SysOperLogVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
return new Paging<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,9 +56,8 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
|||
*/
|
||||
@Override
|
||||
public void insertOperlog(SysOperLogBo bo) {
|
||||
SysOperLog operLog = MapstructUtils.convert(bo, SysOperLog.class);
|
||||
operLog.setOperTime(new Date());
|
||||
baseMapper.insert(operLog);
|
||||
bo.setOperTime(new Date());
|
||||
sysOperLogData.save(bo.to(SysOperLog.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -91,22 +68,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
|||
*/
|
||||
@Override
|
||||
public List<SysOperLogVo> selectOperLogList(SysOperLogBo operLog) {
|
||||
Map<String, Object> params = operLog.getParams();
|
||||
return baseMapper.selectVoList(new LambdaQueryWrapper<SysOperLog>()
|
||||
.like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle())
|
||||
.eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
|
||||
SysOperLog::getBusinessType, operLog.getBusinessType())
|
||||
.func(f -> {
|
||||
if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) {
|
||||
f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes()));
|
||||
}
|
||||
})
|
||||
.eq(operLog.getStatus() != null && operLog.getStatus() > 0,
|
||||
SysOperLog::getStatus, operLog.getStatus())
|
||||
.like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime"))
|
||||
.orderByDesc(SysOperLog::getOperId));
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -116,8 +78,8 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteOperLogByIds(Long[] operIds) {
|
||||
return baseMapper.deleteBatchIds(Arrays.asList(operIds));
|
||||
public void deleteOperLogByIds(Collection<Long> operIds) {
|
||||
sysOperLogData.deleteByIds(operIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -128,7 +90,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
|||
*/
|
||||
@Override
|
||||
public SysOperLogVo selectOperLogById(Long operId) {
|
||||
return baseMapper.selectVoById(operId);
|
||||
return sysOperLogData.findById(operId).to(SysOperLogVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -136,6 +98,5 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
|
|||
*/
|
||||
@Override
|
||||
public void cleanOperLog() {
|
||||
baseMapper.delete(new LambdaQueryWrapper<>());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@ import cc.iotkit.common.oss.factory.OssFactory;
|
|||
import cc.iotkit.common.service.OssService;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.SpringUtils;
|
||||
import cc.iotkit.common.utils.StreamUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.data.system.ISysOssData;
|
||||
import cc.iotkit.model.system.SysOss;
|
||||
import cc.iotkit.system.dto.bo.SysOssBo;
|
||||
import cc.iotkit.system.dto.vo.SysOssVo;
|
||||
|
@ -39,15 +39,11 @@ import java.util.Map;
|
|||
@Service
|
||||
public class SysOssServiceImpl implements ISysOssService, OssService {
|
||||
|
||||
private final SysOssMapper baseMapper;
|
||||
private final ISysOssData sysOssData;
|
||||
|
||||
@Override
|
||||
public Paging<SysOssVo> queryPageList(SysOssBo bo, PageRequest<?> query) {
|
||||
LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo);
|
||||
Page<SysOssVo> result = baseMapper.selectVoPage(query.build(), lqw);
|
||||
List<SysOssVo> filterResult = StreamUtils.toList(result.getRecords(), this::matchingUrl);
|
||||
result.setRecords(filterResult);
|
||||
return TableDataInfo.build(result);
|
||||
return new Paging<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -74,24 +70,10 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
|||
return String.join(StringUtils.SEPARATOR, list);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SysOss> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getFileName()), SysOss::getFileName, bo.getFileName());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getOriginalName()), SysOss::getOriginalName, bo.getOriginalName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getFileSuffix()), SysOss::getFileSuffix, bo.getFileSuffix());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysOss::getUrl, bo.getUrl());
|
||||
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
|
||||
SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
|
||||
lqw.eq(ObjectUtil.isNotNull(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getService()), SysOss::getService, bo.getService());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId")
|
||||
@Override
|
||||
public SysOssVo getById(Long ossId) {
|
||||
return baseMapper.selectVoById(ossId);
|
||||
return sysOssData.findById(ossId).to(SysOssVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -116,22 +98,22 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
|
|||
oss.setFileName(uploadResult.getFilename());
|
||||
oss.setOriginalName(originalfileName);
|
||||
oss.setService(storage.getConfigKey());
|
||||
baseMapper.insert(oss);
|
||||
sysOssData.save(oss);
|
||||
SysOssVo sysOssVo = MapstructUtils.convert(oss, SysOssVo.class);
|
||||
return this.matchingUrl(sysOssVo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
public void deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
// 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
List<SysOss> list = baseMapper.selectBatchIds(ids);
|
||||
List<SysOss> list = sysOssData.findByIds(ids);
|
||||
for (SysOss sysOss : list) {
|
||||
OssClient storage = OssFactory.instance(sysOss.getService());
|
||||
storage.delete(sysOss.getUrl());
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
sysOssData.deleteByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,18 +2,17 @@ package cc.iotkit.system.service.impl;
|
|||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.data.system.ISysPostData;
|
||||
import cc.iotkit.model.system.SysPost;
|
||||
import cc.iotkit.system.dto.bo.SysPostBo;
|
||||
import cc.iotkit.system.dto.vo.SysPostVo;
|
||||
import cc.iotkit.system.mapper.SysPostMapper;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cc.iotkit.system.service.ISysPostService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -25,14 +24,11 @@ import java.util.List;
|
|||
@Service
|
||||
public class SysPostServiceImpl implements ISysPostService {
|
||||
|
||||
private final SysPostMapper baseMapper;
|
||||
private final SysUserPostMapper userPostMapper;
|
||||
private final ISysPostData sysPostData;
|
||||
|
||||
@Override
|
||||
public Paging<SysPostVo> selectPagePostList(SysPostBo post, PageRequest<?> query) {
|
||||
LambdaQueryWrapper<SysPost> lqw = buildQueryWrapper(post);
|
||||
Page<SysPostVo> page = baseMapper.selectVoPage(query.build(), lqw);
|
||||
return TableDataInfo.build(page);
|
||||
return new Paging<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,17 +39,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
*/
|
||||
@Override
|
||||
public List<SysPostVo> selectPostList(SysPostBo post) {
|
||||
LambdaQueryWrapper<SysPost> lqw = buildQueryWrapper(post);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SysPost> buildQueryWrapper(SysPostBo bo) {
|
||||
LambdaQueryWrapper<SysPost> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getPostCode()), SysPost::getPostCode, bo.getPostCode());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getPostName()), SysPost::getPostName, bo.getPostName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysPost::getStatus, bo.getStatus());
|
||||
lqw.orderByAsc(SysPost::getPostSort);
|
||||
return lqw;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -63,7 +49,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
*/
|
||||
@Override
|
||||
public List<SysPostVo> selectPostAll() {
|
||||
return baseMapper.selectVoList(new QueryWrapper<>());
|
||||
return MapstructUtils.convert(sysPostData.findAll(), SysPostVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,7 +60,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
*/
|
||||
@Override
|
||||
public SysPostVo selectPostById(Long postId) {
|
||||
return baseMapper.selectVoById(postId);
|
||||
return sysPostData.findById(postId).to(SysPostVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,7 +71,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
*/
|
||||
@Override
|
||||
public List<Long> selectPostListByUserId(Long userId) {
|
||||
return baseMapper.selectPostListByUserId(userId);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,10 +82,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
*/
|
||||
@Override
|
||||
public boolean checkPostNameUnique(SysPostBo post) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||
.eq(SysPost::getPostName, post.getPostName())
|
||||
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
|
||||
return !exist;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -110,10 +93,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
*/
|
||||
@Override
|
||||
public boolean checkPostCodeUnique(SysPostBo post) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
|
||||
.eq(SysPost::getPostCode, post.getPostCode())
|
||||
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
|
||||
return !exist;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,7 +104,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
*/
|
||||
@Override
|
||||
public long countUserPostById(Long postId) {
|
||||
return userPostMapper.selectCount(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getPostId, postId));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -134,8 +114,8 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostById(Long postId) {
|
||||
return baseMapper.deleteById(postId);
|
||||
public void deletePostById(Long postId) {
|
||||
sysPostData.deleteById(postId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -145,14 +125,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePostByIds(Long[] postIds) {
|
||||
for (Long postId : postIds) {
|
||||
SysPost post = baseMapper.selectById(postId);
|
||||
if (countUserPostById(postId) > 0) {
|
||||
throw new BizException(String.format("%1$s已分配,不能删除", post.getPostName()));
|
||||
}
|
||||
}
|
||||
return baseMapper.deleteBatchIds(Arrays.asList(postIds));
|
||||
public void deletePostByIds(Collection<Long> postIds) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,9 +135,8 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertPost(SysPostBo bo) {
|
||||
SysPost post = MapstructUtils.convert(bo, SysPost.class);
|
||||
return baseMapper.insert(post);
|
||||
public void insertPost(SysPostBo bo) {
|
||||
sysPostData.save(bo.to(SysPost.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -174,8 +146,7 @@ public class SysPostServiceImpl implements ISysPostService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePost(SysPostBo bo) {
|
||||
SysPost post = MapstructUtils.convert(bo, SysPost.class);
|
||||
return baseMapper.updateById(post);
|
||||
public void updatePost(SysPostBo bo) {
|
||||
sysPostData.save(bo.to(SysPost.class));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,25 @@
|
|||
package cc.iotkit.system.service.impl;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.undefined.LoginUser;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.satoken.utils.LoginHelper;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.StreamUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.data.system.ISysRoleData;
|
||||
import cc.iotkit.model.system.SysRole;
|
||||
import cc.iotkit.system.dto.SysRoleDept;
|
||||
import cc.iotkit.system.dto.SysRoleMenu;
|
||||
import cc.iotkit.system.dto.SysUserRole;
|
||||
import cc.iotkit.system.dto.bo.SysRoleBo;
|
||||
import cc.iotkit.system.dto.vo.SysRoleVo;
|
||||
import cc.iotkit.system.mapper.SysRoleMapper;
|
||||
import cn.dev33.satoken.exception.NotLoginException;
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import cc.iotkit.system.service.ISysRoleService;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cc.iotkit.system.mapper.SysUserRoleMapper;
|
||||
import cc.iotkit.system.service.ISysRoleService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 角色 业务层处理
|
||||
|
@ -36,10 +30,11 @@ import java.util.*;
|
|||
@Service
|
||||
public class SysRoleServiceImpl implements ISysRoleService {
|
||||
|
||||
private final ISysRoleData sysRoleData;
|
||||
|
||||
@Override
|
||||
public Paging<SysRoleVo> selectPageRoleList(SysRoleBo role, PageRequest<?> query) {
|
||||
Page<SysRoleVo> page = baseMapper.selectPageRoleList(query.build(), this.buildQueryWrapper(role));
|
||||
return TableDataInfo.build(page);
|
||||
return new Paging<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -50,21 +45,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
public List<SysRoleVo> selectRoleList(SysRoleBo role) {
|
||||
return baseMapper.selectRoleList(this.buildQueryWrapper(role));
|
||||
}
|
||||
|
||||
private Wrapper<SysRole> buildQueryWrapper(SysRoleBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
QueryWrapper<SysRole> wrapper = Wrappers.query();
|
||||
wrapper.eq("r.del_flag", UserConstants.ROLE_NORMAL)
|
||||
.eq(ObjectUtil.isNotNull(bo.getRoleId()), "r.role_id", bo.getRoleId())
|
||||
.like(StringUtils.isNotBlank(bo.getRoleName()), "r.role_name", bo.getRoleName())
|
||||
.eq(StringUtils.isNotBlank(bo.getStatus()), "r.status", bo.getStatus())
|
||||
.like(StringUtils.isNotBlank(bo.getRoleKey()), "r.role_key", bo.getRoleKey())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
"r.create_time", params.get("beginTime"), params.get("endTime"))
|
||||
.orderByAsc("r.role_sort").orderByAsc("r.create_time");;
|
||||
return wrapper;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,17 +56,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
public List<SysRoleVo> selectRolesByUserId(Long userId) {
|
||||
List<SysRoleVo> userRoles = baseMapper.selectRolePermissionByUserId(userId);
|
||||
List<SysRoleVo> roles = selectRoleAll();
|
||||
for (SysRoleVo role : roles) {
|
||||
for (SysRoleVo userRole : userRoles) {
|
||||
if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) {
|
||||
role.setFlag(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return roles;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,14 +67,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
public Set<String> selectRolePermissionByUserId(Long userId) {
|
||||
List<SysRoleVo> perms = baseMapper.selectRolePermissionByUserId(userId);
|
||||
Set<String> permsSet = new HashSet<>();
|
||||
for (SysRoleVo perm : perms) {
|
||||
if (ObjectUtil.isNotNull(perm)) {
|
||||
permsSet.addAll(StringUtils.splitList(perm.getRoleKey().trim()));
|
||||
}
|
||||
}
|
||||
return permsSet;
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -124,7 +88,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
public List<Long> selectRoleListByUserId(Long userId) {
|
||||
return baseMapper.selectRoleListByUserId(userId);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,7 +99,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
public SysRoleVo selectRoleById(Long roleId) {
|
||||
return baseMapper.selectRoleById(roleId);
|
||||
return sysRoleData.findById(roleId).to(SysRoleVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -146,10 +110,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
public boolean checkRoleNameUnique(SysRoleBo role) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getRoleName, role.getRoleName())
|
||||
.ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId()));
|
||||
return !exist;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -160,10 +121,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
public boolean checkRoleKeyUnique(SysRoleBo role) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysRole>()
|
||||
.eq(SysRole::getRoleKey, role.getRoleKey())
|
||||
.ne(ObjectUtil.isNotNull(role.getRoleId()), SysRole::getRoleId, role.getRoleId()));
|
||||
return !exist;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -206,7 +164,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
public long countUserRoleByRoleId(Long roleId) {
|
||||
return userRoleMapper.selectCount(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getRoleId, roleId));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -217,12 +175,10 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertRole(SysRoleBo bo) {
|
||||
SysRole role = MapstructUtils.convert(bo, SysRole.class);
|
||||
// 新增角色信息
|
||||
baseMapper.insert(role);
|
||||
bo.setRoleId(role.getRoleId());
|
||||
return insertRoleMenu(bo);
|
||||
public void insertRole(SysRoleBo bo) {
|
||||
SysRole role = sysRoleData.save(bo.to(SysRole.class));
|
||||
bo.setId(role.getId());
|
||||
insertRoleMenu(bo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,13 +189,8 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateRole(SysRoleBo bo) {
|
||||
SysRole role = MapstructUtils.convert(bo, SysRole.class);
|
||||
// 修改角色信息
|
||||
baseMapper.updateById(role);
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, role.getRoleId()));
|
||||
return insertRoleMenu(bo);
|
||||
public void updateRole(SysRoleBo bo) {
|
||||
sysRoleData.save(bo.to(SysRole.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -250,11 +201,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateRoleStatus(Long roleId, String status) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysRole>()
|
||||
.set(SysRole::getStatus, status)
|
||||
.eq(SysRole::getRoleId, roleId));
|
||||
public void updateRoleStatus(Long roleId, String status) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -265,14 +212,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int authDataScope(SysRoleBo bo) {
|
||||
SysRole role = MapstructUtils.convert(bo, SysRole.class);
|
||||
// 修改角色信息
|
||||
baseMapper.updateById(role);
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().eq(SysRoleDept::getRoleId, role.getRoleId()));
|
||||
// 新增角色和部门信息(数据权限)
|
||||
return insertRoleDept(bo);
|
||||
public void authDataScope(SysRoleBo bo) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -280,20 +220,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*
|
||||
* @param role 角色对象
|
||||
*/
|
||||
private int insertRoleMenu(SysRoleBo role) {
|
||||
int rows = 1;
|
||||
// 新增用户与角色管理
|
||||
List<SysRoleMenu> list = new ArrayList<SysRoleMenu>();
|
||||
for (Long menuId : role.getMenuIds()) {
|
||||
SysRoleMenu rm = new SysRoleMenu();
|
||||
rm.setRoleId(role.getRoleId());
|
||||
rm.setMenuId(menuId);
|
||||
list.add(rm);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
rows = roleMenuMapper.insertBatch(list) ? list.size() : 0;
|
||||
}
|
||||
return rows;
|
||||
private void insertRoleMenu(SysRoleBo role) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -301,20 +228,8 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*
|
||||
* @param role 角色对象
|
||||
*/
|
||||
private int insertRoleDept(SysRoleBo role) {
|
||||
int rows = 1;
|
||||
// 新增角色与部门(数据权限)管理
|
||||
List<SysRoleDept> list = new ArrayList<SysRoleDept>();
|
||||
for (Long deptId : role.getDeptIds()) {
|
||||
SysRoleDept rd = new SysRoleDept();
|
||||
rd.setRoleId(role.getRoleId());
|
||||
rd.setDeptId(deptId);
|
||||
list.add(rd);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
rows = roleDeptMapper.insertBatch(list) ? list.size() : 0;
|
||||
}
|
||||
return rows;
|
||||
private void insertRoleDept(SysRoleBo role) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -325,12 +240,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteRoleById(Long roleId) {
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, roleId));
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().eq(SysRoleDept::getRoleId, roleId));
|
||||
return baseMapper.deleteById(roleId);
|
||||
public void deleteRoleById(Long roleId) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -341,21 +251,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteRoleByIds(Long[] roleIds) {
|
||||
for (Long roleId : roleIds) {
|
||||
checkRoleAllowed(roleId);
|
||||
checkRoleDataScope(roleId);
|
||||
SysRole role = baseMapper.selectById(roleId);
|
||||
if (countUserRoleByRoleId(roleId) > 0) {
|
||||
throw new BizException(String.format("%1$s已分配,不能删除", role.getRoleName()));
|
||||
}
|
||||
}
|
||||
List<Long> ids = Arrays.asList(roleIds);
|
||||
// 删除角色与菜单关联
|
||||
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, ids));
|
||||
// 删除角色与部门关联
|
||||
roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().in(SysRoleDept::getRoleId, ids));
|
||||
return baseMapper.deleteBatchIds(ids);
|
||||
public void deleteRoleByIds(Long[] roleIds) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -365,14 +261,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAuthUser(SysUserRole userRole) {
|
||||
int rows = userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>()
|
||||
.eq(SysUserRole::getRoleId, userRole.getRoleId())
|
||||
.eq(SysUserRole::getUserId, userRole.getUserId()));
|
||||
if (rows > 0) {
|
||||
cleanOnlineUserByRole(userRole.getRoleId());
|
||||
}
|
||||
return rows;
|
||||
public void deleteAuthUser(SysUserRole userRole) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -383,14 +272,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteAuthUsers(Long roleId, Long[] userIds) {
|
||||
int rows = userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>()
|
||||
.eq(SysUserRole::getRoleId, roleId)
|
||||
.in(SysUserRole::getUserId, Arrays.asList(userIds)));
|
||||
if (rows > 0) {
|
||||
cleanOnlineUserByRole(roleId);
|
||||
}
|
||||
return rows;
|
||||
public void deleteAuthUsers(Long roleId, Long[] userIds) {
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -401,44 +283,10 @@ public class SysRoleServiceImpl implements ISysRoleService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertAuthUsers(Long roleId, Long[] userIds) {
|
||||
// 新增用户与角色管理
|
||||
int rows = 1;
|
||||
List<SysUserRole> list = StreamUtils.toList(List.of(userIds), userId -> {
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userId);
|
||||
ur.setRoleId(roleId);
|
||||
return ur;
|
||||
});
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
rows = userRoleMapper.insertBatch(list) ? list.size() : 0;
|
||||
}
|
||||
if (rows > 0) {
|
||||
cleanOnlineUserByRole(roleId);
|
||||
}
|
||||
return rows;
|
||||
public void insertAuthUsers(Long roleId, Long[] userIds) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanOnlineUserByRole(Long roleId) {
|
||||
List<String> keys = StpUtil.searchTokenValue("", 0, -1, false);
|
||||
if (CollUtil.isEmpty(keys)) {
|
||||
return;
|
||||
}
|
||||
// 角色关联的在线用户量过大会导致redis阻塞卡顿 谨慎操作
|
||||
keys.parallelStream().forEach(key -> {
|
||||
String token = StringUtils.substringAfterLast(key, ":");
|
||||
// 如果已经过期则跳过
|
||||
if (StpUtil.stpLogic.getTokenActivityTimeoutByToken(token) < -1) {
|
||||
return;
|
||||
}
|
||||
LoginUser loginUser = LoginHelper.getLoginUser(token);
|
||||
if (loginUser.getRoles().stream().anyMatch(r -> r.getRoleId().equals(roleId))) {
|
||||
try {
|
||||
StpUtil.logoutByTokenValue(token);
|
||||
} catch (NotLoginException ignored) {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,23 +2,18 @@ package cc.iotkit.system.service.impl;
|
|||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.model.system.SysTenant;
|
||||
import cc.iotkit.data.system.ISysTenantPackageData;
|
||||
import cc.iotkit.model.system.SysTenantPackage;
|
||||
import cc.iotkit.system.dto.bo.SysTenantPackageBo;
|
||||
import cc.iotkit.system.dto.vo.SysTenantPackageVo;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cc.iotkit.system.service.ISysTenantPackageService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cc.iotkit.system.service.ISysTenantPackageService;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户套餐Service业务层处理
|
||||
|
@ -29,15 +24,14 @@ import java.util.Collection;
|
|||
@Service
|
||||
public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
|
||||
|
||||
private final SysTenantPackageMapper baseMapper;
|
||||
private final SysTenantMapper tenantMapper;
|
||||
private final ISysTenantPackageData sysTenantPackageData;
|
||||
|
||||
/**
|
||||
* 查询租户套餐
|
||||
*/
|
||||
@Override
|
||||
public SysTenantPackageVo queryById(Long packageId){
|
||||
return baseMapper.selectVoById(packageId);
|
||||
public SysTenantPackageVo queryById(Long packageId) {
|
||||
return sysTenantPackageData.findById(packageId).to(SysTenantPackageVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,15 +39,12 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
|
|||
*/
|
||||
@Override
|
||||
public Paging<SysTenantPackageVo> queryPageList(SysTenantPackageBo bo, PageRequest<?> query) {
|
||||
LambdaQueryWrapper<SysTenantPackage> lqw = buildQueryWrapper(bo);
|
||||
Page<SysTenantPackageVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
return new Paging<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysTenantPackageVo> selectList() {
|
||||
return baseMapper.selectVoList(new LambdaQueryWrapper<SysTenantPackage>()
|
||||
.eq(SysTenantPackage::getStatus, TenantConstants.NORMAL));
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,16 +52,7 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
|
|||
*/
|
||||
@Override
|
||||
public List<SysTenantPackageVo> queryList(SysTenantPackageBo bo) {
|
||||
LambdaQueryWrapper<SysTenantPackage> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SysTenantPackage> buildQueryWrapper(SysTenantPackageBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
LambdaQueryWrapper<SysTenantPackage> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getPackageName()), SysTenantPackage::getPackageName, bo.getPackageName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysTenantPackage::getStatus, bo.getStatus());
|
||||
return lqw;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -79,19 +61,7 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(SysTenantPackageBo bo) {
|
||||
SysTenantPackage add = MapstructUtils.convert(bo, SysTenantPackage.class);
|
||||
// 保存菜单id
|
||||
List<Long> menuIds = Arrays.asList(bo.getMenuIds());
|
||||
if (CollUtil.isNotEmpty(menuIds)) {
|
||||
add.setMenuIds(StringUtils.join(menuIds, ", "));
|
||||
} else {
|
||||
add.setMenuIds("");
|
||||
}
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setPackageId(add.getPackageId());
|
||||
}
|
||||
return flag;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -100,15 +70,7 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateByBo(SysTenantPackageBo bo) {
|
||||
SysTenantPackage update = MapstructUtils.convert(bo, SysTenantPackage.class);
|
||||
// 保存菜单id
|
||||
List<Long> menuIds = Arrays.asList(bo.getMenuIds());
|
||||
if (CollUtil.isNotEmpty(menuIds)) {
|
||||
update.setMenuIds(StringUtils.join(menuIds, ", "));
|
||||
} else {
|
||||
update.setMenuIds("");
|
||||
}
|
||||
return baseMapper.updateById(update) > 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,9 +80,8 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
|
|||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePackageStatus(SysTenantPackageBo bo) {
|
||||
SysTenantPackage tenantPackage = MapstructUtils.convert(bo, SysTenantPackage.class);
|
||||
return baseMapper.updateById(tenantPackage);
|
||||
public void updatePackageStatus(SysTenantPackageBo bo) {
|
||||
sysTenantPackageData.save(bo.to(SysTenantPackage.class));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -129,12 +90,6 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
boolean exists = tenantMapper.exists(new LambdaQueryWrapper<SysTenant>().in(SysTenant::getPackageId, ids));
|
||||
if (exists) {
|
||||
throw new BizException("租户套餐已被使用");
|
||||
}
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +1,15 @@
|
|||
package cc.iotkit.system.service.impl;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.CacheNames;
|
||||
import cc.iotkit.common.constant.Constants;
|
||||
import cc.iotkit.common.constant.TenantConstants;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.model.system.*;
|
||||
import cc.iotkit.system.dto.SysRoleDept;
|
||||
import cc.iotkit.system.dto.SysRoleMenu;
|
||||
import cc.iotkit.system.dto.SysUserRole;
|
||||
import cc.iotkit.data.system.ISysTenantData;
|
||||
import cc.iotkit.system.dto.bo.SysTenantBo;
|
||||
import cc.iotkit.system.dto.vo.SysTenantVo;
|
||||
import cc.iotkit.system.mapper.*;
|
||||
import cn.dev33.satoken.secure.BCrypt;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import cc.iotkit.system.service.ISysTenantService;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -40,327 +21,70 @@ import java.util.List;
|
|||
@Service
|
||||
public class SysTenantServiceImpl implements ISysTenantService {
|
||||
|
||||
private final SysTenantMapper baseMapper;
|
||||
private final SysTenantPackageMapper tenantPackageMapper;
|
||||
private final SysUserMapper userMapper;
|
||||
private final SysDeptMapper deptMapper;
|
||||
private final SysRoleMapper roleMapper;
|
||||
private final SysRoleMenuMapper roleMenuMapper;
|
||||
private final SysRoleDeptMapper roleDeptMapper;
|
||||
private final SysUserRoleMapper userRoleMapper;
|
||||
private final SysDictTypeMapper dictTypeMapper;
|
||||
private final SysDictDataMapper dictDataMapper;
|
||||
private final SysConfigMapper configMapper;
|
||||
private final ISysTenantData sysTenantData;
|
||||
|
||||
/**
|
||||
* 查询租户
|
||||
*/
|
||||
@Override
|
||||
public SysTenantVo queryById(Long id) {
|
||||
return baseMapper.selectVoById(id);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 基于租户ID查询租户
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_TENANT, key = "#tenantId")
|
||||
@Override
|
||||
public SysTenantVo queryByTenantId(String tenantId) {
|
||||
return baseMapper.selectVoOne(new LambdaQueryWrapper<SysTenant>().eq(SysTenant::getTenantId, tenantId));
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户列表
|
||||
*/
|
||||
@Override
|
||||
public Paging<SysTenantVo> queryPageList(SysTenantBo bo, PageRequest<?> query) {
|
||||
LambdaQueryWrapper<SysTenant> lqw = buildQueryWrapper(bo);
|
||||
Page<SysTenantVo> result = baseMapper.selectVoPage(query.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysTenantVo> queryList(SysTenantBo bo) {
|
||||
LambdaQueryWrapper<SysTenant> lqw = buildQueryWrapper(bo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
return null;
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<SysTenant> buildQueryWrapper(SysTenantBo bo) {
|
||||
LambdaQueryWrapper<SysTenant> lqw = Wrappers.lambdaQuery();
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getTenantId()), SysTenant::getTenantId, bo.getTenantId());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getContactUserName()), SysTenant::getContactUserName, bo.getContactUserName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getContactPhone()), SysTenant::getContactPhone, bo.getContactPhone());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getCompanyName()), SysTenant::getCompanyName, bo.getCompanyName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getLicenseNumber()), SysTenant::getLicenseNumber, bo.getLicenseNumber());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getAddress()), SysTenant::getAddress, bo.getAddress());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getIntro()), SysTenant::getIntro, bo.getIntro());
|
||||
lqw.like(StringUtils.isNotBlank(bo.getDomain()), SysTenant::getDomain, bo.getDomain());
|
||||
lqw.eq(bo.getPackageId() != null, SysTenant::getPackageId, bo.getPackageId());
|
||||
lqw.eq(bo.getExpireTime() != null, SysTenant::getExpireTime, bo.getExpireTime());
|
||||
lqw.eq(bo.getAccountCount() != null, SysTenant::getAccountCount, bo.getAccountCount());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysTenant::getStatus, bo.getStatus());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增租户
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean insertByBo(SysTenantBo bo) {
|
||||
SysTenant add = MapstructUtils.convert(bo, SysTenant.class);
|
||||
|
||||
// 获取所有租户编号
|
||||
List<String> tenantIds = baseMapper.selectObjs(
|
||||
new LambdaQueryWrapper<SysTenant>().select(SysTenant::getTenantId), Convert::toStr);
|
||||
String tenantId = generateTenantId(tenantIds);
|
||||
add.setTenantId(tenantId);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (!flag) {
|
||||
throw new BizException("创建租户失败");
|
||||
}
|
||||
bo.setId(add.getId());
|
||||
|
||||
// 根据套餐创建角色
|
||||
Long roleId = createTenantRole(tenantId, bo.getPackageId());
|
||||
|
||||
// 创建部门: 公司名是部门名称
|
||||
SysDept dept = new SysDept();
|
||||
dept.setTenantId(tenantId);
|
||||
dept.setDeptName(bo.getCompanyName());
|
||||
dept.setLeader(bo.getUsername());
|
||||
dept.setParentId(Constants.TOP_PARENT_ID);
|
||||
dept.setAncestors(Constants.TOP_PARENT_ID.toString());
|
||||
deptMapper.insert(dept);
|
||||
Long deptId = dept.getDeptId();
|
||||
|
||||
// 角色和部门关联表
|
||||
SysRoleDept roleDept = new SysRoleDept();
|
||||
roleDept.setRoleId(roleId);
|
||||
roleDept.setDeptId(deptId);
|
||||
roleDeptMapper.insert(roleDept);
|
||||
|
||||
// 创建系统用户
|
||||
SysUser user = new SysUser();
|
||||
user.setTenantId(tenantId);
|
||||
user.setUserName(bo.getUsername());
|
||||
user.setNickName(bo.getUsername());
|
||||
user.setPassword(BCrypt.hashpw(bo.getPassword()));
|
||||
user.setDeptId(deptId);
|
||||
userMapper.insert(user);
|
||||
|
||||
// 用户和角色关联表
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(user.getUserId());
|
||||
userRole.setRoleId(roleId);
|
||||
userRoleMapper.insert(userRole);
|
||||
|
||||
String defaultTenantId = TenantConstants.DEFAULT_TENANT_ID;
|
||||
List<SysDictType> dictTypeList = dictTypeMapper.selectList(
|
||||
new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getTenantId, defaultTenantId));
|
||||
List<SysDictData> dictDataList = dictDataMapper.selectList(
|
||||
new LambdaQueryWrapper<SysDictData>().eq(SysDictData::getTenantId, defaultTenantId));
|
||||
for (SysDictType dictType : dictTypeList) {
|
||||
dictType.setDictId(null);
|
||||
dictType.setTenantId(tenantId);
|
||||
}
|
||||
for (SysDictData dictData : dictDataList) {
|
||||
dictData.setDictCode(null);
|
||||
dictData.setTenantId(tenantId);
|
||||
}
|
||||
dictTypeMapper.insertBatch(dictTypeList);
|
||||
dictDataMapper.insertBatch(dictDataList);
|
||||
|
||||
List<SysConfig> sysConfigList = configMapper.selectList(
|
||||
new LambdaQueryWrapper<SysConfig>().eq(SysConfig::getTenantId, defaultTenantId));
|
||||
for (SysConfig config : sysConfigList) {
|
||||
config.setConfigId(null);
|
||||
config.setTenantId(tenantId);
|
||||
}
|
||||
configMapper.insertBatch(sysConfigList);
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成租户id
|
||||
*
|
||||
* @param tenantIds 已有租户id列表
|
||||
* @return 租户id
|
||||
*/
|
||||
private String generateTenantId(List<String> tenantIds) {
|
||||
// 随机生成6位
|
||||
String numbers = RandomUtil.randomNumbers(6);
|
||||
// 判断是否存在,如果存在则重新生成
|
||||
if (tenantIds.contains(numbers)) {
|
||||
generateTenantId(tenantIds);
|
||||
}
|
||||
return numbers;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据租户菜单创建租户角色
|
||||
*
|
||||
* @param tenantId 租户编号
|
||||
* @param packageId 租户套餐id
|
||||
* @return 角色id
|
||||
*/
|
||||
private Long createTenantRole(String tenantId, Long packageId) {
|
||||
// 获取租户套餐
|
||||
SysTenantPackage tenantPackage = tenantPackageMapper.selectById(packageId);
|
||||
if (ObjectUtil.isNull(tenantPackage)) {
|
||||
throw new BizException("套餐不存在");
|
||||
}
|
||||
// 获取套餐菜单id
|
||||
List<Long> menuIds = StringUtils.splitTo(tenantPackage.getMenuIds(), Convert::toLong);
|
||||
|
||||
// 创建角色
|
||||
SysRole role = new SysRole();
|
||||
role.setTenantId(tenantId);
|
||||
role.setRoleName(TenantConstants.TENANT_ADMIN_ROLE_NAME);
|
||||
role.setRoleKey(TenantConstants.TENANT_ADMIN_ROLE_KEY);
|
||||
role.setRoleSort(1);
|
||||
role.setStatus(TenantConstants.NORMAL);
|
||||
roleMapper.insert(role);
|
||||
Long roleId = role.getRoleId();
|
||||
|
||||
// 创建角色菜单
|
||||
List<SysRoleMenu> roleMenus = new ArrayList<>(menuIds.size());
|
||||
menuIds.forEach(menuId -> {
|
||||
SysRoleMenu roleMenu = new SysRoleMenu();
|
||||
roleMenu.setRoleId(roleId);
|
||||
roleMenu.setMenuId(menuId);
|
||||
roleMenus.add(roleMenu);
|
||||
});
|
||||
roleMenuMapper.insertBatch(roleMenus);
|
||||
|
||||
return roleId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租户
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_TENANT, key = "#bo.tenantId")
|
||||
@Override
|
||||
public Boolean updateByBo(SysTenantBo bo) {
|
||||
SysTenant tenant = MapstructUtils.convert(bo, SysTenant.class);
|
||||
tenant.setTenantId(null);
|
||||
tenant.setPackageId(null);
|
||||
return baseMapper.updateById(tenant) > 0;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租户状态
|
||||
*
|
||||
* @param bo 租户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_TENANT, key = "#bo.tenantId")
|
||||
@Override
|
||||
public int updateTenantStatus(SysTenantBo bo) {
|
||||
SysTenant tenant = MapstructUtils.convert(bo, SysTenant.class);
|
||||
return baseMapper.updateById(tenant);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验租户是否允许操作
|
||||
*
|
||||
* @param tenantId 租户ID
|
||||
*/
|
||||
@Override
|
||||
public void checkTenantAllowed(String tenantId) {
|
||||
if (ObjectUtil.isNotNull(tenantId) && TenantConstants.DEFAULT_TENANT_ID.equals(tenantId)) {
|
||||
throw new ServiceException("不允许操作管理租户");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除租户
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_TENANT, allEntries = true)
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
// 做一些业务上的校验,判断是否需要校验
|
||||
if (ids.contains(TenantConstants.SUPER_ADMIN_ID)) {
|
||||
throw new ServiceException("超管租户不能删除");
|
||||
}
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验企业名称是否唯一
|
||||
*/
|
||||
@Override
|
||||
public boolean checkCompanyNameUnique(SysTenantBo bo) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysTenant>()
|
||||
.eq(SysTenant::getCompanyName, bo.getCompanyName())
|
||||
.ne(ObjectUtil.isNotNull(bo.getTenantId()), SysTenant::getTenantId, bo.getTenantId()));
|
||||
return !exist;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验账号余额
|
||||
*/
|
||||
@Override
|
||||
public boolean checkAccountBalance(String tenantId) {
|
||||
SysTenantVo tenant = SpringUtils.getAopProxy(this).queryByTenantId(tenantId);
|
||||
// 如果余额为-1代表不限制
|
||||
if (tenant.getAccountCount() == -1) {
|
||||
return true;
|
||||
}
|
||||
Long userNumber = userMapper.selectCount(new LambdaQueryWrapper<>());
|
||||
// 如果余额大于0代表还有可用名额
|
||||
return tenant.getAccountCount() - userNumber > 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验有效期
|
||||
*/
|
||||
@Override
|
||||
public boolean checkExpireTime(String tenantId) {
|
||||
SysTenantVo tenant = SpringUtils.getAopProxy(this).queryByTenantId(tenantId);
|
||||
// 如果未设置过期时间代表不限制
|
||||
if (ObjectUtil.isNull(tenant.getExpireTime())) {
|
||||
return true;
|
||||
}
|
||||
// 如果当前时间在过期时间之前则通过
|
||||
return new Date().before(tenant.getExpireTime());
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步租户套餐
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean syncTenantPackage(String tenantId, String packageId) {
|
||||
SysTenantPackage tenantPackage = tenantPackageMapper.selectById(packageId);
|
||||
List<SysRole> roles = roleMapper.selectList(
|
||||
new LambdaQueryWrapper<SysRole>().eq(SysRole::getTenantId, tenantId));
|
||||
List<Long> roleIds = new ArrayList<>(roles.size() - 1);
|
||||
List<Long> menuIds = StringUtils.splitTo(tenantPackage.getMenuIds(), Convert::toLong);
|
||||
roles.forEach(item -> {
|
||||
if (TenantConstants.TENANT_ADMIN_ROLE_KEY.equals(item.getRoleKey())) {
|
||||
List<SysRoleMenu> roleMenus = new ArrayList<>(menuIds.size());
|
||||
menuIds.forEach(menuId -> {
|
||||
SysRoleMenu roleMenu = new SysRoleMenu();
|
||||
roleMenu.setRoleId(item.getRoleId());
|
||||
roleMenu.setMenuId(menuId);
|
||||
roleMenus.add(roleMenu);
|
||||
});
|
||||
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().eq(SysRoleMenu::getRoleId, item.getRoleId()));
|
||||
roleMenuMapper.insertBatch(roleMenus);
|
||||
} else {
|
||||
roleIds.add(item.getRoleId());
|
||||
}
|
||||
});
|
||||
if (!roleIds.isEmpty()) {
|
||||
roleMenuMapper.delete(
|
||||
new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, roleIds).notIn(!menuIds.isEmpty(), SysRoleMenu::getMenuId, menuIds));
|
||||
}
|
||||
return true;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,36 +1,16 @@
|
|||
package cc.iotkit.system.service.impl;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.CacheNames;
|
||||
import cc.iotkit.common.constant.UserConstants;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.satoken.utils.LoginHelper;
|
||||
import cc.iotkit.common.service.UserService;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.StreamUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.model.system.SysDept;
|
||||
import cc.iotkit.model.system.SysUser;
|
||||
import cc.iotkit.system.dto.SysUserPost;
|
||||
import cc.iotkit.system.dto.SysUserRole;
|
||||
import cc.iotkit.system.dto.bo.SysUserBo;
|
||||
import cc.iotkit.system.dto.vo.SysPostVo;
|
||||
import cc.iotkit.system.dto.vo.SysRoleVo;
|
||||
import cc.iotkit.system.dto.vo.SysUserVo;
|
||||
import cc.iotkit.system.mapper.*;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cc.iotkit.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import cc.iotkit.system.service.ISysUserService;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户 业务层处理
|
||||
|
@ -42,475 +22,128 @@ import java.util.Map;
|
|||
@Service
|
||||
public class SysUserServiceImpl implements ISysUserService, UserService {
|
||||
|
||||
private final SysUserMapper baseMapper;
|
||||
private final SysDeptMapper deptMapper;
|
||||
private final SysRoleMapper roleMapper;
|
||||
private final SysPostMapper postMapper;
|
||||
private final SysUserRoleMapper userRoleMapper;
|
||||
private final SysUserPostMapper userPostMapper;
|
||||
@Override
|
||||
public String selectUserNameById(Long userId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paging<SysUserVo> selectPageUserList(SysUserBo user, PageRequest<?> query) {
|
||||
Page<SysUserVo> page = baseMapper.selectPageUserList(query.build(), this.buildQueryWrapper(user));
|
||||
return TableDataInfo.build(page);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询用户列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysUserVo> selectUserList(SysUserBo user) {
|
||||
return baseMapper.selectUserList(this.buildQueryWrapper(user));
|
||||
return null;
|
||||
}
|
||||
|
||||
private Wrapper<SysUser> buildQueryWrapper(SysUserBo user) {
|
||||
Map<String, Object> params = user.getParams();
|
||||
QueryWrapper<SysUser> wrapper = Wrappers.query();
|
||||
wrapper.eq("u.del_flag", UserConstants.USER_NORMAL)
|
||||
.eq(ObjectUtil.isNotNull(user.getUserId()), "u.user_id", user.getUserId())
|
||||
.like(StringUtils.isNotBlank(user.getUserName()), "u.user_name", user.getUserName())
|
||||
.eq(StringUtils.isNotBlank(user.getStatus()), "u.status", user.getStatus())
|
||||
.like(StringUtils.isNotBlank(user.getPhonenumber()), "u.phonenumber", user.getPhonenumber())
|
||||
.between(params.get("beginTime") != null && params.get("endTime") != null,
|
||||
"u.create_time", params.get("beginTime"), params.get("endTime"))
|
||||
.and(ObjectUtil.isNotNull(user.getDeptId()), w -> {
|
||||
List<SysDept> deptList = deptMapper.selectList(new LambdaQueryWrapper<SysDept>()
|
||||
.select(SysDept::getDeptId)
|
||||
.apply(DataBaseHelper.findInSet(user.getDeptId(), "ancestors")));
|
||||
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
|
||||
ids.add(user.getDeptId());
|
||||
w.in("u.dept_id", ids);
|
||||
});
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询已分配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
public Paging<SysUserVo> selectAllocatedList(SysUserBo user, PageRequest<?> query) {
|
||||
QueryWrapper<SysUser> wrapper = Wrappers.query();
|
||||
wrapper.eq("u.del_flag", UserConstants.USER_NORMAL)
|
||||
.eq(ObjectUtil.isNotNull(user.getRoleId()), "r.role_id", user.getRoleId())
|
||||
.like(StringUtils.isNotBlank(user.getUserName()), "u.user_name", user.getUserName())
|
||||
.eq(StringUtils.isNotBlank(user.getStatus()), "u.status", user.getStatus())
|
||||
.like(StringUtils.isNotBlank(user.getPhonenumber()), "u.phonenumber", user.getPhonenumber());
|
||||
Page<SysUserVo> page = baseMapper.selectAllocatedList(query.build(), wrapper);
|
||||
return TableDataInfo.build(page);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据条件分页查询未分配用户角色列表
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
public Paging<SysUserVo> selectUnallocatedList(SysUserBo user, PageRequest<?> query) {
|
||||
List<Long> userIds = userRoleMapper.selectUserIdsByRoleId(user.getRoleId());
|
||||
QueryWrapper<SysUser> wrapper = Wrappers.query();
|
||||
wrapper.eq("u.del_flag", UserConstants.USER_NORMAL)
|
||||
.and(w -> w.ne("r.role_id", user.getRoleId()).or().isNull("r.role_id"))
|
||||
.notIn(CollUtil.isNotEmpty(userIds), "u.user_id", userIds)
|
||||
.like(StringUtils.isNotBlank(user.getUserName()), "u.user_name", user.getUserName())
|
||||
.like(StringUtils.isNotBlank(user.getPhonenumber()), "u.phonenumber", user.getPhonenumber());
|
||||
Page<SysUserVo> page = baseMapper.selectUnallocatedList(query.build(), wrapper);
|
||||
return TableDataInfo.build(page);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户名查询用户
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUserVo selectUserByUserName(String userName) {
|
||||
return baseMapper.selectUserByUserName(userName);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过手机号查询用户
|
||||
*
|
||||
* @param phonenumber 手机号
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUserVo selectUserByPhonenumber(String phonenumber) {
|
||||
return baseMapper.selectUserByPhonenumber(phonenumber);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
@Override
|
||||
public SysUserVo selectUserById(Long userId) {
|
||||
return baseMapper.selectUserById(userId);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户所属角色组
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String selectUserRoleGroup(String userName) {
|
||||
List<SysRoleVo> list = roleMapper.selectRolesByUserName(userName);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return StreamUtils.join(list, SysRoleVo::getRoleName);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户所属岗位组
|
||||
*
|
||||
* @param userName 用户名
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public String selectUserPostGroup(String userName) {
|
||||
List<SysPostVo> list = postMapper.selectPostsByUserName(userName);
|
||||
if (CollUtil.isEmpty(list)) {
|
||||
return StringUtils.EMPTY;
|
||||
}
|
||||
return StreamUtils.join(list, SysPostVo::getPostName);
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户名称是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean checkUserNameUnique(SysUserBo user) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getUserName, user.getUserName())
|
||||
.ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId()));
|
||||
return !exist;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验手机号码是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
@Override
|
||||
public boolean checkPhoneUnique(SysUserBo user) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getPhonenumber, user.getPhonenumber())
|
||||
.ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId()));
|
||||
return !exist;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验email是否唯一
|
||||
*
|
||||
* @param user 用户信息
|
||||
*/
|
||||
@Override
|
||||
public boolean checkEmailUnique(SysUserBo user) {
|
||||
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getEmail, user.getEmail())
|
||||
.ne(ObjectUtil.isNotNull(user.getUserId()), SysUser::getUserId, user.getUserId()));
|
||||
return !exist;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否允许操作
|
||||
*
|
||||
* @param userId 用户ID
|
||||
*/
|
||||
@Override
|
||||
public void checkUserAllowed(Long userId) {
|
||||
if (ObjectUtil.isNotNull(userId) && LoginHelper.isSuperAdmin(userId)) {
|
||||
throw new BizException("不允许操作超级管理员用户");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验用户是否有数据权限
|
||||
*
|
||||
* @param userId 用户id
|
||||
*/
|
||||
@Override
|
||||
public void checkUserDataScope(Long userId) {
|
||||
if (ObjectUtil.isNull(userId)) {
|
||||
return;
|
||||
}
|
||||
if (LoginHelper.isSuperAdmin()) {
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isNull(baseMapper.selectUserById(userId))) {
|
||||
throw new BizException("没有权限访问用户数据!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增保存用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertUser(SysUserBo user) {
|
||||
SysUser sysUser = MapstructUtils.convert(user, SysUser.class);
|
||||
// 新增用户信息
|
||||
int rows = baseMapper.insert(sysUser);
|
||||
user.setUserId(sysUser.getUserId());
|
||||
// 新增用户岗位关联
|
||||
insertUserPost(user, false);
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user, false);
|
||||
return rows;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean registerUser(SysUserBo user, String tenantId) {
|
||||
user.setCreateBy(user.getUserId());
|
||||
user.setUpdateBy(user.getUserId());
|
||||
SysUser sysUser = MapstructUtils.convert(user, SysUser.class);
|
||||
sysUser.setTenantId(tenantId);
|
||||
return baseMapper.insert(sysUser) > 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改保存用户信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int updateUser(SysUserBo user) {
|
||||
// 新增用户与角色管理
|
||||
insertUserRole(user, true);
|
||||
// 新增用户与岗位管理
|
||||
insertUserPost(user, true);
|
||||
SysUser sysUser = MapstructUtils.convert(user, SysUser.class);
|
||||
// 防止错误更新后导致的数据误删除
|
||||
int flag = baseMapper.updateById(sysUser);
|
||||
if (flag < 1) {
|
||||
throw new BizException("修改用户" + user.getUserName() + "信息失败");
|
||||
}
|
||||
return flag;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户授权角色
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param roleIds 角色组
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void insertUserAuth(Long userId, Long[] roleIds) {
|
||||
insertUserRole(userId, roleIds, true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户状态
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param status 帐号状态
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserStatus(Long userId, String status) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(SysUser::getStatus, status)
|
||||
.eq(SysUser::getUserId, userId));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户基本信息
|
||||
*
|
||||
* @param user 用户信息
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateUserProfile(SysUserBo user) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(ObjectUtil.isNotNull(user.getNickName()), SysUser::getNickName, user.getNickName())
|
||||
.set(SysUser::getPhonenumber, user.getPhonenumber())
|
||||
.set(SysUser::getEmail, user.getEmail())
|
||||
.set(SysUser::getSex, user.getSex())
|
||||
.eq(SysUser::getUserId, user.getUserId()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户头像
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param avatar 头像地址
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public boolean updateUserAvatar(Long userId, Long avatar) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(SysUser::getAvatar, avatar)
|
||||
.eq(SysUser::getUserId, userId)) > 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置用户密码
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param password 密码
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int resetUserPwd(Long userId, String password) {
|
||||
return baseMapper.update(null,
|
||||
new LambdaUpdateWrapper<SysUser>()
|
||||
.set(SysUser::getPassword, password)
|
||||
.eq(SysUser::getUserId, userId));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户角色信息
|
||||
*
|
||||
* @param user 用户对象
|
||||
* @param clear 清除已存在的关联数据
|
||||
*/
|
||||
private void insertUserRole(SysUserBo user, boolean clear) {
|
||||
this.insertUserRole(user.getUserId(), user.getRoleIds(), clear);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户岗位信息
|
||||
*
|
||||
* @param user 用户对象
|
||||
* @param clear 清除已存在的关联数据
|
||||
*/
|
||||
private void insertUserPost(SysUserBo user, boolean clear) {
|
||||
Long[] posts = user.getPostIds();
|
||||
if (ArrayUtil.isNotEmpty(posts)) {
|
||||
if (clear) {
|
||||
// 删除用户与岗位关联
|
||||
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId, user.getUserId()));
|
||||
}
|
||||
// 新增用户与岗位管理
|
||||
List<SysUserPost> list = StreamUtils.toList(List.of(posts), postId -> {
|
||||
SysUserPost up = new SysUserPost();
|
||||
up.setUserId(user.getUserId());
|
||||
up.setPostId(postId);
|
||||
return up;
|
||||
});
|
||||
userPostMapper.insertBatch(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户角色信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @param roleIds 角色组
|
||||
* @param clear 清除已存在的关联数据
|
||||
*/
|
||||
private void insertUserRole(Long userId, Long[] roleIds, boolean clear) {
|
||||
if (ArrayUtil.isNotEmpty(roleIds)) {
|
||||
// 判断是否具有此角色的操作权限
|
||||
List<SysRoleVo> roles = roleMapper.selectRoleList(new LambdaQueryWrapper<>());
|
||||
if (CollUtil.isEmpty(roles)) {
|
||||
throw new BizException("没有权限访问角色的数据");
|
||||
}
|
||||
List<Long> roleList = StreamUtils.toList(roles, SysRoleVo::getRoleId);
|
||||
if (!LoginHelper.isSuperAdmin(userId)) {
|
||||
roleList.remove(UserConstants.SUPER_ADMIN_ID);
|
||||
}
|
||||
List<Long> canDoRoleList = StreamUtils.filter(List.of(roleIds), roleList::contains);
|
||||
if (CollUtil.isEmpty(canDoRoleList)) {
|
||||
throw new BizException("没有权限访问角色的数据");
|
||||
}
|
||||
if (clear) {
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
|
||||
}
|
||||
// 新增用户与角色管理
|
||||
List<SysUserRole> list = StreamUtils.toList(canDoRoleList, roleId -> {
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(userId);
|
||||
ur.setRoleId(roleId);
|
||||
return ur;
|
||||
});
|
||||
userRoleMapper.insertBatch(list);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID删除用户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteUserById(Long userId) {
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
|
||||
// 删除用户与岗位表
|
||||
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().eq(SysUserPost::getUserId, userId));
|
||||
// 防止更新失败导致的数据删除
|
||||
int flag = baseMapper.deleteById(userId);
|
||||
if (flag < 1) {
|
||||
throw new BizException("删除用户失败!");
|
||||
}
|
||||
return flag;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除用户信息
|
||||
*
|
||||
* @param userIds 需要删除的用户ID
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int deleteUserByIds(Long[] userIds) {
|
||||
for (Long userId : userIds) {
|
||||
checkUserAllowed(userId);
|
||||
checkUserDataScope(userId);
|
||||
}
|
||||
List<Long> ids = List.of(userIds);
|
||||
// 删除用户与角色关联
|
||||
userRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, ids));
|
||||
// 删除用户与岗位表
|
||||
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().in(SysUserPost::getUserId, ids));
|
||||
// 防止更新失败导致的数据删除
|
||||
int flag = baseMapper.deleteBatchIds(ids);
|
||||
if (flag < 1) {
|
||||
throw new BizException("删除用户失败!");
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
@Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId")
|
||||
@Override
|
||||
public String selectUserNameById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getUserName).eq(SysUser::getUserId, userId));
|
||||
return ObjectUtil.isNull(sysUser) ? null : sysUser.getUserName();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue