|
@@ -4,15 +4,22 @@ import com.github.microservice.net.ResultContent;
|
|
|
import com.zhongshu.card.client.model.config.ProjectUserConfigModel;
|
|
import com.zhongshu.card.client.model.config.ProjectUserConfigModel;
|
|
|
import com.zhongshu.card.client.model.config.ProjectUserConfigParam;
|
|
import com.zhongshu.card.client.model.config.ProjectUserConfigParam;
|
|
|
import com.zhongshu.card.server.core.dao.config.ProjectUserConfigDao;
|
|
import com.zhongshu.card.server.core.dao.config.ProjectUserConfigDao;
|
|
|
|
|
+import com.zhongshu.card.server.core.dataConfig.UserProjectTaskConfig;
|
|
|
import com.zhongshu.card.server.core.domain.config.ProjectUserConfig;
|
|
import com.zhongshu.card.server.core.domain.config.ProjectUserConfig;
|
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
|
|
+import com.zhongshu.card.server.core.util.CommonUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @author TRX
|
|
* @author TRX
|
|
|
* @date 2024/11/26
|
|
* @date 2024/11/26
|
|
@@ -24,6 +31,55 @@ public class ProjectUserConfigService extends SuperService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ProjectUserConfigDao projectUserConfigDao;
|
|
private ProjectUserConfigDao projectUserConfigDao;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 得到项目中用户所有的配置
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param userId
|
|
|
|
|
+ * @param projectId
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public Map<String, Object> getProjectUserConfigs(String userId, String projectId) {
|
|
|
|
|
+ if (StringUtils.isEmpty(userId)) {
|
|
|
|
|
+ userId = getCurrentUserId();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isEmpty(projectId)) {
|
|
|
|
|
+ projectId = getCurrentProjectOid();
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
+ List<String> keys = CommonUtil.getClassAllStringStatic(UserProjectTaskConfig.class);
|
|
|
|
|
+ List<ProjectUserConfig> list = getUserProjectConfigs(userId, projectId, keys);
|
|
|
|
|
+ Map<String, Object> tempMap = new HashMap<>();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(list)) {
|
|
|
|
|
+ tempMap = list.stream().collect(Collectors.toMap(
|
|
|
|
|
+ it -> it.getKey(),
|
|
|
|
|
+ it -> it.getData(),
|
|
|
|
|
+ (v1, v2) -> v1
|
|
|
|
|
+ ));
|
|
|
|
|
+ }
|
|
|
|
|
+ for (String key : keys) {
|
|
|
|
|
+ if (tempMap.containsKey(key)) {
|
|
|
|
|
+ map.put(key, tempMap.get(key));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ map.put(key, Boolean.FALSE);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return map;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public ResultContent saveUserConfig(String key, Object data) {
|
|
|
|
|
+ ProjectUserConfigParam param = new ProjectUserConfigParam();
|
|
|
|
|
+ if (StringUtils.isEmpty(param.getUserId())) {
|
|
|
|
|
+ param.setUserId(getCurrentUserId());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isEmpty(param.getProjectOid())) {
|
|
|
|
|
+ param.setProjectOid(getCurrentProjectOid());
|
|
|
|
|
+ }
|
|
|
|
|
+ param.setKey(key);
|
|
|
|
|
+ param.setData(data);
|
|
|
|
|
+ return saveUserConfig(param);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 保存小程序用户配置
|
|
* 保存小程序用户配置
|
|
|
*
|
|
*
|
|
@@ -88,7 +144,7 @@ public class ProjectUserConfigService extends SuperService {
|
|
|
if (StringUtils.isEmpty(param.getKey())) {
|
|
if (StringUtils.isEmpty(param.getKey())) {
|
|
|
return ResultContent.buildFail("key为空");
|
|
return ResultContent.buildFail("key为空");
|
|
|
}
|
|
}
|
|
|
- ProjectUserConfig entity = projectUserConfigDao.findTopByProjectOidAndUserIdAndKey(param.getProjectOid(), param.getUserId(), param.getKey());
|
|
|
|
|
|
|
+ ProjectUserConfig entity = getUserProjectConfig(param.getUserId(), param.getProjectOid(), param.getKey());
|
|
|
ProjectUserConfigModel model = toModel(entity);
|
|
ProjectUserConfigModel model = toModel(entity);
|
|
|
if (StringUtils.isEmpty(model.getKey())) {
|
|
if (StringUtils.isEmpty(model.getKey())) {
|
|
|
if (ObjectUtils.isEmpty(model)) {
|
|
if (ObjectUtils.isEmpty(model)) {
|
|
@@ -99,6 +155,32 @@ public class ProjectUserConfigService extends SuperService {
|
|
|
return ResultContent.buildSuccess(model);
|
|
return ResultContent.buildSuccess(model);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public ProjectUserConfig getUserProjectConfig(String userId, String projectOid, String key) {
|
|
|
|
|
+ if (StringUtils.isEmpty(userId)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isEmpty(projectOid)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isEmpty(key)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return projectUserConfigDao.findTopByProjectOidAndUserIdAndKey(projectOid, userId, key);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public List<ProjectUserConfig> getUserProjectConfigs(String userId, String projectOid, List<String> keys) {
|
|
|
|
|
+ if (StringUtils.isEmpty(userId)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isEmpty(projectOid)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ObjectUtils.isEmpty(keys)) {
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
|
|
+ return projectUserConfigDao.findByProjectOidAndUserIdAndKeyIn(projectOid, userId, keys);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private ProjectUserConfigModel toModel(ProjectUserConfig entity) {
|
|
private ProjectUserConfigModel toModel(ProjectUserConfig entity) {
|
|
|
ProjectUserConfigModel model = new ProjectUserConfigModel();
|
|
ProjectUserConfigModel model = new ProjectUserConfigModel();
|
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|
|
if (ObjectUtils.isNotEmpty(entity)) {
|