Merge remote-tracking branch 'origin/v7.0.1-develop' into v7.0.1-develop

pull/3/head
陈立 2021-03-05 17:51:38 +08:00
commit 3d9a0e0d03
21 changed files with 218 additions and 58 deletions

View File

@ -38,4 +38,10 @@ public interface DbFieldConstants {
*/
String DEL_FLAG = "delFlag";
/**
*
* 1-2-
*/
String STATUS_FLAG = "statusFlag";
}

View File

@ -1,6 +1,7 @@
package cn.stylefeng.roses.kernel.db.mp.fieldfill;
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
import cn.stylefeng.roses.kernel.rule.enums.StatusEnum;
import cn.stylefeng.roses.kernel.rule.enums.YesOrNotEnum;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import lombok.extern.slf4j.Slf4j;
@ -31,9 +32,11 @@ public class CustomMetaObjectHandler implements MetaObjectHandler {
// 设置createTimeBaseEntity)
setFieldValByName(CREATE_TIME, new Date(), metaObject);
// 设置删除标记默认N删除
// 设置删除标记 默认N-删除
setFieldValByName(DEL_FLAG, YesOrNotEnum.N.getCode(), metaObject);
// 设置状态字段 默认1-启用
setFieldValByName(STATUS_FLAG, StatusEnum.ENABLE.getCode(), metaObject);
} catch (ReflectionException e) {
log.warn("CustomMetaObjectHandler处理过程中无相关字段不做处理");

View File

@ -150,8 +150,7 @@ public class DatabaseInfoServiceImpl extends ServiceImpl<DatabaseInfoMapper, Dat
Class.forName(param.getJdbcDriver());
conn = DriverManager.getConnection(param.getJdbcUrl(), param.getUsername(), param.getPassword());
} catch (Exception e) {
String userTip = StrUtil.format(VALIDATE_DATASOURCE_ERROR.getUserTip(), param.getJdbcUrl());
throw new DatasourceContainerException(VALIDATE_DATASOURCE_ERROR, userTip);
throw new DatasourceContainerException(VALIDATE_DATASOURCE_ERROR, param.getJdbcUrl());
} finally {
if (conn != null) {
try {

View File

@ -3,6 +3,7 @@ package cn.stylefeng.roses.kernel.log.starter;
import cn.hutool.core.util.StrUtil;
import cn.hutool.system.SystemUtil;
import cn.stylefeng.roses.kernel.log.api.LogManagerApi;
import cn.stylefeng.roses.kernel.log.api.LogRecordApi;
import cn.stylefeng.roses.kernel.log.api.enums.LogSaveTypeEnum;
import cn.stylefeng.roses.kernel.log.api.expander.LogConfigExpander;
import cn.stylefeng.roses.kernel.log.api.pojo.log.SysLogProperties;
@ -67,7 +68,7 @@ public class GunsLogAutoConfiguration {
* db-file-
*
* @param sysLogProperties
* @param sysLogService service
* @param sysLogService service
* @author liuhanqing
* @date 2020/12/20 13:02
*/
@ -122,4 +123,15 @@ public class GunsLogAutoConfiguration {
return new DbLogManagerServiceImpl();
}
/**
* api
*
* @author fengshuonan
* @date 2021/3/4 22:16
*/
@Bean
public LogRecordApi logRecordApi(SysLogServiceImpl sysLogService) {
return new DbLogRecordServiceImpl(new LogManagerThreadPool(), sysLogService);
}
}

View File

@ -40,6 +40,22 @@
<version>7.0.1</version>
</dependency>
<!--system的api-->
<!--查询用户-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>system-api</artifactId>
<version>7.0.1</version>
</dependency>
<!--包装器模块-->
<!--包装结果-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>wrapper-api</artifactId>
<version>7.0.1</version>
</dependency>
<!--数据库sdk-->
<!--数据库dao框架-->
<dependency>

View File

@ -7,6 +7,8 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.PostResource;
import cn.stylefeng.roses.kernel.timer.modular.param.SysTimersParam;
import cn.stylefeng.roses.kernel.timer.modular.service.SysTimersService;
import cn.stylefeng.roses.kernel.timer.modular.wrapper.TimerWrapper;
import cn.stylefeng.roses.kernel.wrapper.api.annotation.Wrapper;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
@ -105,6 +107,7 @@ public class SysTimersController {
* @date 2020/6/30 18:26
*/
@GetResource(name = "分页查询定时任务", path = "/sysTimers/page")
@Wrapper(TimerWrapper.class)
public ResponseData page(SysTimersParam sysTimersParam) {
return new SuccessResponseData(sysTimersService.findPage(sysTimersParam));
}

View File

@ -0,0 +1,43 @@
package cn.stylefeng.roses.kernel.timer.modular.wrapper;
import cn.hutool.extra.spring.SpringUtil;
import cn.stylefeng.roses.kernel.system.api.UserServiceApi;
import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO;
import cn.stylefeng.roses.kernel.timer.modular.entity.SysTimers;
import cn.stylefeng.roses.kernel.wrapper.api.BaseWrapper;
import java.util.HashMap;
import java.util.Map;
/**
*
*
* @author fengshuonan
* @date 2021/3/1 23:45
*/
public class TimerWrapper implements BaseWrapper<SysTimers> {
@Override
public Map<String, Object> doWrap(SysTimers beWrappedModel) {
HashMap<String, Object> resultMap = new HashMap<>();
UserServiceApi userServiceApi = SpringUtil.getBean(UserServiceApi.class);
if (beWrappedModel.getCreateUser() != null) {
SysUserDTO sysUserDTO = userServiceApi.getUserInfoByUserId(beWrappedModel.getCreateUser());
if (sysUserDTO != null) {
resultMap.put("createUserName", sysUserDTO.getRealName());
}
}
if (beWrappedModel.getUpdateUser() != null) {
SysUserDTO sysUserDTO = userServiceApi.getUserInfoByUserId(beWrappedModel.getUpdateUser());
if (sysUserDTO != null) {
resultMap.put("updateUserName", sysUserDTO.getRealName());
}
}
return resultMap;
}
}

View File

@ -25,6 +25,6 @@ public interface UserOrgServiceApi {
* @author fengshuonan
* @date 2020/12/19 22:33
*/
SysUserOrgDTO getUserOrgInfo(Long userId);
SysUserOrgDTO getUserOrgByUserId(Long userId);
}

View File

@ -0,0 +1,33 @@
package cn.stylefeng.roses.kernel.system.api.exception.enums.user;
import cn.stylefeng.roses.kernel.rule.constants.RuleConstants;
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
import cn.stylefeng.roses.kernel.system.api.constants.SystemConstants;
import lombok.Getter;
@Getter
public enum SysUserDataScopeExceptionEnum implements AbstractExceptionEnum {
/**
*
*/
USER_DATA_SCOPE_NOT_EXIST(RuleConstants.USER_OPERATION_ERROR_TYPE_CODE + SystemConstants.SYSTEM_EXCEPTION_STEP_CODE + "91", "{} 用户数据范围不存在");
/**
*
*/
private final String errorCode;
/**
*
*/
private final String userTip;
SysUserDataScopeExceptionEnum(String errorCode, String userTip) {
this.errorCode = errorCode;
this.userTip = userTip;
}
}

View File

@ -40,6 +40,22 @@
<version>7.0.1</version>
</dependency>
<!--system的api-->
<!--查询用户-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>system-api</artifactId>
<version>7.0.1</version>
</dependency>
<!--包装器模块-->
<!--包装结果-->
<dependency>
<groupId>cn.stylefeng.roses</groupId>
<artifactId>wrapper-api</artifactId>
<version>7.0.1</version>
</dependency>
<!--数据库sdk-->
<!--数据库dao框架-->
<dependency>

View File

@ -6,6 +6,8 @@ import cn.stylefeng.roses.kernel.scanner.api.annotation.ApiResource;
import cn.stylefeng.roses.kernel.scanner.api.annotation.GetResource;
import cn.stylefeng.roses.kernel.system.api.pojo.loginlog.SysLoginLogRequest;
import cn.stylefeng.roses.kernel.system.modular.loginlog.service.SysLoginLogService;
import cn.stylefeng.roses.kernel.system.modular.loginlog.wrapper.SysLoginLogWrapper;
import cn.stylefeng.roses.kernel.wrapper.api.annotation.Wrapper;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
@ -54,6 +56,7 @@ public class SysLoginLogController {
* @date 2021/1/13 17:51
*/
@GetResource(name = "分页查询登录日志", path = "/loginLog/page")
@Wrapper(SysLoginLogWrapper.class)
public ResponseData page(SysLoginLogRequest sysLoginLogRequest) {
return new SuccessResponseData(sysLoginLogService.findPage(sysLoginLogRequest));
}

View File

@ -0,0 +1,34 @@
package cn.stylefeng.roses.kernel.system.modular.loginlog.wrapper;
import cn.hutool.extra.spring.SpringUtil;
import cn.stylefeng.roses.kernel.system.api.UserServiceApi;
import cn.stylefeng.roses.kernel.system.api.pojo.user.SysUserDTO;
import cn.stylefeng.roses.kernel.system.modular.loginlog.entity.SysLoginLog;
import cn.stylefeng.roses.kernel.wrapper.api.BaseWrapper;
import java.util.HashMap;
import java.util.Map;
/**
*
*
* @author fengshuonan
* @date 2021/2/28 10:59
*/
public class SysLoginLogWrapper implements BaseWrapper<SysLoginLog> {
@Override
public Map<String, Object> doWrap(SysLoginLog sysLoginLog) {
if (sysLoginLog.getUserId() == null) {
return new HashMap<>();
}
UserServiceApi userServiceApi = SpringUtil.getBean(UserServiceApi.class);
SysUserDTO sysUserDTO = userServiceApi.getUserInfoByUserId(sysLoginLog.getUserId());
HashMap<String, Object> map = new HashMap<>();
map.put("realName", sysUserDTO.getRealName());
return map;
}
}

View File

@ -71,7 +71,7 @@ public class HrPositionController {
*/
@PostResource(name = "更新职位状态", path = "/hrPosition/updateStatus")
public ResponseData updateStatus(@RequestBody @Validated(BaseRequest.updateStatus.class) HrPositionRequest hrPositionRequest) {
hrPositionService.updateStatus(hrPositionRequest);
hrPositionService.changeStatus(hrPositionRequest);
return new SuccessResponseData();
}

View File

@ -61,7 +61,7 @@ public class HrOrganization extends BaseEntity {
/**
* 1-2-
*/
@TableField("status_flag")
@TableField(value = "status_flag",fill = FieldFill.INSERT)
private Integer statusFlag;
/**

View File

@ -53,7 +53,7 @@ public class DataScopeService implements DataScopeApi {
}
// 获取用户的主要部门信息
SysUserOrgDTO sysUserOrgResponse = userOrgServiceApi.getUserOrgInfo(userId);
SysUserOrgDTO sysUserOrgResponse = userOrgServiceApi.getUserOrgByUserId(userId);
// 获取角色中的数据范围类型
Set<DataScopeTypeEnum> dataScopeTypeEnums = sysRoles.stream().map(SysRoleDTO::getDataScopeTypeEnum).collect(Collectors.toSet());

View File

@ -43,13 +43,13 @@ public interface HrPositionService extends IService<HrPosition> {
void edit(HrPositionRequest hrPositionRequest);
/**
*
*
*
* @param hrPositionRequest
* @author chenjinlong
* @date 2020/11/18 23:00
*/
void updateStatus(HrPositionRequest hrPositionRequest);
void changeStatus(HrPositionRequest hrPositionRequest);
/**
*

View File

@ -149,7 +149,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
@Override
public HrOrganization detail(HrOrganizationRequest hrOrganizationRequest) {
return this.queryOrganization(hrOrganizationRequest);
return this.getOne(this.createWrapper(hrOrganizationRequest), false);
}
@Override
@ -387,7 +387,7 @@ public class HrOrganizationServiceImpl extends ServiceImpl<HrOrganizationMapper,
} else {
// 获取父组织机构
HrOrganizationRequest hrOrganizationRequest = new HrOrganizationRequest();
hrOrganizationRequest.setOrgId(hrOrganization.getOrgId());
hrOrganizationRequest.setOrgId(hrOrganization.getOrgParentId());
HrOrganization parentOrganization = this.queryOrganization(hrOrganizationRequest);
// 设置本节点的父ids为 (上一个节点的pids + (上级节点的id) )

View File

@ -69,7 +69,7 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
}
@Override
public void updateStatus(HrPositionRequest hrPositionRequest) {
public void changeStatus(HrPositionRequest hrPositionRequest) {
HrPosition sysPosition = this.querySysPositionById(hrPositionRequest);
sysPosition.setStatusFlag(hrPositionRequest.getStatusFlag());
this.updateById(sysPosition);
@ -82,8 +82,7 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
@Override
public List<HrPosition> findList(HrPositionRequest hrPositionRequest) {
LambdaQueryWrapper<HrPosition> wrapper = this.createWrapper(hrPositionRequest);
return this.list(wrapper);
return this.list(this.createWrapper(hrPositionRequest));
}
@Override
@ -119,16 +118,6 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
private LambdaQueryWrapper<HrPosition> createWrapper(HrPositionRequest hrPositionRequest) {
LambdaQueryWrapper<HrPosition> queryWrapper = new LambdaQueryWrapper<>();
// 查询未删除状态的
queryWrapper.eq(HrPosition::getDelFlag, YesOrNotEnum.N.getCode());
// 根据排序升序排列,序号越小越在前
queryWrapper.orderByAsc(HrPosition::getPositionSort);
if (ObjectUtil.isEmpty(hrPositionRequest)) {
return queryWrapper;
}
Long positionId = hrPositionRequest.getPositionId();
String positionName = hrPositionRequest.getPositionName();
String positionCode = hrPositionRequest.getPositionCode();
@ -138,6 +127,11 @@ public class HrPositionServiceImpl extends ServiceImpl<HrPositionMapper, HrPosit
queryWrapper.like(StrUtil.isNotEmpty(positionName), HrPosition::getPositionName, positionName);
queryWrapper.eq(StrUtil.isNotEmpty(positionCode), HrPosition::getPositionCode, positionCode);
// 查询未删除状态的
queryWrapper.eq(HrPosition::getDelFlag, YesOrNotEnum.N.getCode());
// 根据排序升序排列
queryWrapper.orderByAsc(HrPosition::getPositionSort);
return queryWrapper;
}

View File

@ -3,12 +3,16 @@ package cn.stylefeng.roses.kernel.system.modular.user.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException;
import cn.stylefeng.roses.kernel.system.api.exception.enums.user.SysUserDataScopeExceptionEnum;
import cn.stylefeng.roses.kernel.system.api.exception.enums.user.SysUserOrgExceptionEnum;
import cn.stylefeng.roses.kernel.system.modular.user.entity.SysUserDataScope;
import cn.stylefeng.roses.kernel.system.modular.user.mapper.SysUserDataScopeMapper;
import cn.stylefeng.roses.kernel.system.modular.user.service.SysUserDataScopeService;
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.SysUserRequest;
import cn.stylefeng.roses.kernel.system.api.pojo.user.request.UserDataScopeRequest;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -68,10 +72,11 @@ public class SysUserDataScopeServiceImpl extends ServiceImpl<SysUserDataScopeMap
@Override
public void delByUserId(Long userId) {
UserDataScopeRequest userDataScopeRequest = new UserDataScopeRequest();
userDataScopeRequest.setUserId(userId);
LambdaQueryWrapper<SysUserDataScope> queryWrapper = this.createQueryWrapper(userDataScopeRequest);
this.remove(queryWrapper);
if (ObjectUtil.isNotEmpty(userId)) {
LambdaQueryWrapper<SysUserDataScope> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SysUserDataScope::getUserId, userId);
this.remove(queryWrapper);
}
}
@Override
@ -83,8 +88,7 @@ public class SysUserDataScopeServiceImpl extends ServiceImpl<SysUserDataScopeMap
@Override
public SysUserDataScope detail(UserDataScopeRequest userDataScopeRequest) {
LambdaQueryWrapper<SysUserDataScope> queryWrapper = this.createQueryWrapper(userDataScopeRequest);
return this.getOne(queryWrapper, false);
return this.getOne(this.createQueryWrapper(userDataScopeRequest), false);
}
@Override
@ -109,7 +113,11 @@ public class SysUserDataScopeServiceImpl extends ServiceImpl<SysUserDataScopeMap
* @date 2021/2/3 15:02
*/
private SysUserDataScope querySysUserRoleById(UserDataScopeRequest userDataScopeRequest) {
return this.getById(userDataScopeRequest.getUserDataScopeId());
SysUserDataScope sysUserDataScope = this.getById(userDataScopeRequest.getUserDataScopeId());
if (ObjectUtil.isEmpty(sysUserDataScope)) {
throw new SystemModularException(SysUserDataScopeExceptionEnum.USER_DATA_SCOPE_NOT_EXIST, sysUserDataScope.getUserDataScopeId());
}
return sysUserDataScope;
}
/**

View File

@ -16,7 +16,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import static cn.stylefeng.roses.kernel.system.api.exception.enums.user.SysUserOrgExceptionEnum.EMPLOYEE_MANY_MAIN_NOT_FOUND;
/**
*
@ -28,20 +27,17 @@ import static cn.stylefeng.roses.kernel.system.api.exception.enums.user.SysUserO
public class SysUserOrgServiceServiceImpl extends ServiceImpl<SysUserOrgMapper, SysUserOrg> implements SysUserOrgService {
@Override
public SysUserOrgDTO getUserOrgInfo(Long userId) {
public SysUserOrgDTO getUserOrgByUserId(Long userId) {
LambdaQueryWrapper<SysUserOrg> sysUserOrgLambdaQueryWrapper = new LambdaQueryWrapper<>();
sysUserOrgLambdaQueryWrapper.eq(SysUserOrg::getUserId, userId);
List<SysUserOrg> list = this.list(sysUserOrgLambdaQueryWrapper);
if (list.size() != 1) {
throw new SystemModularException(EMPLOYEE_MANY_MAIN_NOT_FOUND);
} else {
SysUserOrg sysUserOrg = list.get(0);
SysUserOrgDTO sysUserOrgResponse = new SysUserOrgDTO();
BeanUtil.copyProperties(sysUserOrg, sysUserOrgResponse);
return sysUserOrgResponse;
UserOrgRequest userOrgRequest = new UserOrgRequest();
userOrgRequest.setUserId(userId);
SysUserOrg sysUserOrg = this.detail(userOrgRequest);
if(ObjectUtil.isEmpty(sysUserOrg)){
throw new SystemModularException(SysUserOrgExceptionEnum.EMPLOYEE_MANY_MAIN_NOT_FOUND);
}
SysUserOrgDTO sysUserOrgDTO = new SysUserOrgDTO();
BeanUtil.copyProperties(sysUserOrg, sysUserOrgDTO);
return sysUserOrgDTO;
}
@ -84,22 +80,16 @@ public class SysUserOrgServiceServiceImpl extends ServiceImpl<SysUserOrgMapper,
@Override
@Transactional(rollbackFor = Exception.class)
public void edit(Long userId, Long orgId, Long positionId) {
UserOrgRequest userOrgResponse = new UserOrgRequest();
userOrgResponse.setUserId(userId);
userOrgResponse.setOrgId(orgId);
userOrgResponse.setPositionId(positionId);
// 删除已有
this.delByUserId(userId);
// 新增
this.add(userId, orgId, positionId);
}
@Override
public SysUserOrg detail(UserOrgRequest userOrgResponse) {
LambdaQueryWrapper<SysUserOrg> queryWrapper = this.createWrapper(userOrgResponse);
return this.getOne(queryWrapper, false);
return this.getOne( this.createWrapper(userOrgResponse), false);
}
@Override

View File

@ -159,7 +159,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
}
// 获取被授权用户的所属机构
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgInfo(sysUser.getUserId());
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(sysUser.getUserId());
Long organizationId = userOrgInfo.getOrgId();
// 判断当前用户有无该用户的权限
@ -318,7 +318,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
SysUser sysUser = this.querySysUser(sysUserRequest);
// 获取要授权角色的用户的所属机构
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgInfo(sysUser.getUserId());
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(sysUser.getUserId());
Long organizationId = userOrgInfo.getOrgId();
// 判断当前用户有无该用户的权限
@ -334,7 +334,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
SysUser sysUser = this.querySysUser(sysUserRequest);
// 获取被授权用户的所属机构
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgInfo(sysUser.getUserId());
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(sysUser.getUserId());
Long organizationId = userOrgInfo.getOrgId();
// 判断当前用户有无该用户的权限
@ -352,7 +352,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
BeanUtil.copyProperties(sysUser, sysUserResponse);
// 获取用户组织绑定信息
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgInfo(sysUser.getUserId());
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(sysUser.getUserId());
sysUserResponse.setOrgId(userOrgInfo.getOrgId());
sysUserResponse.setPositionId(userOrgInfo.getPositionId());
@ -504,7 +504,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
DataScopeDTO dataScopeResponse = dataScopeApi.getDataScope(userId, roleResponseList);
// 4. 获取用户的组织机构和职位信息
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgInfo(userId);
SysUserOrgDTO userOrgInfo = sysUserOrgService.getUserOrgByUserId(userId);
// 5. 获取用户的所有资源url
List<String> resourceCodeList = roleServiceApi.getRoleResourceCodeList(roleIds);