refactor:数据字典等实现修改

V0.5.x
xiwa 2023-05-26 02:19:02 +08:00
parent d54f520d98
commit 783eac5c45
32 changed files with 161 additions and 289 deletions

View File

@ -14,11 +14,15 @@ import java.util.List;
*/
public interface ISysDictData extends ICommonData<SysDictData, Long> {
/**
*
*/
List<SysDictData> findByConditions(SysDictData query);
/**
*
*/
Paging<SysDictData> findByConditions(String dictType, String dictValue,
String status, int page, int size);
Paging<SysDictData> findByConditions(SysDictData query, int page, int size);
/**
*
@ -37,4 +41,12 @@ public interface ISysDictData extends ICommonData<SysDictData, Long> {
*/
List<SysDictType> findByDicType(String dictType);
/**
*
*
* @param dictType
* @return
*/
long countByDicType(String dictType);
}

View File

@ -4,6 +4,8 @@ import cc.iotkit.data.ICommonData;
import cc.iotkit.common.api.Paging;
import cc.iotkit.model.system.SysDictType;
import java.util.List;
/**
*
*
@ -11,11 +13,15 @@ import cc.iotkit.model.system.SysDictType;
*/
public interface ISysDictTypeData extends ICommonData<SysDictType, Long> {
/**
*
*/
List<SysDictType> findByConditions(SysDictType cond);
/**
*
*/
Paging<SysDictType> findByConditions(String dictName, String dictType,
String status, int page, int size);
Paging<SysDictType> findByConditions(SysDictType cond, int page, int size);
/**
*
@ -25,4 +31,12 @@ public interface ISysDictTypeData extends ICommonData<SysDictType, Long> {
*/
SysDictType findByDicType(String dictType);
/**
*
*
* @param dictType
* @param newType
*/
void updateDicType(String dictType, String newType);
}

View File

@ -4,6 +4,8 @@ import cc.iotkit.data.ICommonData;
import cc.iotkit.common.api.Paging;
import cc.iotkit.model.system.SysLogininfor;
import java.util.List;
/**
*
*
@ -11,11 +13,15 @@ import cc.iotkit.model.system.SysLogininfor;
*/
public interface ISysLogininforData extends ICommonData<SysLogininfor, Long> {
/**
*
*/
List<SysLogininfor> findByConditions(SysLogininfor cond);
/**
*
*/
Paging<SysLogininfor> findByConditions(String tenantId, String userName,
String status, int page, int size);
Paging<SysLogininfor> findByConditions(SysLogininfor cond, int page, int size);
/**
*
@ -24,4 +30,8 @@ public interface ISysLogininforData extends ICommonData<SysLogininfor, Long> {
*/
void deleteByTenantId(String tenantId);
/**
*
*/
void deleteAll();
}

View File

@ -8,7 +8,6 @@ import cc.iotkit.common.api.Paging;
import cc.iotkit.model.system.SysConfig;
import java.util.List;
import io.github.linpeilie.Converter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
@ -68,4 +67,9 @@ public class SysConfigDataImpl implements ISysConfigData {
public Paging<SysConfig> findConfigs(SysConfig query) {
return null;
}
@Override
public SysConfig findByConfigKey(String configKey) {
return null;
}
}

View File

@ -12,8 +12,6 @@ import cn.hutool.core.lang.Dict;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.ttl.TransmittableThreadLocal;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.time.StopWatch;
import org.aspectj.lang.JoinPoint;
@ -26,6 +24,8 @@ import org.springframework.http.HttpMethod;
import org.springframework.validation.BindingResult;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Collection;
import java.util.Map;

View File

