首页 > 其他分享 >userService源代码

userService源代码

时间:2024-11-17 11:29:06浏览次数:1  
标签:userName request userConfig user new userService 源代码 response

@Slf4j
@ Service("userService")
public class UserServiceImpl implements UserService{
@ Autowired
private FinTechDataProviderService finTechDataProviderService;
@ Autowired
private UserConfigMapper userConfigMapper;
@ Autowired
private UserDepartmentMapper userDepartmentMapper;
@ Autowired
private UserPermissionServiceImpl userPermissionService;
@ Autowired
private DepartmentServiceImpl departmentService;
@ Autowired
private IndexPatternMapper indexPatternMapper;
@ Autowired
private IndexPatternServiceImpl indexPattemService;
public ListgetUserByNameList( List< String>nameList){
if (CollectionUtils. isEmpty(nameList)){
return new ArrayList<>();
}
Example example = new Example(UserConfig. class);
Example. Criteria criteria = example. createCriteria();
for ( String name : nameList){
criteria. orEqualTo("userName", name);}
return userConfigMapper. selectByExample( example);
}
public UserConfig queryByUserName( String userName){
Example example= new Example(UserConfig. class);
example. createCriteria(). andEqualTo("userName",userName); return userConfigMapper. selectOneByExample( example);
)
@ Transactional(rollbackFor= Exception.class)
public void deleteUser( Long userId){
userConfigMapper. deleteByPrimaryKey(userId);
Example example = new Example(UserDepartment. class);
example. createCriteria(). andEqualTo("userId",userId);
userDepartmentMapper. deleteByExample( example);
return;
}
@ Override
public QueryUserGlobalQueryResponse
isGlobalQuery(QueryUserGlobalQueryRequest request){
String userName= request. getUserName();
QueryUserGlobalQueryResponse response = new
QueryUserGlobalQueryResponse();
if (StringUtils. isEmpty(userName)){
log. error("查询用户全局查询权限请求参数为空");
throw new TitanException("所传参数为空!");
}
UserConfig user= queryByUserName(userName);
if ( user== null){
RespUtils. setError(ErrorCodeEnum. USER_NOT_EXIST, response);
return response;
}
Boolean globalQueryFlag= user. getGlobalQuery();
if (globalQueryFlag && user. getQueryPermanentFlag() != null&&
user. getQueryEffectiveDate()!= null){
if (! user. getQueryPermanentFlag() &&
user. getQueryEffectiveDate(). before( new Date()))
globalQueryFlag= false;
}
response,setGlobalQueryFlag(globalQueryFlag);
response,setEffectiveDate( user. getQueryEffectiveDate());
response. setPermanentFlag( user. getQueryPermanentFlag());
RespUtils. setSuccess( response);
return response;
}
@ Override
public QueryUserIndexPatternResponse
queryIndexPatternByUserName(QueryUserIndexPatternRequest request){
String userName= request. getUserName();
QueryUserIndexPatternResponse response = new
QueryUserIndexPatternResponse();
if (StringUtils. isEmpty(userName)){
log. error("查询用户关联索引请求参数为空");
throw new TitanException("所传参数为空!");
}
UserConfig user= queryByUserName(userName);
if ( user== null) {
RespUtils. setError(ErrorCodeEnum. USER_NOT_EXIST, response);
return response;
}
response. setIndexPatternItemList(indexPatternService. getUserIndexPatternByUserName(userName));
RespUtils. setSuccess( response);
return response;
}
@ Override
public QueryIndicesNoPermissionResponse
queryIndicesNoPermission(QueryIndicesNoPermissionRequest request
String userName= request. getUserName();
QueryIndicesNoPermissionResponse response = new QueryIndicesNoPermissionResponse();
if (StringUtils. isEmpty(userName)){
log. error("查询用户关联索引请求参数为空");
throw new TitanException("所传参数为空!");
}
Example example = new Example(UserConfig. class);
example. createCriteria(). andEqualTo("userName",userName);
UserConfig userConfig = userConfigMapper. selectOneByExample( example);
List< String>userNameList = new ArrayList<>();
userNameList. add(userName);
QueryFinTechUserRequest userRequest= new QueryFinTechUserRequest();
userRequest. setUserNameList(userNameList);
UserInfoResponse userInfoResponse =
finTechDataProviderService. queryFinTechUserInfo(userRequest);
String departmentId= userInfoResponse. getUserList(). get(0). getOrgId();
Department department =
departmentService. getDepartmentById(departmentId);
if((userConfig!= null && userConfig. getGlobalQuery())||( department != null && department. getGlobalQuery())){
response. setErrMsg("用户是全查询用户, 无需申请临时权限! ");
return response;
}
PageHelper. startPage( request. getPageIndex(), request. getLimit());
PageInfo pageInfo = new
PageInfo<>(indexPatternMapper. queryIndicesNoPermission(userName,departmentId, req uest. getIndexName(), request. getSystemIdList(), request. getApplicationName()));
response. setTotal(pageInfo. getTotal());
List indexPatternItemList= new ArrayList<>();
pageInfo. getList(). forEach(indexPattern->{
IndexPatternItem indexPatternItem= new IndexPatternItem();
indexPatternItem. setId(indexPattern. getId());
indexPatternItem. setIndexPatternName(indexPattern. getIndexPattemName());
indexPatternItem. setApplicationName(indexPattern. getApplicationName());
indexPatternItem. setSystemId(indexPattern. getSystemId());
indexPatternItemList. add(indexPatternItem);
});
response. setIndicesList(indexPatternItemList);
response. setSuccess();
return response;
)
@ Transactional(rollbackFor= Exception.class)
@ Override
public AddUserPermissionResponse addUserPermission(AddUserPermissionRequest request){
String userName= request. getUserName();
AddUserPermissionResponse response= new AddUserPermissionResponse();
if (StringUtils. isEmpty(userName) II
CollectionUtils. isEmpty( request. getUserPermissionDTOList())){
log. error("新增用户关联索引请求参数为空");
throw new TitanException("所传参数为空!");
)
UserConfig user= queryByUserName(userName);
if( user== null) {
UserConfig userNew= new UserConfig();
userNew. setUserName(userName);
userNew. setCreateTime( new Date());
userNew. setGlobalQuery( false);
//新增设置默认管理员权限为 false
userNew. setAdministratorFlag( false);
//新增结束
userConfigMapper. insert(userNew);
} else if (isGlobalQuery( new
QueryUserGlobalQueryRequest( request. getUserName())). getGlobalQueryFlag()){
RespUtils. setError(ErrorCodeEnum. USER_ALREADY_GLOBAL_QUERY, response);
return response;
}
// List< Long> indexIdList =
indexPatternService. getIndexPatternIdByNameList(indexPatternNameList);
userPermissionService. addPermissionForUser( request. getUserName(),
request. getUserPermissionDTOList());
RespUtils. setSuccess( response);
return response;
}
@ Transactional(rollbackFor= Exception.class)
@ Override
public DelUserPermissionResponse
deleteUserPermission(DelUserPermissionRequest request){
String userName = request. getUserName();
List< String>indexPatternNameList= request. getIndexPatternNameList();
DelUserPermissionResponse response= new DelUserPermissionResponse();
if (StringUtils. isEmpty(userName) ll
CollectionUtils. isEmpty(indexPatternNameList)) {
log. error("删除用户关联索引请求参数为空");
throw new TitanException("所传参数为空!");
}
List< Long> indexIdList =
indexPatternService. getIndexPatternIdByNameList(indexPattemNameList);
userPermissionService. deleteUserPermissionForUser( request. getUserName(),
indexIdList);
RespUtils. setSuccess( response);
return response;
}
@ Transactional(rollbackFor = Exception.class)
@ Override
public ChangeUserGlobalQueryResponse
changeGlobalQuery(ChangeUserGlobalQueryRequest request){
String userName= request. getUserName();
Boolean globalQuery = request. getGlobalQuery();
if (StringUtils. isEmpty(userName) || globalQuery== null) {
log. error("修改用户全局查询标志请求参数为空");
throw new TitanException("所传参数为空!");
}
if ( request. getGlobalQuery()){
if ( request. getPermanentFlag() == null){
log. error("修改用户全局查询标志请求参数->永久有效期标志字段为空");
throw new TitanException("所传参数为空!");
} else if (! request. getPermanentFlag() && request. getEffectiveDate() == null){
log. error("修改用户全局查询标志请求参数->有效期字段为空");
throw new TitanException("所传参数为空!");
}
}
ChangeUserGlobalQueryResponse response = new
ChangeUserGlobalQueryResponse();
UserConfig user= queryByUserName(userName);
if ( user== null){
UserConfig userNew= new UserConfig();
userNew. setUserName(userName);
userNew. setCreateTime( new Date());
userNew. setUpdateTime( new Date());
userNew. setGlobalQuery( false);
//新增设置默认管理员权限为 false
userNew. setAdministratorFlag( false);
//新增结束
userConfigMapper. insert(userNew);
}
Boolean isGlobalQuery = isGlobalQuery( new
QueryUserGlobalQueryRequest(userName)). getGlobalQueryFlag();
if (isGlobalQuery && !globalQuery){
UserConfig updateUser= new UserConfig();
updateUser. setUserName( request. getUserName());
updateUser. setGlobalQuery( false);
updateUser. setUpdateTime( new Date());
userConfigMapper. updateByPrimaryKeySelective(updateUser);
} else if (!isGlobalQuery && globalQuery) {
UserConfig updateUser= new UserConfig();
updateUser. setUserName( request. getUserName());
updateUser. setGlobalQuery( true);
updateUser. setQueryEffectiveDate( request. getEffectiveDate());
updateUser. setQueryPermanentFlag( request. getPermanentFlag());
updateUser. setUpdateTime( new Date());
userConfigMapper. updateByPrimaryKeySelective(updateUser);
)
RespUtils. setSuccess( response);
return response;
)
public ListgetSpecialPermissionUser( String userName){
ListspecialPermissionUsers= new ArrayList<>();
Example example = new Example(UserConfig. class);
Example. Criteria criteria = example. createCriteria();
if(StringUtils. isNotBlank(userName)){
criteria. andLike("userName", "%"+userName+"%");
}
List userConfigList =
userConfigMapper. selectByExample( example);
if(userConfigList. isEmpty()){
return specialPermissionUsers;
}
List< String> userNameList = new ArrayList<>();
List< String>departmentIdList= new ArrayList<>();
userConfigList. forEach(userConfig - >{
userNameList. add(userConfig. getUserName());
});
QueryFinTechUserRequest userRequest = new QueryFinTechUserRequest();
userRequest. setUserNameList(userNameList);
UserInfoResponse userInfoResponse =
finTechDataProviderService. queryFinTechUserInfo(userRequest);
if( userInfoResponse. getUserList()== null){
userConfigList. forEach(userConfig→{
SpecialPermissionUser user= new SpecialPermissionUser();
user. setUserName(userConfig. getUserName());
if (userConfig. getGlobalQuery()){
user. setSpecialPermission("是");
} else{
user. setSpecialPermission("否");
}
if(userConfig. getIsOfficeAllowLogin()){
user. setIsOfficeAllowLogin("是");
} else{
user. setIsOfficeAllowLogin("否");
}
SimpleDateFormat dateFormat = new
SimpleDateFormat("yyyy-MM-dd HH: mm: ss");
String s="9999-12-31 00:00:00";
Date effDate = userConfig. getQueryEffectiveDate();
if (effDate == null && (userConfig. getQueryPermanentFlag() == null||
userConfig. getQueryPermanentFlag() != true)) {
s="2020-01-01 00:00:00";
}
try{
if (effDate == null || userConfig. getQueryPermanentFlag()) {
effDate= dateFormat. parse(s);
}
} catch (ParseException e){
effDate= new Date();
log. error("查询全局查询团队异常",e);
)
user. setQueryEffectiveDate(effDate);
specialPermissionUsers. add( user);
});
return specialPermissionUsers;
}
userInfoResponse. getUserList(). forEach(userInfo->{
departmentIdList. add(userInfo. getOrgId());
});
QueryFinTechDeptRequest deptRequest= new QueryFinTechDeptRequest();
deptRequest. setDeptIdList(departmentIdList);
DeptInfoResponse deptInfoResponse
finTechDataProviderService. queryFinTechDeptInfo(deptRequest);
userConfigList. forEach(userConfig->{
userInfoResponse. getUserList(). forEach(userInfo->{
if (userConfig. getUserName(). equals(userInfo. getUserName())){
SpecialPermissionUser user= new SpecialPermissionUser();
user. setUserName(userInfo. getUserName());
user. setRealName(userInfo. getUserRealName());
if
(userConfig. getGlobalQuery()!= null&&userConfig. getGlobalQuery()) {
user. setSpecialPermission("是");
} else{
user. setSpecialPermission("否");
}
if(userConfig. getIsOfficeAllowLogin()){
user. setIsOfficeAllowLogin("是");
} else{
user. setIsOfficeAllowLogin("否");
}
deptInfoResponse. getDeptList(). forEach(deptInfo->{
if (userInfo. getOrgId(). equals(deptInfo. getOrgId())) {
user. setDepartmentName(deptInfo. getOrgName());
}
});
SimpleDateFormat dateFormat = new
SimpleDateFormat("yyyy-MM-dd HH: mm: ss");
String s="9999-12-31 00:00:00";
Date effDate = userConfig. getQueryEffectiveDate();
if (effDate == null && (userConfig. getQueryPermanentFlag()
== null || userConfig. getQueryPermanentFlag() != true)){
s="2020-01-01 00:00:00";
}
try{
if (effDate == null || userConfig. getQueryPermanentFlag()) {
effDate= dateFormat. parse(s);
}
} catch (ParseException e){
effDate= new Date();
log. error("查询全局查询团队异常",e);
}
user. setQueryEffectiveDate(effDate);
specialPermissionUsers. add( user);
}
});
});
return specialPermissionUsers;
}
public int getUserCount() {
Example example = new Example(UserConfig. class);
return userConfigMapper. selectCountByExample( example);
}
public void editUserConfig( String userName, Boolean flag){ userConfigMapper. updateByUserName(userName, flag);}
public void addUserConfig( String userNameArrayStr, Boolean flag){ String[] userNameArray= userNameArrayStr. split(";");
for( String userName:userNameArray) {
if(StringUtils. isBlank(userName)){
continue;
}
Example example = new Example(UserConfig. class); example. createCriteria(). andEqualTo("userName", userName); int count = userConfigMapper. selectCountByExample( example); if ( count ==0){
UserConfig userConfig= new UserConfig();
userConfig. setAuditAllUserFlag( false);
userConfig. setAdministratorFlag( false);
userConfig. setCreateTime( new Date());
userConfig. setGlobalQuery( false);
userConfig. setIsOfficeAllowLogin( flag);
userConfig. setQueryEffectiveDate( new Date());
userConfig. setQueryPermanentFlag( false);
userConfig. setUpdateTime( new Date());
userConfig. setUserName(userName);
userConfigMapper. insert(userConfig);
} else{
userConfigMapper. updateByUserName(userName, flag);
}
}
}
}

