Browse Source

发布时添加发布范围

dev
zhaoqifeng 4 years ago
parent
commit
d5a1bb674e
  1. 24
      tduck-api/src/main/java/com/tduck/cloud/api/web/controller/UserProjectController.java
  2. 58
      tduck-project/src/main/java/com/tduck/cloud/project/entity/PrPublishRangeEntity.java
  3. 4
      tduck-project/src/main/java/com/tduck/cloud/project/entity/UserProjectEntity.java
  4. 14
      tduck-project/src/main/java/com/tduck/cloud/project/mapper/PrPublishRangeMapper.java
  5. 23
      tduck-project/src/main/java/com/tduck/cloud/project/request/PublishProjectRequest.java
  6. 32
      tduck-project/src/main/java/com/tduck/cloud/project/service/PrPublishRangeService.java
  7. 36
      tduck-project/src/main/java/com/tduck/cloud/project/service/impl/PrPublishRangeServiceImpl.java

24
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.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Sets; 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.constant.CommonConstants;
import com.tduck.cloud.common.entity.BaseEntity; import com.tduck.cloud.common.entity.BaseEntity;
import com.tduck.cloud.common.util.JsonUtils; 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.RedisUtils;
import com.tduck.cloud.common.util.Result; import com.tduck.cloud.common.util.Result;
import com.tduck.cloud.common.validator.ValidatorUtils; 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.ProjectSourceTypeEnum;
import com.tduck.cloud.project.entity.enums.ProjectStatusEnum; import com.tduck.cloud.project.entity.enums.ProjectStatusEnum;
import com.tduck.cloud.project.entity.struct.ItemDefaultValueStruct; import com.tduck.cloud.project.entity.struct.ItemDefaultValueStruct;
import com.tduck.cloud.project.request.OperateProjectItemRequest; import com.tduck.cloud.project.request.*;
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.service.*; import com.tduck.cloud.project.service.*;
import com.tduck.cloud.project.util.SortUtils; import com.tduck.cloud.project.util.SortUtils;
import com.tduck.cloud.project.vo.OperateProjectItemVO; import com.tduck.cloud.project.vo.OperateProjectItemVO;
@ -71,7 +70,7 @@ public class UserProjectController {
private final WxMpUserService wxMpUserService; private final WxMpUserService wxMpUserService;
private final RedisUtils redisUtils; private final RedisUtils redisUtils;
private final WxMpService wxMpService; private final WxMpService wxMpService;
private final PrPublishRangeService publishRangeService;
/** /**
* 创建项目 * 创建项目
@ -187,14 +186,27 @@ public class UserProjectController {
*/ */
@Login @Login
@PostMapping("/user/project/publish") @PostMapping("/user/project/publish")
public Result publishProject(@RequestBody UserProjectEntity request) { public Result publishProject(@RequestBody PublishProjectRequest request) {
int count = projectItemService int count = projectItemService
.count(Wrappers.<UserProjectItemEntity>lambdaQuery().eq(UserProjectItemEntity::getProjectKey, request.getKey())); .count(Wrappers.<UserProjectItemEntity>lambdaQuery().eq(UserProjectItemEntity::getProjectKey, request.getKey()));
if (count == CommonConstants.ConstantNumber.ZERO) { if (count == CommonConstants.ConstantNumber.ZERO) {
return Result.failed("无有效表单项,无法发布"); return Result.failed("无有效表单项,无法发布");
} }
//获取旧的发布范围
List<PrPublishRangeEntity> publishRangeList = publishRangeService.list(Wrappers.<PrPublishRangeEntity>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()); UserProjectEntity entity = projectService.getByKey(request.getKey());
entity.setStatus(ProjectStatusEnum.RELEASE); entity.setStatus(ProjectStatusEnum.RELEASE);
entity.setClient(request.getClient());
return Result.success(projectService.updateById(entity)); return Result.success(projectService.updateById(entity));
} }

58
tduck-project/src/main/java/com/tduck/cloud/project/entity/PrPublishRangeEntity.java

@ -0,0 +1,58 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PrPublishRangeEntity> {
private static final long serialVersionUID = 1L;
/**
* 项目key
*/
private String projectKey;
/**
* 范围组织ids,格式与组织维度一致 冒号隔开 即选中节点的全路径id
*/
private String orgIds;
/**
* 最后发布组织的ID
*/
private String orgId;
/**
* 最后发布组织的类型departmentagencygrid
*/
private String orgType;
}

4
tduck-project/src/main/java/com/tduck/cloud/project/entity/UserProjectEntity.java

@ -71,5 +71,9 @@ public class UserProjectEntity extends BaseEntity<UserProjectEntity> {
*/ */
private Boolean recycled; private Boolean recycled;
/**
* 适用于哪个端 resi居民端用户gov工作端用户
*/
private String client;
} }

14
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<PrPublishRangeEntity> {
}

23
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<PrPublishRangeEntity> rangeList;
}

32
tduck-project/src/main/java/com/tduck/cloud/project/service/PrPublishRangeService.java

@ -0,0 +1,32 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PrPublishRangeEntity> {
}

36
tduck-project/src/main/java/com/tduck/cloud/project/service/impl/PrPublishRangeServiceImpl.java

@ -0,0 +1,36 @@
/**
* Copyright 2018 人人开源 https://www.renren.io
* <p>
* 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.
* <p>
* 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.
* <p>
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
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<PrPublishRangeMapper, PrPublishRangeEntity> implements PrPublishRangeService {
}
Loading…
Cancel
Save