@ -1,9 +1,8 @@
package cc.iotkit.common.log.event;
import cn.hutool.http.useragent.UserAgent;
import lombok.Data;
import jakarta.servlet.http.HttpServletRequest;
import java.io.Serializable;
/**
@ -37,9 +36,14 @@ public class LogininforEvent implements Serializable {
private String message;
/**
*
* ip
*/
private HttpServletRequest request;
private String ip;
/**
* user-agent
*/
private UserAgent userAgent;
/**
*

View File

@ -10,11 +10,11 @@ import cc.iotkit.system.dto.bo.SysConfigBo;
import cc.iotkit.system.dto.vo.SysConfigVo;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cc.iotkit.system.service.ISysConfigService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**

View File

@ -11,11 +11,11 @@ import cc.iotkit.system.service.ISysDictDataService;
import cc.iotkit.system.service.ISysDictTypeService;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.util.ObjectUtil;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

View File

@ -10,11 +10,11 @@ import cc.iotkit.system.dto.bo.SysDictTypeBo;
import cc.iotkit.system.dto.vo.SysDictTypeVo;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cc.iotkit.system.service.ISysDictTypeService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**

View File

@ -13,7 +13,6 @@ import cc.iotkit.system.dto.vo.SysOssVo;
import cc.iotkit.system.service.ISysOssService;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.hutool.core.util.ObjectUtil;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
@ -21,6 +20,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;

View File

@ -10,11 +10,11 @@ import cc.iotkit.system.dto.bo.SysPostBo;
import cc.iotkit.system.dto.vo.SysPostVo;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cc.iotkit.system.service.ISysPostService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**

View File

@ -17,11 +17,11 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
import cc.iotkit.system.service.ISysDeptService;
import cc.iotkit.system.service.ISysRoleService;
import cc.iotkit.system.service.ISysUserService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**

View File

@ -6,7 +6,6 @@ import cc.iotkit.common.api.Paging;
import cc.iotkit.common.excel.utils.ExcelUtil;
import cc.iotkit.common.log.annotation.Log;
import cc.iotkit.common.log.enums.BusinessType;
import cc.iotkit.common.tenant.helper.TenantHelper;
import cc.iotkit.common.validate.AddGroup;
import cc.iotkit.common.validate.EditGroup;
import cc.iotkit.common.web.core.BaseController;
@ -15,7 +14,6 @@ import cc.iotkit.system.dto.vo.SysTenantVo;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole;
import com.baomidou.lock.annotation.Lock4j;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
@ -31,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**

View File

@ -14,13 +14,13 @@ import cc.iotkit.system.dto.vo.SysTenantPackageVo;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.annotation.SaCheckRole;
import cc.iotkit.system.service.ISysTenantPackageService;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**

View File

@ -22,7 +22,6 @@ import cn.dev33.satoken.secure.BCrypt;
import cn.hutool.core.lang.tree.Tree;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.ObjectUtil;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import cc.iotkit.system.listener.SysUserImportListener;
import org.springframework.http.MediaType;
@ -30,6 +29,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

View File

@ -26,7 +26,7 @@ public class SysDictDataBo extends BaseDto {
*
*/
@NotNull(message = "字典编码不能为空", groups = { EditGroup.class })
private Long dictCode;
private Long id;
/**
*

View File

@ -27,7 +27,7 @@ public class SysDictTypeBo extends BaseDto {
*
*/
@NotNull(message = "字典主键不能为空", groups = { EditGroup.class })
private Long dictId;
private Long id;
/**
*

View File

@ -21,7 +21,7 @@ public class SysLogininforBo {
/**
* 访ID
*/
private Long infoId;
private Long id;
/**
*

View File

@ -27,7 +27,7 @@ public class SysDictDataVo implements Serializable {
*
*/
@ExcelProperty(value = "字典编码")
private Long dictCode;
private Long id;
/**
*

View File

@ -27,7 +27,7 @@ public class SysDictTypeVo implements Serializable {
*
*/
@ExcelProperty(value = "字典主键")
private Long dictId;
private Long id;
/**
*

View File

@ -1,40 +0,0 @@
package cc.iotkit.system.mapper;
import cc.iotkit.model.system.SysDept;
import cc.iotkit.system.dto.vo.SysDeptVo;
import java.util.List;
/**
*
*
* @author Lion Li
*/
public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
/**
*
*
* @param queryWrapper
* @return
*/
@DataPermission({
@DataColumn(key = "deptName", value = "dept_id")
})
List<SysDeptVo> selectDeptList(@Param(Constants.WRAPPER) Wrapper<SysDept> queryWrapper);
@DataPermission({
@DataColumn(key = "deptName", value = "dept_id")
})
SysDeptVo selectDeptById(Long deptId);
/**
* ID
*
* @param roleId ID
* @param deptCheckStrictly
* @return
*/
List<Long> selectDeptListByRoleId(@Param("roleId") Long roleId, @Param("deptCheckStrictly") boolean deptCheckStrictly);
}

View File

