-
Notifications
You must be signed in to change notification settings - Fork 364
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature]:添加修改问卷,删除问卷接口,增加相关单元测试 (#369)
* feat: 1,添加修改问卷,删除问卷接口,修改创建问卷 部分逻辑 2,添加修改问卷,删除问卷接口单元测试 * feat: 1,添加修改问卷,删除问卷接口,修改创建问卷 部分逻辑 2,添加修改问卷,删除问卷接口单元测试 * style:代码格式化调整 * style:代码格式化调整 --------- Co-authored-by: kui <[email protected]>
- Loading branch information
Showing
14 changed files
with
508 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
survey-common/src/main/java/com/xiaojusurvey/engine/common/entity/survey/SurveyPublish.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.xiaojusurvey.engine.common.entity.survey; | ||
|
||
import com.xiaojusurvey.engine.common.entity.BaseEntity; | ||
import lombok.Data; | ||
import lombok.EqualsAndHashCode; | ||
import lombok.ToString; | ||
import org.springframework.data.mongodb.core.mapping.Document; | ||
|
||
import javax.validation.constraints.NotBlank; | ||
import javax.validation.constraints.NotNull; | ||
|
||
/** | ||
* 问卷发布后的配置表 | ||
* | ||
* @author [email protected] | ||
* @date: 2024/7/27 13:59 | ||
*/ | ||
@Document("surveySubmit") | ||
@EqualsAndHashCode(callSuper = true) | ||
@ToString(callSuper = true) | ||
@Data | ||
public class SurveyPublish extends BaseEntity { | ||
|
||
/** | ||
* 问卷配置ID | ||
*/ | ||
@NotBlank(message = "问卷配置ID不能为空") | ||
@NotNull(message = "问卷配置ID不能为空") | ||
private String pageId; | ||
|
||
/** | ||
* 问卷标题 | ||
*/ | ||
@NotBlank(message = "问卷标题不能为空") | ||
@NotNull(message = "问卷标题不能为空") | ||
private String title; | ||
/** | ||
* 问卷短链 | ||
*/ | ||
@NotBlank(message = "问卷短链不能为空") | ||
@NotNull(message = "问卷短链不能为空") | ||
private String surveyPath; | ||
/** | ||
* 问卷schema | ||
*/ | ||
@NotBlank(message = "问卷schema不能为空") | ||
@NotNull(message = "问卷schema不能为空") | ||
private String code; | ||
|
||
|
||
} |
37 changes: 37 additions & 0 deletions
37
survey-common/src/main/java/com/xiaojusurvey/engine/common/enums/SurveyStatusEnum.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package com.xiaojusurvey.engine.common.enums; | ||
|
||
import com.xiaojusurvey.engine.common.entity.Status; | ||
|
||
/** | ||
* Survey状态 | ||
* | ||
* @author [email protected] | ||
* @Date 2024/7/26 23:32 | ||
*/ | ||
public enum SurveyStatusEnum { | ||
NEW("new"), | ||
EDITING("editing"), | ||
PAUSING("pausing"), | ||
PUBLISHED("published"), | ||
REMOVED("removed"), | ||
FORCE_REMOVED("FORCE_REMOVED"); | ||
|
||
private String status; | ||
|
||
SurveyStatusEnum(String status) { | ||
this.status = status; | ||
} | ||
|
||
public String getStatus() { | ||
return this.status; | ||
} | ||
|
||
|
||
public static Status getSpecStatus(SurveyStatusEnum statusEnum) { | ||
Status newStatus = new Status(); | ||
newStatus.setStatus(statusEnum.getStatus()); | ||
newStatus.setDate(System.currentTimeMillis()); | ||
return newStatus; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
survey-core/src/main/java/com/xiaojusurvey/engine/core/survey/SurveyPublishService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.xiaojusurvey.engine.core.survey; | ||
|
||
import com.xiaojusurvey.engine.common.entity.survey.SurveyMeta; | ||
|
||
/** | ||
* 问卷发布配置服务 | ||
* | ||
* @author [email protected] | ||
* @date: 2024/7/27 13:54 | ||
*/ | ||
public interface SurveyPublishService { | ||
|
||
|
||
boolean delete(SurveyMeta param); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...core/src/main/java/com/xiaojusurvey/engine/core/survey/impl/SurveyPublishServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.xiaojusurvey.engine.core.survey.impl; | ||
|
||
import com.xiaojusurvey.engine.common.entity.Status; | ||
import com.xiaojusurvey.engine.common.entity.survey.SurveyMeta; | ||
import com.xiaojusurvey.engine.common.entity.survey.SurveyPublish; | ||
import com.xiaojusurvey.engine.common.enums.SurveyStatusEnum; | ||
import com.xiaojusurvey.engine.core.survey.SurveyPublishService; | ||
import com.xiaojusurvey.engine.repository.MongoRepository; | ||
import org.springframework.data.mongodb.core.query.Criteria; | ||
import org.springframework.data.mongodb.core.query.Query; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.util.StringUtils; | ||
|
||
import javax.annotation.Resource; | ||
|
||
/** | ||
* 问卷发布配置服务实现 | ||
* | ||
* @author [email protected] | ||
* @Date 2024/7/27 14:02 | ||
*/ | ||
@Service | ||
public class SurveyPublishServiceImpl implements SurveyPublishService { | ||
@Resource | ||
private MongoRepository mongoRepository; | ||
|
||
public MongoRepository getMongoRepository() { | ||
return mongoRepository; | ||
} | ||
|
||
public void setMongoRepository(MongoRepository mongoRepository) { | ||
this.mongoRepository = mongoRepository; | ||
} | ||
|
||
|
||
@Override | ||
public boolean delete(SurveyMeta param) { | ||
if (StringUtils.hasLength(param.getSurveyPath())) { | ||
SurveyPublish surveyPublish = getBysurveyPath(param.getSurveyPath()); | ||
if (surveyPublish != null) { | ||
Status st = SurveyStatusEnum.getSpecStatus(SurveyStatusEnum.PUBLISHED); | ||
surveyPublish.setCurStatus(st); | ||
surveyPublish.getStatusList().add(st); | ||
mongoRepository.save(surveyPublish); | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
public SurveyPublish getBysurveyPath(String surveyPath) { | ||
Query query = new Query(); | ||
query.addCriteria(Criteria.where("surveyPath").is(surveyPath)); | ||
SurveyPublish surveyPublish = mongoRepository.findOne(query, SurveyPublish.class); | ||
return surveyPublish; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.