Skip to content

Commit 66a4ea0

Browse files
author
jianggang
authored
feat: add access guide (#21)
* feat: add access guide
1 parent b841472 commit 66a4ea0

20 files changed

Lines changed: 522 additions & 102 deletions

src/main/java/com/featureprobe/api/base/enums/ResourceType.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
public enum ResourceType {
88
PROJECT("projectKey"), TOGGLE("toggleKey"), ENVIRONMENT("environmentKey"),
9-
MEMBER("account"),SEGMENT("segment");
9+
MEMBER("account"),SEGMENT("segment"),DICTIONARY("dictionary");
1010

1111
private String paramName;
1212

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package com.featureprobe.api.base.enums;
2+
3+
public enum VisitFilter {
4+
5+
IN_WEEK_VISITED, OUT_WEEK_VISITED, NOT_VISITED
6+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.featureprobe.api.controller;
2+
3+
import com.featureprobe.api.base.doc.DefaultApiResponses;
4+
import com.featureprobe.api.dto.DictionaryResponse;
5+
import com.featureprobe.api.service.DictionaryService;
6+
import lombok.AllArgsConstructor;
7+
import org.springframework.web.bind.annotation.GetMapping;
8+
import org.springframework.web.bind.annotation.PathVariable;
9+
import org.springframework.web.bind.annotation.PostMapping;
10+
import org.springframework.web.bind.annotation.RequestBody;
11+
import org.springframework.web.bind.annotation.RequestMapping;
12+
import org.springframework.web.bind.annotation.RestController;
13+
14+
@RequestMapping("/dictionaries")
15+
@RestController
16+
@DefaultApiResponses
17+
@AllArgsConstructor
18+
public class DictionaryController {
19+
20+
private DictionaryService dictionaryService;
21+
22+
@GetMapping("/{key}")
23+
public DictionaryResponse query(@PathVariable("key") String key) {
24+
return dictionaryService.query(key);
25+
}
26+
27+
@PostMapping("/{key}")
28+
public DictionaryResponse save(@PathVariable("key") String key,
29+
@RequestBody String value) {
30+
return dictionaryService.save(key, value);
31+
}
32+
33+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.featureprobe.api.dto;
2+
3+
import lombok.Data;
4+
5+
import java.util.Date;
6+
7+
@Data
8+
public class DictionaryResponse {
9+
10+
private String key;
11+
12+
private String value;
13+
14+
private Date modifiedTime;
15+
16+
private Date createdTime;
17+
18+
}

src/main/java/com/featureprobe/api/dto/TargetingVersionResponse.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,6 @@ public class TargetingVersionResponse {
2323
private Long version;
2424

2525
private Date createdTime;
26+
27+
private String createdBy;
2628
}

src/main/java/com/featureprobe/api/dto/ToggleSearchRequest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.featureprobe.api.dto;
22

3+
import com.featureprobe.api.base.enums.VisitFilter;
34
import lombok.Data;
45

56
import javax.validation.constraints.NotBlank;
@@ -11,7 +12,7 @@ public class ToggleSearchRequest extends PaginationRequest {
1112
@NotBlank
1213
private String environmentKey;
1314

14-
private Boolean isVisited;
15+
private VisitFilter visitFilter;
1516

1617
private Boolean disabled;
1718

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.featureprobe.api.entity;
2+
3+
import com.featureprobe.api.base.entity.AbstractAuditEntity;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Builder;
6+
import lombok.Data;
7+
import lombok.EqualsAndHashCode;
8+
import lombok.NoArgsConstructor;
9+
import lombok.ToString;
10+
import org.hibernate.annotations.DynamicInsert;
11+
import org.hibernate.annotations.Where;
12+
13+
import javax.persistence.Column;
14+
import javax.persistence.Entity;
15+
import javax.persistence.Table;
16+
17+
@EqualsAndHashCode(callSuper = true)
18+
@NoArgsConstructor
19+
@AllArgsConstructor
20+
@Data
21+
@Builder
22+
@Entity
23+
@Table(name = "dictionary")
24+
@ToString(callSuper = true)
25+
@Where(clause = "deleted = 0")
26+
@DynamicInsert
27+
public class Dictionary extends AbstractAuditEntity {
28+
29+
private String value;
30+
31+
@Column(name = "[key]")
32+
private String key;
33+
34+
private String account;
35+
36+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.featureprobe.api.entity;
2+
3+
import com.featureprobe.api.base.constants.MetricType;
4+
import lombok.AllArgsConstructor;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
7+
import lombok.ToString;
8+
import org.hibernate.annotations.DynamicInsert;
9+
10+
import javax.persistence.Column;
11+
import javax.persistence.Entity;
12+
import javax.persistence.GeneratedValue;
13+
import javax.persistence.GenerationType;
14+
import javax.persistence.Id;
15+
import javax.persistence.Table;
16+
import java.util.Date;
17+
18+
@NoArgsConstructor
19+
@AllArgsConstructor
20+
@Data
21+
@Entity
22+
@Table(name = "metrics_cache")
23+
@DynamicInsert
24+
@ToString(callSuper = true)
25+
public class MetricsCache {
26+
27+
@Id
28+
@GeneratedValue(strategy = GenerationType.IDENTITY)
29+
private Long id;
30+
31+
@Column(name = "sdk_key")
32+
private String sdkKey;
33+
34+
@Column(name = "toggle_key")
35+
private String toggleKey;
36+
37+
private String data;
38+
39+
@Column(name = "start_date")
40+
private Date startDate;
41+
42+
@Column(name = "end_date")
43+
private Date endDate;
44+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.featureprobe.api.mapper;
2+
3+
import com.featureprobe.api.dto.DictionaryResponse;
4+
import com.featureprobe.api.entity.Dictionary;
5+
import org.mapstruct.Mapper;
6+
import org.mapstruct.factory.Mappers;
7+
8+
@Mapper
9+
public interface DictionaryMapper {
10+
11+
DictionaryMapper INSTANCE = Mappers.getMapper(DictionaryMapper.class);
12+
13+
DictionaryResponse entityToResponse(Dictionary dictionary);
14+
}

src/main/java/com/featureprobe/api/mapper/TargetingVersionMapper.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
import org.mapstruct.factory.Mappers;
1010

1111
@Mapper
12-
public interface TargetingVersionMapper {
12+
public interface TargetingVersionMapper extends BaseMapper {
1313

1414
TargetingVersionMapper INSTANCE = Mappers.getMapper(TargetingVersionMapper.class);
1515

1616
@Mapping(target = "content",
1717
expression = "java(toTargetingContent(targetingVersion.getContent()))")
18+
@Mapping(target = "createdBy", expression = "java(getAccount(targetingVersion.getCreatedBy()))")
1819
TargetingVersionResponse entityToResponse(TargetingVersion targetingVersion);
1920

2021
default TargetingContent toTargetingContent(String content) {

0 commit comments

Comments
 (0)