@ -1,23 +0,0 @@
package cc.iotkit.system.mapper;
import cc.iotkit.common.constant.UserConstants;
import cc.iotkit.model.system.SysDictData;
import cc.iotkit.system.dto.vo.SysDictDataVo;
import java.util.List;
/**
*
*
* @author Lion Li
*/
public interface SysDictDataMapper extends BaseMapperPlus<SysDictData, SysDictDataVo> {
default List<SysDictDataVo> selectDictDataByType(String dictType) {
return selectVoList(
new LambdaQueryWrapper<SysDictData>()
.eq(SysDictData::getStatus, UserConstants.DICT_NORMAL)
.eq(SysDictData::getDictType, dictType)
.orderByAsc(SysDictData::getDictSort));
}
}

View File

@ -1,30 +0,0 @@
package cc.iotkit.system.mapper;
import cc.iotkit.system.dto.vo.SysPostVo;
import java.util.List;
/**
*
*
* @author Lion Li
*/
public interface SysPostMapper extends BaseMapperPlus<SysPost, SysPostVo> {
/**
* ID
*
* @param userId ID
* @return ID
*/
List<Long> selectPostListByUserId(Long userId);
/**
*
*
* @param userName
* @return
*/
List<SysPostVo> selectPostsByUserName(String userName);
}

View File

@ -38,7 +38,7 @@ public interface ISysLogininforService {
* @param infoIds ID
* @return
*/
int deleteLogininforByIds(Long[] infoIds);
void deleteLogininforByIds(Long[] infoIds);
/**
*

View File

@ -4,9 +4,9 @@ import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.system.dto.bo.SysOssBo;
import cc.iotkit.system.dto.vo.SysOssVo;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Collection;
import java.util.List;

View File

@ -1,11 +1,5 @@
package cc.iotkit.system.service.impl;
import cc.iotkit.common.utils.StreamUtils;
import cc.iotkit.model.system.SysDept;
import cc.iotkit.system.dto.SysRoleDept;
import cc.iotkit.system.mapper.SysDeptMapper;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

View File

@ -4,13 +4,11 @@ import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.constant.CacheNames;
import cc.iotkit.common.exception.BizException;
import cc.iotkit.common.redis.utils.CacheUtils;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.data.system.ISysDictData;
import cc.iotkit.model.system.SysDictData;
import cc.iotkit.system.dto.bo.SysDictDataBo;
import cc.iotkit.system.dto.vo.SysDictDataVo;
import cc.iotkit.system.mapper.SysDictDataMapper;
import cc.iotkit.system.service.ISysDictDataService;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CachePut;
@ -27,13 +25,16 @@ import java.util.List;
@Service
public class SysDictDataServiceImpl implements ISysDictDataService {
private final SysDictDataMapper baseMapper;
private final ISysDictData sysDictData;
@Override
public Paging<SysDictDataVo> selectPageDictDataList(SysDictDataBo dictData, PageRequest<?> query) {
LambdaQueryWrapper<SysDictData> lqw = buildQueryWrapper(dictData);
Page<SysDictDataVo> page = baseMapper.selectVoPage(query.build(), lqw);
return TableDataInfo.build(page);
return MapstructUtils.convert(
sysDictData.findByConditions(
MapstructUtils.convert(dictData, SysDictData.class),
query.getPageNum(),
query.getPageSize()
), SysDictDataVo.class);
}
/**
@ -44,18 +45,10 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
*/
@Override
public List<SysDictDataVo> selectDictDataList(SysDictDataBo dictData) {
LambdaQueryWrapper<SysDictData> lqw = buildQueryWrapper(dictData);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<SysDictData> buildQueryWrapper(SysDictDataBo bo) {
LambdaQueryWrapper<SysDictData> lqw = Wrappers.lambdaQuery();
lqw.eq(bo.getDictSort() != null, SysDictData::getDictSort, bo.getDictSort());
lqw.like(StringUtils.isNotBlank(bo.getDictLabel()), SysDictData::getDictLabel, bo.getDictLabel());
lqw.eq(StringUtils.isNotBlank(bo.getDictType()), SysDictData::getDictType, bo.getDictType());
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDictData::getStatus, bo.getStatus());
lqw.orderByAsc(SysDictData::getDictSort);
return lqw;
return MapstructUtils.convert(
sysDictData.findByConditions(
MapstructUtils.convert(dictData, SysDictData.class)
), SysDictDataVo.class);
}
/**
@ -67,11 +60,7 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
*/
@Override
public String selectDictLabel(String dictType, String dictValue) {
return baseMapper.selectOne(new LambdaQueryWrapper<SysDictData>()
.select(SysDictData::getDictLabel)
.eq(SysDictData::getDictType, dictType)
.eq(SysDictData::getDictValue, dictValue))
.getDictLabel();
return sysDictData.findByDictTypeAndDictValue(dictType, dictValue).getDictLabel();
}
/**
@ -82,7 +71,7 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
*/
@Override
public SysDictDataVo selectDictDataById(Long dictCode) {
return baseMapper.selectVoById(dictCode);
return MapstructUtils.convert(sysDictData.findById(dictCode), SysDictDataVo.class);
}
/**
@ -93,9 +82,9 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
@Override
public void deleteDictDataByIds(Long[] dictCodes) {
for (Long dictCode : dictCodes) {
SysDictData data = baseMapper.selectById(dictCode);
baseMapper.deleteById(dictCode);
CacheUtils.evict(CacheNames.SYS_DICT, data.getDictType());
SysDictData data = sysDictData.findById(dictCode);
sysDictData.deleteById(dictCode);
// CacheUtils.evict(CacheNames.SYS_DICT, data.getDictType());
}
}
@ -109,11 +98,8 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
@Override
public List<SysDictDataVo> insertDictData(SysDictDataBo bo) {
SysDictData data = MapstructUtils.convert(bo, SysDictData.class);
int row = baseMapper.insert(data);
if (row > 0) {
return baseMapper.selectDictDataByType(data.getDictType());
}
throw new BizException("操作失败");
sysDictData.save(data);
return MapstructUtils.convert(sysDictData.findByDicType(data.getDictType()), SysDictDataVo.class);
}
/**
@ -122,15 +108,12 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
* @param bo
* @return
*/
@CachePut(cacheNames = CacheNames.SYS_DICT, key = "#bo.dictType")
// @CachePut(cacheNames = CacheNames.SYS_DICT, key = "#bo.dictType")
@Override
public List<SysDictDataVo> updateDictData(SysDictDataBo bo) {
SysDictData data = MapstructUtils.convert(bo, SysDictData.class);
int row = baseMapper.updateById(data);
if (row > 0) {
return baseMapper.selectDictDataByType(data.getDictType());
}
throw new BizException("操作失败");
sysDictData.save(data);
return MapstructUtils.convert(sysDictData.findByDicType(data.getDictType()), SysDictDataVo.class);
}
}

