|
|
@@ -0,0 +1,94 @@
|
|
|
+package com.zhongshu.card.server.core.service.config;
|
|
|
+
|
|
|
+import com.github.microservice.net.ResultContent;
|
|
|
+import com.zhongshu.card.client.model.config.ProjectUserConfigModel;
|
|
|
+import com.zhongshu.card.client.model.config.ProjectUserConfigParam;
|
|
|
+import com.zhongshu.card.server.core.dao.config.ProjectUserConfigDao;
|
|
|
+import com.zhongshu.card.server.core.domain.config.ProjectUserConfig;
|
|
|
+import com.zhongshu.card.server.core.service.base.SuperService;
|
|
|
+import com.zhongshu.card.server.core.util.BeanUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author TRX
|
|
|
+ * @date 2024/11/26
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+public class ProjectUserConfigService extends SuperService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProjectUserConfigDao projectUserConfigDao;
|
|
|
+
|
|
|
+ public ResultContent xcxSaveUserConfig(ProjectUserConfigParam param) {
|
|
|
+ if (StringUtils.isEmpty(param.getUserId())) {
|
|
|
+ param.setUserId(getCurrentUserId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(param.getProjectOid())) {
|
|
|
+ param.setProjectOid(getCurrentProjectOid());
|
|
|
+ }
|
|
|
+ return saveUserConfig(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ private ResultContent saveUserConfig(ProjectUserConfigParam param) {
|
|
|
+ if (StringUtils.isEmpty(param.getUserId())) {
|
|
|
+ return ResultContent.buildFail("userId为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(param.getProjectOid())) {
|
|
|
+ return ResultContent.buildFail("projectOid为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(param.getKey())) {
|
|
|
+ return ResultContent.buildFail("key为空");
|
|
|
+ }
|
|
|
+ ProjectUserConfig entity = projectUserConfigDao.findTopByProjectOidAndUserIdAndKey(param.getProjectOid(), param.getUserId(), param.getKey());
|
|
|
+ if (ObjectUtils.isEmpty(entity)) {
|
|
|
+ entity = new ProjectUserConfig();
|
|
|
+ }
|
|
|
+ entity.setProjectOid(param.getProjectOid());
|
|
|
+ entity.setUserId(param.getUserId());
|
|
|
+ entity.setKey(param.getKey());
|
|
|
+ entity.setData(param.getData());
|
|
|
+ projectUserConfigDao.save(entity);
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent<ProjectUserConfigModel> xcxGetUserConfig(ProjectUserConfigParam param) {
|
|
|
+ if (StringUtils.isEmpty(param.getUserId())) {
|
|
|
+ param.setUserId(getCurrentUserId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(param.getProjectOid())) {
|
|
|
+ param.setProjectOid(getCurrentProjectOid());
|
|
|
+ }
|
|
|
+ return getUserConfig(param);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultContent<ProjectUserConfigModel> getUserConfig(ProjectUserConfigParam param) {
|
|
|
+ if (StringUtils.isEmpty(param.getUserId())) {
|
|
|
+ return ResultContent.buildFail("userId为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(param.getProjectOid())) {
|
|
|
+ return ResultContent.buildFail("projectOid为空");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(param.getKey())) {
|
|
|
+ return ResultContent.buildFail("key为空");
|
|
|
+ }
|
|
|
+ ProjectUserConfig entity = projectUserConfigDao.findTopByProjectOidAndUserIdAndKey(param.getProjectOid(), param.getUserId(), param.getKey());
|
|
|
+ ProjectUserConfigModel model = toModel(entity);
|
|
|
+ if (StringUtils.isEmpty(model.getKey())) {
|
|
|
+ model.setKey(param.getKey());
|
|
|
+ }
|
|
|
+ return ResultContent.buildSuccess(model);
|
|
|
+ }
|
|
|
+
|
|
|
+ private ProjectUserConfigModel toModel(ProjectUserConfig entity) {
|
|
|
+ ProjectUserConfigModel model = new ProjectUserConfigModel();
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
+ BeanUtils.copyProperties(entity, model);
|
|
|
+ }
|
|
|
+ return model;
|
|
|
+ }
|
|
|
+}
|