22 changed files with 238 additions and 18 deletions
@ -1,19 +1,48 @@ |
|||
package com.tduck.cloud.api.web.controller; |
|||
|
|||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|||
import com.tduck.cloud.api.annotation.Login; |
|||
import com.tduck.cloud.common.util.Result; |
|||
import com.tduck.cloud.project.entity.UserProjectItemEntity; |
|||
import com.tduck.cloud.project.entity.UserProjectLogicEntity; |
|||
import com.tduck.cloud.project.service.UserProjectLogicService; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author : smalljop |
|||
* @description : 项目 |
|||
* @description : 项目逻辑 |
|||
* @create : 2020-11-18 18:17 |
|||
**/ |
|||
@RequiredArgsConstructor |
|||
@RestController |
|||
@Slf4j |
|||
@RestController |
|||
@RequiredArgsConstructor |
|||
public class UserProjectLogicController { |
|||
|
|||
private final UserProjectLogicService projectLogicService; |
|||
|
|||
@Login |
|||
@PostMapping("/user/project/logic/save") |
|||
public Result saveUserProjectLogic(@RequestBody UserProjectLogicEntity userProjectLogicEntity) { |
|||
projectLogicService.saveOrUpdate(userProjectLogicEntity); |
|||
return Result.success(userProjectLogicEntity); |
|||
} |
|||
|
|||
|
|||
@Login |
|||
@PostMapping("/user/project/logic/delete") |
|||
public Result deleteUserProjectLogic(@RequestBody UserProjectLogicEntity userProjectLogicEntity) { |
|||
return Result.success(projectLogicService.removeById(userProjectLogicEntity)); |
|||
} |
|||
|
|||
@Login |
|||
@GetMapping("/user/project/logic/list") |
|||
public Result queryProjectItem(@RequestParam @NotBlank String projectKey) { |
|||
List<UserProjectLogicEntity> entityList = projectLogicService.list(Wrappers.<UserProjectLogicEntity>lambdaQuery().eq(UserProjectLogicEntity::getProjectKey, projectKey)); |
|||
return Result.success(entityList); |
|||
} |
|||
} |
@ -0,0 +1,66 @@ |
|||
package com.tduck.cloud.project.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.tduck.cloud.common.entity.BaseEntity; |
|||
import com.tduck.cloud.common.mybatis.handler.JacksonTypeHandler; |
|||
import com.tduck.cloud.project.entity.enums.ProjectLogicExpressionEnum; |
|||
import lombok.Data; |
|||
import lombok.experimental.Accessors; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import java.util.Set; |
|||
|
|||
/** |
|||
* 项目逻辑(UserProjectLogic)表实体类 |
|||
* |
|||
* @author smalljop |
|||
* @since 2020-05-01 13:36:27 |
|||
*/ |
|||
@Data |
|||
@Accessors(chain = true) |
|||
@TableName(value = "pr_user_project_logic", autoResultMap = true) |
|||
public class UserProjectLogicEntity extends BaseEntity<UserProjectLogicEntity> { |
|||
private Long id; |
|||
/** |
|||
* 项目key |
|||
*/ |
|||
@NotBlank(message = "projectKey不能为空") |
|||
private String projectKey; |
|||
/** |
|||
* 表单项Id |
|||
*/ |
|||
private Long formItemId; |
|||
/** |
|||
* 条件成立的表达式 |
|||
*/ |
|||
private ProjectLogicExpressionEnum expression; |
|||
|
|||
|
|||
/** |
|||
* 条件 |
|||
*/ |
|||
@TableField(typeHandler = JacksonTypeHandler.class) |
|||
private Set<Condition> conditionList; |
|||
|
|||
|
|||
/** |
|||
* 条件 |
|||
*/ |
|||
@Data |
|||
public static class Condition { |
|||
/** |
|||
* 表单项Id |
|||
*/ |
|||
private Long formItemId; |
|||
/** |
|||
* 表达式 |
|||
*/ |
|||
private String expression; |
|||
/** |
|||
* 选项 |
|||
*/ |
|||
private Object optionValue; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.tduck.cloud.project.entity.enums; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.EnumValue; |
|||
import com.fasterxml.jackson.annotation.JsonCreator; |
|||
import com.fasterxml.jackson.annotation.JsonValue; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
|
|||
/** |
|||
* @author : smalljop |
|||
* @description :逻辑条件 |
|||
* @create : 2020-12-04 13:35 |
|||
**/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum ProjectLogicConditionExpressionEnum { |
|||
|
|||
EQ("eq", "等于"), |
|||
NE("ne", "不等于"); |
|||
|
|||
|
|||
@EnumValue |
|||
@JsonValue |
|||
private String value; |
|||
|
|||
private String desc; |
|||
|
|||
|
|||
/** |
|||
* 枚举入参注解 |
|||
* |
|||
* @param value |
|||
* @return |
|||
*/ |
|||
@JsonCreator |
|||
public static ProjectLogicConditionExpressionEnum getByValue(Integer value) { |
|||
for (ProjectLogicConditionExpressionEnum typeEnum : values()) { |
|||
if (typeEnum.getValue().equals(value)) { |
|||
return typeEnum; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
@ -0,0 +1,45 @@ |
|||
package com.tduck.cloud.project.entity.enums; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.EnumValue; |
|||
import com.fasterxml.jackson.annotation.JsonCreator; |
|||
import com.fasterxml.jackson.annotation.JsonValue; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
|
|||
/** |
|||
* @author : smalljop |
|||
* @description :逻辑条件 |
|||
* @create : 2020-12-04 13:35 |
|||
**/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum ProjectLogicExpressionEnum { |
|||
|
|||
ALL(1, "全部"), |
|||
ANY(2, "任意"); |
|||
|
|||
|
|||
@EnumValue |
|||
@JsonValue |
|||
private Integer value; |
|||
|
|||
private String desc; |
|||
|
|||
|
|||
/** |
|||
* 枚举入参注解 |
|||
* |
|||
* @param value |
|||
* @return |
|||
*/ |
|||
@JsonCreator |
|||
public static ProjectLogicExpressionEnum getByValue(Integer value) { |
|||
for (ProjectLogicExpressionEnum typeEnum : values()) { |
|||
if (typeEnum.getValue().equals(value)) { |
|||
return typeEnum; |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
@ -0,0 +1,15 @@ |
|||
package com.tduck.cloud.project.mapper; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.tduck.cloud.project.entity.UserProjectEntity; |
|||
import com.tduck.cloud.project.entity.UserProjectLogicEntity; |
|||
|
|||
/** |
|||
* 用户项目逻辑表(UserProjectLogic)表数据库访问层 |
|||
* |
|||
* @author smalljop |
|||
* @since 2020-11-18 18:16:17 |
|||
*/ |
|||
public interface UserProjectLogicMapper extends BaseMapper<UserProjectLogicEntity> { |
|||
|
|||
} |
@ -0,0 +1,7 @@ |
|||
package com.tduck.cloud.project.service; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.tduck.cloud.project.entity.UserProjectLogicEntity; |
|||
|
|||
public interface UserProjectLogicService extends IService<UserProjectLogicEntity> { |
|||
} |
@ -0,0 +1,12 @@ |
|||
package com.tduck.cloud.project.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.tduck.cloud.project.entity.UserProjectLogicEntity; |
|||
import com.tduck.cloud.project.mapper.UserProjectLogicMapper; |
|||
import com.tduck.cloud.project.service.UserProjectLogicService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
|
|||
@Service("userProjectLogicService") |
|||
public class UserProjectLogicServiceImpl extends ServiceImpl<UserProjectLogicMapper, UserProjectLogicEntity> implements UserProjectLogicService { |
|||
} |
Loading…
Reference in new issue