View File

@ -1,9 +1,9 @@
package cc.iotkit.system.service.impl;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.constant.CacheConstants;
import cc.iotkit.common.constant.CacheNames;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.exception.BizException;
import cc.iotkit.common.redis.utils.CacheUtils;
import cc.iotkit.common.service.DictService;
@ -11,21 +11,17 @@ 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.model.system.SysDictData;
import cc.iotkit.data.system.ISysDictData;
import cc.iotkit.data.system.ISysDictTypeData;
import cc.iotkit.model.system.SysDictType;
import cc.iotkit.system.dto.bo.SysDictTypeBo;
import cc.iotkit.system.dto.vo.SysDictDataVo;
import cc.iotkit.system.dto.vo.SysDictTypeVo;
import cc.iotkit.system.mapper.SysDictDataMapper;
import cn.dev33.satoken.context.SaHolder;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cc.iotkit.system.service.ISysDictTypeService;
import cn.dev33.satoken.context.SaHolder;
import cn.hutool.core.util.ObjectUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
@ -42,14 +38,16 @@ import java.util.stream.Collectors;
@Service
public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService {
private final SysDictTypeMapper baseMapper;
private final SysDictDataMapper dictDataMapper;
private final ISysDictTypeData sysDictTypeData;
private final ISysDictData sysDictData;
@Override
public Paging<SysDictTypeVo> selectPageDictTypeList(SysDictTypeBo dictType, PageRequest<?> pageQuery) {
LambdaQueryWrapper<SysDictType> lqw = buildQueryWrapper(dictType);
Page<SysDictTypeVo> page = baseMapper.selectVoPage(query.build(), lqw);
return TableDataInfo.build(page);
public Paging<SysDictTypeVo> selectPageDictTypeList(SysDictTypeBo dictType, PageRequest<?> query) {
return MapstructUtils.convert(
sysDictTypeData.findByConditions(
MapstructUtils.convert(dictType, SysDictType.class),
query.getPageNum(), query.getPageSize()),
SysDictTypeVo.class);
}
/**
@ -60,19 +58,10 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
*/
@Override
public List<SysDictTypeVo> selectDictTypeList(SysDictTypeBo dictType) {
LambdaQueryWrapper<SysDictType> lqw = buildQueryWrapper(dictType);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<SysDictType> buildQueryWrapper(SysDictTypeBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<SysDictType> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getDictName()), SysDictType::getDictName, bo.getDictName());
lqw.like(StringUtils.isNotBlank(bo.getDictType()), SysDictType::getDictType, bo.getDictType());
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDictType::getStatus, bo.getStatus());
lqw.between(params.get("beginTime") != null && params.get("endTime") != null,
SysDictType::getCreateTime, params.get("beginTime"), params.get("endTime"));
return lqw;
return MapstructUtils.convert(
sysDictTypeData.findByConditions(
MapstructUtils.convert(dictType, SysDictType.class)),
SysDictTypeVo.class);
}
/**
@ -82,7 +71,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
*/
@Override
public List<SysDictTypeVo> selectDictTypeAll() {
return baseMapper.selectVoList();
return MapstructUtils.convert(sysDictTypeData.findAll(), SysDictTypeVo.class);
}
/**
@ -91,14 +80,10 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
* @param dictType
* @return
*/
@Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
// @Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
@Override
public List<SysDictDataVo> selectDictDataByType(String dictType) {
List<SysDictDataVo> dictDatas = dictDataMapper.selectDictDataByType(dictType);
if (CollUtil.isNotEmpty(dictDatas)) {
return dictDatas;
}
return null;
return MapstructUtils.convert(sysDictData.findByDicType(dictType), SysDictDataVo.class);
}
/**
@ -109,7 +94,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
*/
@Override
public SysDictTypeVo selectDictTypeById(Long dictId) {
return baseMapper.selectVoById(dictId);
return MapstructUtils.convert(sysDictTypeData.findById(dictId), SysDictTypeVo.class);
}
/**
@ -118,10 +103,10 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
* @param dictType
* @return
*/
@Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
// @Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
@Override
public SysDictTypeVo selectDictTypeByType(String dictType) {
return baseMapper.selectVoById(new LambdaQueryWrapper<SysDictType>().eq(SysDictType::getDictType, dictType));
return MapstructUtils.convert(sysDictTypeData.findByDicType(dictType), SysDictTypeVo.class);
}
/**
@ -132,14 +117,13 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
@Override
public void deleteDictTypeByIds(Long[] dictIds) {
for (Long dictId : dictIds) {
SysDictType dictType = baseMapper.selectById(dictId);
if (dictDataMapper.exists(new LambdaQueryWrapper<SysDictData>()
.eq(SysDictData::getDictType, dictType.getDictType()))) {
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
SysDictType dictType = sysDictTypeData.findById(dictId);
if (sysDictData.countByDicType(dictType.getDictType()) > 0) {
throw new BizException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
}
CacheUtils.evict(CacheNames.SYS_DICT, dictType.getDictType());
}
baseMapper.deleteBatchIds(Arrays.asList(dictIds));
sysDictTypeData.deleteByIds(dictIds);
}
/**
@ -156,15 +140,12 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
* @param bo
* @return
*/
@CachePut(cacheNames = CacheNames.SYS_DICT, key = "#bo.dictType")
// @CachePut(cacheNames = CacheNames.SYS_DICT, key = "#bo.dictType")
@Override
public List<SysDictTypeVo> insertDictType(SysDictTypeBo bo) {
SysDictType dict = MapstructUtils.convert(bo, SysDictType.class);
int row = baseMapper.insert(dict);
if (row > 0) {
return new ArrayList<>();
}
throw new BizException("操作失败");
sysDictTypeData.save(dict);
return new ArrayList<>();
}
/**
@ -173,21 +154,13 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
* @param bo
* @return
*/
@CachePut(cacheNames = CacheNames.SYS_DICT, key = "#bo.dictType")
// @CachePut(cacheNames = CacheNames.SYS_DICT, key = "#bo.dictType")
@Override
@Transactional(rollbackFor = Exception.class)
public List<SysDictDataVo> updateDictType(SysDictTypeBo bo) {
SysDictType dict = MapstructUtils.convert(bo, SysDictType.class);
SysDictType oldDict = baseMapper.selectById(dict.getDictId());
dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>()
.set(SysDictData::getDictType, dict.getDictType())
.eq(SysDictData::getDictType, oldDict.getDictType()));
int row = baseMapper.updateById(dict);
if (row > 0) {
CacheUtils.evict(CacheNames.SYS_DICT, oldDict.getDictType());
return dictDataMapper.selectDictDataByType(dict.getDictType());
}
throw new BizException("操作失败");
SysDictType oldDict = sysDictTypeData.findById(bo.getId());
sysDictTypeData.updateDicType(oldDict.getDictType(), bo.getDictType());
// CacheUtils.evict(CacheNames.SYS_DICT, oldDict.getDictType());
return MapstructUtils.convert(sysDictData.findByDicType(bo.getDictType()), SysDictDataVo.class);
}
/**
@ -198,10 +171,11 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
*/
@Override
public boolean checkDictTypeUnique(SysDictTypeBo dictType) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDictType>()
.eq(SysDictType::getDictType, dictType.getDictType())
.ne(ObjectUtil.isNotNull(dictType.getDictId()), SysDictType::getDictId, dictType.getDictId()));
return !exist;
// boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDictType>()
// .eq(SysDictType::getDictType, dictType.getDictType())
// .ne(ObjectUtil.isNotNull(dictType.getDictId()), SysDictType::getDictId, dictType.getDictId()));
// return !exist;
return false;
}
/**
@ -225,8 +199,8 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
Map<String, String> map = StreamUtils.toMap(datas, SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel);
if (StringUtils.containsAny(dictValue, separator)) {
return Arrays.stream(dictValue.split(separator))
.map(v -> map.getOrDefault(v, StringUtils.EMPTY))
.collect(Collectors.joining(separator));
.map(v -> map.getOrDefault(v, StringUtils.EMPTY))
.collect(Collectors.joining(separator));
} else {
return map.getOrDefault(dictValue, StringUtils.EMPTY);
}
@ -253,8 +227,8 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
Map<String, String> map = StreamUtils.toMap(datas, SysDictDataVo::getDictLabel, SysDictDataVo::getDictValue);
if (StringUtils.containsAny(dictLabel, separator)) {
return Arrays.stream(dictLabel.split(separator))
.map(l -> map.getOrDefault(l, StringUtils.EMPTY))
.collect(Collectors.joining(separator));
.map(l -> map.getOrDefault(l, StringUtils.EMPTY))
.collect(Collectors.joining(separator));
} else {
return map.getOrDefault(dictLabel, StringUtils.EMPTY);
}

View File

@ -1,31 +1,26 @@
package cc.iotkit.system.service.impl;
import cc.iotkit.common.api.PageRequest;
import cc.iotkit.common.constant.Constants;
import cc.iotkit.common.api.Paging;
import cc.iotkit.common.constant.Constants;
import cc.iotkit.common.log.event.LogininforEvent;
import cc.iotkit.common.utils.MapstructUtils;
import cc.iotkit.common.utils.ServletUtils;
import cc.iotkit.common.utils.StringUtils;
import cc.iotkit.common.utils.ip.AddressUtils;
import cc.iotkit.common.web.utils.UnsignedMathGenerator;
import cc.iotkit.data.system.ISysLogininforData;
import cc.iotkit.model.system.SysLogininfor;
import cc.iotkit.system.dto.bo.SysLogininforBo;
import cc.iotkit.system.dto.vo.SysLogininforVo;
import cn.hutool.http.useragent.UserAgent;
import cn.hutool.http.useragent.UserAgentUtil;
import cc.iotkit.system.service.ISysLogininforService;
import cn.hutool.http.useragent.UserAgent;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import jakarta.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 访
@ -37,7 +32,7 @@ import java.util.Map;
@Service
public class SysLogininforServiceImpl implements ISysLogininforService {
private final SysLogininforMapper baseMapper;
private final ISysLogininforData sysLogininforData;
/**
*
@ -47,10 +42,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
@Async
@EventListener
public void recordLogininfor(LogininforEvent logininforEvent) {
HttpServletRequest request = logininforEvent.getRequest();
final UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent"));
final String ip = UnsignedMathGenerator.ServletUtils.getClientIP(request);
String ip = logininforEvent.getIp();
String address = AddressUtils.getRealAddressByIP(ip);
StringBuilder s = new StringBuilder();
s.append(getBlock(ip));
@ -60,6 +52,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
s.append(getBlock(logininforEvent.getMessage()));
// 打印信息到日志
log.info(s.toString(), logininforEvent.getArgs());
UserAgent userAgent = logininforEvent.getUserAgent();
// 获取客户端操作系统
String os = userAgent.getOs().getName();
// 获取客户端浏览器
@ -92,19 +85,13 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
@Override
public Paging<SysLogininforVo> selectPageLogininforList(SysLogininforBo logininfor, PageRequest<?> query) {
Map<String, Object> params = logininfor.getParams();
LambdaQueryWrapper<SysLogininfor> lqw = new LambdaQueryWrapper<SysLogininfor>()
.like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr())
.eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus())
.like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName())
.between(params.get("beginTime") != null && params.get("endTime") != null,
SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime"));
if (StringUtils.isBlank(query.getOrderByColumn())) {
pageQuery.setOrderByColumn("info_id");
pageQuery.setIsAsc("desc");
}
Page<SysLogininforVo> page = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(page);
return MapstructUtils.convert(
sysLogininforData.findByConditions(
MapstructUtils.convert(logininfor, SysLogininfor.class),
query.getPageNum(),
query.getPageSize()
), SysLogininforVo.class
);
}
/**
@ -116,7 +103,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
public void insertLogininfor(SysLogininforBo bo) {
SysLogininfor logininfor = MapstructUtils.convert(bo, SysLogininfor.class);
logininfor.setLoginTime(new Date());
baseMapper.insert(logininfor);
sysLogininforData.save(logininfor);
}
/**
@ -127,14 +114,11 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
*/
@Override
public List<SysLogininforVo> selectLogininforList(SysLogininforBo logininfor) {
Map<String, Object> params = logininfor.getParams();
return baseMapper.selectVoList(new LambdaQueryWrapper<SysLogininfor>()
.like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr())
.eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus())
.like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName())
.between(params.get("beginTime") != null && params.get("endTime") != null,
SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime"))
.orderByDesc(SysLogininfor::getInfoId));
return MapstructUtils.convert(
sysLogininforData.findByConditions(
MapstructUtils.convert(logininfor, SysLogininfor.class)
), SysLogininforVo.class
);
}
/**
@ -144,8 +128,8 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
* @return
*/
@Override
public int deleteLogininforByIds(Long[] infoIds) {
return baseMapper.deleteBatchIds(Arrays.asList(infoIds));
public void deleteLogininforByIds(Long[] infoIds) {
sysLogininforData.deleteByIds(infoIds);
}
/**
@ -153,6 +137,6 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
*/
@Override
public void cleanLogininfor() {
baseMapper.delete(new LambdaQueryWrapper<>());
sysLogininforData.deleteAll();
}
}

