初始代码

This commit is contained in:
wangmingwei
2026-04-21 16:49:46 +08:00
parent aae9dc4036
commit f0453ff3a3
2396 changed files with 256575 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>yunzhupaas-app</artifactId>
<groupId>com.yunzhupaas</groupId>
<version>5.2.0-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>yunzhupaas-app-biz</artifactId>
<dependencies>
<dependency>
<groupId>com.yunzhupaas</groupId>
<artifactId>yunzhupaas-app-entity</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.yunzhupaas</groupId>
<artifactId>yunzhupaas-permission-biz</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.yunzhupaas</groupId>
<artifactId>yunzhupaas-system-biz</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@@ -0,0 +1,17 @@
package com.yunzhupaas.mapper;
import com.yunzhupaas.base.mapper.SuperMapper;
import com.yunzhupaas.entity.AppDataEntity;
/**
* app常用数据
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024-07-08
*/
public interface AppDataMapper extends SuperMapper<AppDataEntity> {
}

View File

@@ -0,0 +1,57 @@
package com.yunzhupaas.service;
import com.yunzhupaas.base.service.SuperService;
import com.yunzhupaas.entity.AppDataEntity;
import java.util.List;
/**
* app常用数据
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024-08-08
*/
public interface AppDataService extends SuperService<AppDataEntity> {
/**
* 列表
*
* @return
*/
List<AppDataEntity> getList();
/**
* 信息
*
* @param objectId 对象主键
* @return
*/
AppDataEntity getInfo(String objectId);
/**
* 验证名称
*
* @param objectId 对象主键
* @return
*/
boolean isExistByObjectId(String objectId, String systemId);
/**
* 创建
*
* @param entity 实体对象
*/
void create(AppDataEntity entity);
/**
* 删除
*
* @param entity 实体对象
*/
void delete(AppDataEntity entity);
}

View File

@@ -0,0 +1,29 @@
package com.yunzhupaas.service;
import com.yunzhupaas.model.AppUserInfoVO;
import com.yunzhupaas.model.AppUsersVO;
/**
* app用户信息
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024-08-08
*/
public interface AppService {
/**
* app用户信息
* @return
*/
AppUsersVO userInfo();
/**
* 通讯录
* @return
*/
AppUserInfoVO getInfo(String id);
}

View File

@@ -0,0 +1,72 @@
package com.yunzhupaas.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.base.service.SuperServiceImpl;
import com.yunzhupaas.entity.AppDataEntity;
import com.yunzhupaas.mapper.AppDataMapper;
import com.yunzhupaas.service.AppDataService;
import com.yunzhupaas.util.RandomUtil;
import com.yunzhupaas.util.UserProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* app常用数据
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024-08-08
*/
@Service
public class AppDataServiceImpl extends SuperServiceImpl<AppDataMapper, AppDataEntity> implements AppDataService {
@Override
public List<AppDataEntity> getList() {
QueryWrapper<AppDataEntity> queryWrapper = new QueryWrapper<>();
return this.list(queryWrapper);
}
@Override
public AppDataEntity getInfo(String objectId) {
UserInfo userInfo = UserProvider.getUser();
QueryWrapper<AppDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(AppDataEntity::getObjectId, objectId).eq(AppDataEntity::getCreatorUserId, userInfo.getUserId());
return this.getOne(queryWrapper);
}
@Override
public boolean isExistByObjectId(String objectId, String systemId) {
UserInfo userInfo = UserProvider.getUser();
QueryWrapper<AppDataEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(AppDataEntity::getObjectId, objectId)
.eq(AppDataEntity::getCreatorUserId, userInfo.getUserId())
.eq(AppDataEntity::getSystemId, systemId);
return this.count(queryWrapper) > 0 ? true : false;
}
@Override
public void create(AppDataEntity entity) {
UserInfo userInfo = UserProvider.getUser();
entity.setId(RandomUtil.uuId());
entity.setCreatorUserId(userInfo.getUserId());
entity.setCreatorTime(new Date());
entity.setEnabledMark(1);
entity.setSystemId(userInfo.getAppSystemId());
this.save(entity);
}
@Override
public void delete(AppDataEntity entity) {
this.removeById(entity.getId());
}
}

