diff --git a/tduck-api/src/main/java/com/tduck/cloud/api/web/controller/UserProjectController.java b/tduck-api/src/main/java/com/tduck/cloud/api/web/controller/UserProjectController.java index c4678ce..b46b9fd 100644 --- a/tduck-api/src/main/java/com/tduck/cloud/api/web/controller/UserProjectController.java +++ b/tduck-api/src/main/java/com/tduck/cloud/api/web/controller/UserProjectController.java @@ -5,6 +5,7 @@ import cn.hutool.core.util.IdUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.collect.Sets; @@ -13,6 +14,7 @@ import com.tduck.cloud.api.util.HttpUtils; import com.tduck.cloud.common.constant.CommonConstants; import com.tduck.cloud.common.entity.BaseEntity; import com.tduck.cloud.common.util.JsonUtils; +import com.tduck.cloud.common.util.LoginUserUtil; import com.tduck.cloud.common.util.RedisUtils; import com.tduck.cloud.common.util.Result; import com.tduck.cloud.common.validator.ValidatorUtils; @@ -23,10 +25,7 @@ import com.tduck.cloud.project.entity.*; import com.tduck.cloud.project.entity.enums.ProjectSourceTypeEnum; import com.tduck.cloud.project.entity.enums.ProjectStatusEnum; import com.tduck.cloud.project.entity.struct.ItemDefaultValueStruct; -import com.tduck.cloud.project.request.OperateProjectItemRequest; -import com.tduck.cloud.project.request.QueryProjectItemRequest; -import com.tduck.cloud.project.request.QueryProjectRequest; -import com.tduck.cloud.project.request.SortProjectItemRequest; +import com.tduck.cloud.project.request.*; import com.tduck.cloud.project.service.*; import com.tduck.cloud.project.util.SortUtils; import com.tduck.cloud.project.vo.OperateProjectItemVO; @@ -71,7 +70,7 @@ public class UserProjectController { private final WxMpUserService wxMpUserService; private final RedisUtils redisUtils; private final WxMpService wxMpService; - + private final PrPublishRangeService publishRangeService; /** * 创建项目 @@ -187,14 +186,27 @@ public class UserProjectController { */ @Login @PostMapping("/user/project/publish") - public Result publishProject(@RequestBody UserProjectEntity request) { + public Result publishProject(@RequestBody PublishProjectRequest request) { int count = projectItemService .count(Wrappers.lambdaQuery().eq(UserProjectItemEntity::getProjectKey, request.getKey())); if (count == CommonConstants.ConstantNumber.ZERO) { return Result.failed("无有效表单项,无法发布"); } + //获取旧的发布范围 + List publishRangeList = publishRangeService.list(Wrappers.lambdaQuery().eq(PrPublishRangeEntity::getProjectKey, request.getKey())); + if (CollectionUtils.isNotEmpty(publishRangeList)) { + //删除旧的发布范围 + publishRangeService.removeByIds(publishRangeList.stream().map(PrPublishRangeEntity::getId).collect(Collectors.toList())); + } + //保存发布范围 + request.getRangeList().forEach(item -> { + item.setProjectKey(request.getKey()); + }); + publishRangeService.saveBatch(request.getRangeList()); + UserProjectEntity entity = projectService.getByKey(request.getKey()); entity.setStatus(ProjectStatusEnum.RELEASE); + entity.setClient(request.getClient()); return Result.success(projectService.updateById(entity)); } diff --git a/tduck-project/src/main/java/com/tduck/cloud/project/entity/PrPublishRangeEntity.java b/tduck-project/src/main/java/com/tduck/cloud/project/entity/PrPublishRangeEntity.java new file mode 100644 index 0000000..50ff60c --- /dev/null +++ b/tduck-project/src/main/java/com/tduck/cloud/project/entity/PrPublishRangeEntity.java @@ -0,0 +1,58 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.tduck.cloud.project.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.tduck.cloud.common.entity.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 项目发布范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-15 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("pr_publish_range") +public class PrPublishRangeEntity extends BaseEntity { + + private static final long serialVersionUID = 1L; + + /** + * 项目key + */ + private String projectKey; + + /** + * 范围组织ids,格式与组织维度一致 冒号隔开 即选中节点的全路径id + */ + private String orgIds; + + /** + * 最后发布组织的ID + */ + private String orgId; + + /** + * 最后发布组织的类型;department,agency;grid + */ + private String orgType; + +} diff --git a/tduck-project/src/main/java/com/tduck/cloud/project/entity/UserProjectEntity.java b/tduck-project/src/main/java/com/tduck/cloud/project/entity/UserProjectEntity.java index 6104e05..6db6a00 100644 --- a/tduck-project/src/main/java/com/tduck/cloud/project/entity/UserProjectEntity.java +++ b/tduck-project/src/main/java/com/tduck/cloud/project/entity/UserProjectEntity.java @@ -71,5 +71,9 @@ public class UserProjectEntity extends BaseEntity { */ private Boolean recycled; + /** + * 适用于哪个端 resi:居民端用户;gov:工作端用户 + */ + private String client; } diff --git a/tduck-project/src/main/java/com/tduck/cloud/project/mapper/PrPublishRangeMapper.java b/tduck-project/src/main/java/com/tduck/cloud/project/mapper/PrPublishRangeMapper.java new file mode 100644 index 0000000..ff707c1 --- /dev/null +++ b/tduck-project/src/main/java/com/tduck/cloud/project/mapper/PrPublishRangeMapper.java @@ -0,0 +1,14 @@ +package com.tduck.cloud.project.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.tduck.cloud.project.entity.PrPublishRangeEntity; + +/** + * 项目发布范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-15 + */ +public interface PrPublishRangeMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/tduck-project/src/main/java/com/tduck/cloud/project/request/PublishProjectRequest.java b/tduck-project/src/main/java/com/tduck/cloud/project/request/PublishProjectRequest.java new file mode 100644 index 0000000..b41206f --- /dev/null +++ b/tduck-project/src/main/java/com/tduck/cloud/project/request/PublishProjectRequest.java @@ -0,0 +1,23 @@ +package com.tduck.cloud.project.request; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.tduck.cloud.common.validator.group.UpdateGroup; +import com.tduck.cloud.project.entity.PrPublishRangeEntity; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.util.List; + +/** + * @Description + * @Author zhaoqifeng + * @Date 2021/9/23 15:01 + */ +@Data +public class PublishProjectRequest { + @NotBlank(message = "项目Key不能为空", groups = {UpdateGroup.class}) + private String key; + @NotBlank(message = "发布范围不能为空", groups = {UpdateGroup.class}) + private String client; + private List rangeList; +} diff --git a/tduck-project/src/main/java/com/tduck/cloud/project/service/PrPublishRangeService.java b/tduck-project/src/main/java/com/tduck/cloud/project/service/PrPublishRangeService.java new file mode 100644 index 0000000..7e74e4b --- /dev/null +++ b/tduck-project/src/main/java/com/tduck/cloud/project/service/PrPublishRangeService.java @@ -0,0 +1,32 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.tduck.cloud.project.service; + + +import com.baomidou.mybatisplus.extension.service.IService; +import com.tduck.cloud.project.entity.PrPublishRangeEntity; + +/** + * 项目发布范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-15 + */ +public interface PrPublishRangeService extends IService { + +} \ No newline at end of file diff --git a/tduck-project/src/main/java/com/tduck/cloud/project/service/impl/PrPublishRangeServiceImpl.java b/tduck-project/src/main/java/com/tduck/cloud/project/service/impl/PrPublishRangeServiceImpl.java new file mode 100644 index 0000000..e844cd0 --- /dev/null +++ b/tduck-project/src/main/java/com/tduck/cloud/project/service/impl/PrPublishRangeServiceImpl.java @@ -0,0 +1,36 @@ +/** + * Copyright 2018 人人开源 https://www.renren.io + *

+ * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + *

+ * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + *

+ * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.tduck.cloud.project.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.tduck.cloud.project.entity.PrPublishRangeEntity; +import com.tduck.cloud.project.mapper.PrPublishRangeMapper; +import com.tduck.cloud.project.service.PrPublishRangeService; +import org.springframework.stereotype.Service; + +/** + * 项目发布范围表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2021-09-15 + */ +@Service("prPublishRangeService") +public class PrPublishRangeServiceImpl extends ServiceImpl implements PrPublishRangeService { + + +} \ No newline at end of file