View File

@ -33,11 +33,6 @@ import java.util.*;
@Service
public class SysMenuServiceImpl implements ISysMenuService {
private final SysMenuMapper baseMapper;
private final SysRoleMapper roleMapper;
private final SysRoleMenuMapper roleMenuMapper;
private final SysTenantPackageMapper tenantPackageMapper;
/**
*
*

View File

@ -25,9 +25,6 @@ import java.util.List;
@Service
public class SysNoticeServiceImpl implements ISysNoticeService {
private final SysNoticeMapper baseMapper;
private final SysUserMapper userMapper;
@Override
public Paging<SysNoticeVo> selectPageNoticeList(SysNoticeBo notice, PageRequest<?> query) {
LambdaQueryWrapper<SysNotice> lqw = buildQueryWrapper(notice);

View File

@ -36,11 +36,6 @@ import java.util.*;
@Service
public class SysRoleServiceImpl implements ISysRoleService {
private final SysRoleMapper baseMapper;
private final SysRoleMenuMapper roleMenuMapper;
private final SysUserRoleMapper userRoleMapper;
private final SysRoleDeptMapper roleDeptMapper;
@Override
public Paging<SysRoleVo> selectPageRoleList(SysRoleBo role, PageRequest<?> query) {
Page<SysRoleVo> page = baseMapper.selectPageRoleList(query.build(), this.buildQueryWrapper(role));