View File

@@ -0,0 +1,163 @@
package com.yunzhupaas.service.impl;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.ObjectUtil;
import com.yunzhupaas.base.UserInfo;
import com.yunzhupaas.base.entity.DictionaryDataEntity;
import com.yunzhupaas.base.service.DictionaryDataService;
import com.yunzhupaas.model.AppPositionVO;
import com.yunzhupaas.model.AppUserInfoVO;
import com.yunzhupaas.model.AppUsersVO;
import com.yunzhupaas.permission.entity.*;
import com.yunzhupaas.permission.service.*;
import com.yunzhupaas.service.AppService;
import com.yunzhupaas.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* app用户信息
*
* @author 云筑产品开发平台组
* @version V3.1.0
* @copyright 深圳市乐程软件有限公司
* @date 2024-08-08
*/
@Service
public class AppServiceImpl implements AppService {
@Autowired
private UserService userService;
@Autowired
private PositionService positionService;
@Autowired
private OrganizeService organizeService;
@Autowired
private RoleService roleService;
@Autowired
private RedisUtil redisUtil;
@Autowired
private UserRelationService userRelationService;
@Autowired
private DictionaryDataService dictionaryDataService;
@Override
public AppUsersVO userInfo() {
UserInfo userInfo = UserProvider.getUser();
UserEntity userEntity = userService.getInfo(userInfo.getUserId());
AppUsersVO usersVO = new AppUsersVO();
usersVO.setBirthday(userEntity.getBirthday() != null ? userEntity.getBirthday().getTime() : null);
usersVO.setEmail(userEntity.getEmail());
List<DictionaryDataEntity> dataServiceList4 = dictionaryDataService.getListByTypeDataCode("sex");
Map<String, String> dataServiceMap4 = dataServiceList4.stream().filter(t -> ObjectUtil.equal(t.getEnabledMark(), 1)).collect(Collectors.toMap(DictionaryDataEntity::getEnCode, DictionaryDataEntity::getFullName));
usersVO.setGender(dataServiceMap4.get(userEntity.getGender()));
usersVO.setMobilePhone(userEntity.getMobilePhone());
this.data(usersVO, userEntity, userInfo);
this.userInfo(usersVO, userInfo);
//岗位
PositionEntity position = positionService.getInfo(userEntity.getPositionId());
AppPositionVO positionVO = new AppPositionVO();
if(position != null){
positionVO.setId(position.getId());
positionVO.setName(position.getFullName());
usersVO.setPositionIds(ListUtil.toList(positionVO));
}
//直属主管
if(StringUtil.isNotEmpty(userEntity.getManagerId())){
UserEntity menager = userService.getInfo(userEntity.getManagerId());
usersVO.setManager(menager != null ? menager.getRealName() + "/" + menager.getAccount() : "");
}
//角色
List<String> roles = roleService.getAllRoleIdsByUserIdAndOrgId(userInfo.getUserId(), usersVO.getOrganizeId());
List<RoleEntity> roleList = roleService.getListByIds(roles, null, false);
usersVO.setRoleName(String.join("", roleList.stream().map(RoleEntity::getFullName).collect(Collectors.toList())));
usersVO.setRoleId(String.join(".", roleList.stream().map(RoleEntity::getId).collect(Collectors.toList())));
return usersVO;
}
@Override
public AppUserInfoVO getInfo(String id) {
AppUserInfoVO userInfoVO = new AppUserInfoVO();
UserEntity entity = userService.getInfo(id);
if (entity != null) {
userInfoVO = JsonUtil.getJsonToBean(entity, AppUserInfoVO.class);
List<String> positionIds = StringUtil.isNotEmpty(entity.getPositionId()) ? Arrays.asList(entity.getPositionId().split(",")) : new ArrayList<>();
List<String> positionName = positionService.getPositionName(positionIds, false).stream().map(t -> t.getFullName()).collect(Collectors.toList());
userInfoVO.setPositionName(String.join(",", positionName));
OrganizeEntity info = organizeService.getInfo(entity.getOrganizeId());
userInfoVO.setOrganizeName(info != null ? info.getFullName() : "");
userInfoVO.setHeadIcon(UploaderUtil.uploaderImg(userInfoVO.getHeadIcon()));
}
return userInfoVO;
}
/**
* 赋值
*
* @param userInfo
* @param userId
* @param isAdmin
*/
private void userInfo(UserInfo userInfo, String userId, boolean isAdmin, UserEntity userEntity) {
List<String> userIdList = new ArrayList(){{add(userId);}};
List<UserRelationEntity> data = userRelationService.getListByUserIdAll(userIdList);
//获取一个字段的值
List<String> positionList = data.stream().filter(m -> "Position".equals(m.getObjectType())).map(t -> t.getObjectId()).collect(Collectors.toList());
Set<String> id = new LinkedHashSet<>();
String[] position = StringUtil.isNotEmpty(userEntity.getPositionId()) ? userEntity.getPositionId().split(",") : new String[]{};
List<String> positions = positionList.stream().filter(t->Arrays.asList(position).contains(t)).collect(Collectors.toList());
id.addAll(positions);
id.addAll(positionList);
userInfo.setPositionIds(id.toArray(new String[id.size()]));
if (!isAdmin) {
data = data.stream().filter(m -> "Role".equals(m.getObjectType())).collect(Collectors.toList());
}
List<String> roleList = data.stream().map(t -> t.getObjectId()).collect(Collectors.toList());
userInfo.setRoleIds(roleList);
}
private void data(AppUsersVO usersVO, UserEntity userEntity, UserInfo userInfo) {
//组织
usersVO.setOrganizeId(userEntity.getOrganizeId());
List<OrganizeEntity> organizeIdList = new ArrayList<>();
organizeService.getOrganizeId(userEntity.getOrganizeId(),organizeIdList);
Collections.reverse(organizeIdList);
usersVO.setOrganizeName(organizeIdList.stream().map(OrganizeEntity::getFullName).collect(Collectors.joining("/")));
OrganizeEntity organizeEntity = organizeIdList.stream().filter(t->t.getId().equals(userEntity.getOrganizeId())).findFirst().orElse(null);
if (organizeEntity != null) {
String[] organizeId = StringUtil.isNotEmpty(organizeEntity.getOrganizeIdTree()) ? organizeEntity.getOrganizeIdTree().split(",") : new String[]{};
if (organizeId.length > 0) {
userInfo.setOrganizeId(organizeId[0]);
userInfo.setDepartmentId(organizeId[organizeId.length - 1]);
}
}
userInfo.setManagerId(userInfo.getManagerId());
boolean b = userInfo.getIsAdministrator();
List<String> subordinateIdsList = userService.getListByManagerId(userInfo.getUserId(),null).stream().map(UserEntity::getId).collect(Collectors.toList());
userInfo.setSubordinateIds(subordinateIdsList);
this.userInfo(userInfo, userInfo.getUserId(), b,userEntity);
// userInfo.setSubOrganizeIds(new String[]{});
//redisUtil.insert(userInfo.getId(), userInfo, DateUtil.getTime(userInfo.getOverdueTime()) - DateUtil.getTime(new Date()));
UserProvider.setLoginUser(userInfo);
UserProvider.setLocalLoginUser(userInfo);
}
/**
* 登录信息
*
* @param appUsersVO 返回对象
* @param userInfo 回话信息
* @return
*/
private void userInfo(AppUsersVO appUsersVO, UserInfo userInfo) {
appUsersVO.setUserId(userInfo.getUserId());
appUsersVO.setHeadIcon(UploaderUtil.uploaderImg(userInfo.getUserIcon()));
appUsersVO.setUserName(userInfo.getUserName());
appUsersVO.setUserAccount(userInfo.getUserAccount());
}
}