标签:userName,request,userConfig,user,new,userService,源代码,response
From: https://www.cnblogs.com/lmzzr24/p/18550379

相关文章

  • 【MATLAB代码】基于EKF的IMM,三个模型的交互,包括:CV,CA,CT,附源代码下载链接
    基于交互多模型(IMM)算法的目标跟踪,使用了三种运动模型:匀速运动(CV)、匀加速运动(CA)和匀转弯运动(CT)。滤波方法为EKF文章目录运行结果源代码运行结果详解代码详解概述主要功能代码详细介绍初始化与仿真参数设置定义模型参数状态转移矩阵定义生成真实数据IMM......
  • snapshot源代码
    @Service("snapshotService")@Slf4jpublicclassSnapshotServiceImplimplementsSnapshotService{@AutowiredprivateRestHighLevelClientrestHighLevelClient;@AutowiredprivateElasticSearchServiceelasticSearchService;@AutowiredprivateIndi......
  • 源代码
    importcom.example.entity.Department;importcom.example.mapper.DepartmentMapper;importcom.example.request.DelDepartmentPermissionRequest;importcom.example.response.DelDepartmentPermissionResponse;importcom.example.service.DepartmentPermissionServic......
  • 如何查看 SAP ABAP Kernel Module 的源代码
    StackOverflow上有个网友提问,想查看ABAP系统生成UUID方法,在KernelModulepf_create_uuid16c32里实现的源代码:https://stackoverflow.com/questions/42110195/how-to-open-kernel-module-in-abap笔者之前的文章提到,类似上图高亮这种ABAPKernelModule,通过C语......
  • 接口1源代码分析
    当然可以,下面是对addDepartmentPermission方法的详细解释,包括每一行代码的功能和作用:方法签名@Override@Transactional(rollbackFor=Exception.class)publicAddDepartmentPermissionResponseaddDepartmentPermission(AddDepartmentPermissionRequestrequest){@Over......
  • Ogre默认资源代码中加载
    //OgreResources Ogre::ResourceGroupManager::getSingleton().addResourceLocation(QString(OGRE_PLUGIN_DIR).toStdString()+"/../Media/Main","FileSystem","OgreInternal"); Ogre::ResourceGroupManager::getSingleton().addResour......
  • JAVA毕业设计198—基于Java+Springboot+vue3的健身房管理系统(源代码+数据库)
    毕设所有选题:https://blog.csdn.net/2303_76227485/article/details/131104075基于Java+Springboot+vue3的健身房管理系统(源代码+数据库)198一、系统介绍本项目前后端分离(可以改为ssm版本),分为用户、管理员两种角色1、用户:注册、登录、公告、论坛交流、健身课程购买......
  • AI带货主播背景替换与虚拟场景融合的源代码!
    AI带货主播作为新兴的直播形式,正在逐步改变我们的购物体验,借助先进的人工智能技术,带货主播可以在虚拟环境中进行直播,背景可以实时替换,场景也可以灵活变换。这不仅增强了直播的趣味性,也大大提升了观众的沉浸感,接下来,本文将分享一些关于AI带货主播背景替换与虚拟场景融合的源代......
  • 基于51单片机温湿度采集数码管手机app显示+源代码程序+proteus仿真+dht11温湿度传感器
    一、设计简介本项目是简单的物联网(IoT)应用,使用51单片机STC89C52与温湿度传感器DHT11相结合,测量温湿度数据显示在八位数码管,同时通过WiFi模块ESP8266(ESP-01S)将测得的温湿度数据发送到手机APP上,而手机APP则使用AppInventor进行开发。二、功能设计1、数码管实时显示当前温湿度......
  • 【matlab代码】3个模型的IMM例程(匀速、左转、右转),附源代码(可复制粘贴)
    文章目录3个模型的IMM源代码运行结果代码介绍总结3个模型的IMM代码实现了基于IMMIMMIMM(InteractingMultipleModel)算法的目标跟踪。它使用三种不同的运动模型(匀速直线运动、左转弯和右转弯)来预测目标的位置,并通过卡尔曼滤波进行状......