Commit bc10e8bc authored by zhuxiang's avatar zhuxiang
Browse files

画布接口增加团体

parent 71cc9168
...@@ -90,8 +90,8 @@ ...@@ -90,8 +90,8 @@
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<configuration> <configuration>
<source>8</source> <source>9</source>
<target>8</target> <target>9</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>
......
...@@ -4,10 +4,7 @@ import com.platform.model.dto.UserDTO; ...@@ -4,10 +4,7 @@ import com.platform.model.dto.UserDTO;
import com.platform.model.resp.Result; import com.platform.model.resp.Result;
import com.platform.service.UserService; import com.platform.service.UserService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -19,13 +16,13 @@ public class UserController extends BaseController { ...@@ -19,13 +16,13 @@ public class UserController extends BaseController {
private UserService userService; private UserService userService;
@ApiOperation(value = "用户详情") @ApiOperation(value = "用户详情")
@RequestMapping("/detail") @GetMapping("/detail")
public Result detail(@RequestParam String userName) { public Result detail(@RequestParam String userName) {
return Result.data(userService.getDetail(userName)); return Result.data(userService.getDetail(userName));
} }
@ApiOperation(value = "编辑用户信息") @ApiOperation(value = "编辑用户信息")
@RequestMapping("/update") @PutMapping("/update")
public Result update(@RequestBody UserDTO userDTO) { public Result update(@RequestBody UserDTO userDTO) {
return toAjax(userService.updateUser(userDTO)); return toAjax(userService.updateUser(userDTO));
} }
......
...@@ -18,14 +18,17 @@ public class EdgeVO { ...@@ -18,14 +18,17 @@ public class EdgeVO {
private double totalAmount; private double totalAmount;
private String groupId;
private List<String> states; private List<String> states;
public EdgeVO(String id, String source, String target, int totalTransactions, double totalAmount) { public EdgeVO(String id, String source, String target, int totalTransactions, double totalAmount, String groupId) {
this.id = id; this.id = id;
this.source = source; this.source = source;
this.target = target; this.target = target;
this.totalTransactions = totalTransactions; this.totalTransactions = totalTransactions;
this.totalAmount = totalAmount; this.totalAmount = totalAmount;
this.groupId = groupId;
} }
} }
...@@ -12,9 +12,12 @@ public class GraphVO { ...@@ -12,9 +12,12 @@ public class GraphVO {
private List<EdgeVO> edges; private List<EdgeVO> edges;
private List<GroupVO> groups;
public GraphVO() { public GraphVO() {
this.nodes = new ArrayList<>(); this.nodes = new ArrayList<>();
this.edges = new ArrayList<>(); this.edges = new ArrayList<>();
this.groups = new ArrayList<>();
} }
public void addNode(NodeVO node) { public void addNode(NodeVO node) {
...@@ -24,4 +27,8 @@ public class GraphVO { ...@@ -24,4 +27,8 @@ public class GraphVO {
public void addEdge(EdgeVO edge) { public void addEdge(EdgeVO edge) {
edges.add(edge); edges.add(edge);
} }
public void addGroup(GroupVO groupVO) {
groups.add(groupVO);
}
} }
package com.platform.model.vo;
import lombok.Data;
@Data
public class GroupVO {
private String groupName; // 团体名
private int groupSize; // 团体人数
private double totalAmount; // 团体资金总量
private int totalTransactions; // 交易总次数
public GroupVO(String groupName, int groupSize, double totalAmount, int totalTransactions) {
this.groupName = groupName;
this.groupSize = groupSize;
this.totalAmount = totalAmount;
this.totalTransactions = totalTransactions;
}
}
package com.platform.model.vo;
import lombok.Data;
import java.util.HashMap;
import java.util.Map;
@Data
public class UnionFindVO {
private Map<String, String> parent;
private Map<String, Integer> rank;
public UnionFindVO() {
parent = new HashMap<>();
rank = new HashMap<>();
}
public void makeSet(String node) {
parent.put(node, node);
rank.put(node, 0);
}
public String find(String node) {
if (!parent.containsKey(node)) {
makeSet(node);
}
if (!parent.get(node).equals(node)) {
parent.put(node, find(parent.get(node))); // 路径压缩
}
return parent.get(node);
}
public void union(String node1, String node2) {
String root1 = find(node1);
String root2 = find(node2);
if (!root1.equals(root2)) {
if (rank.get(root1) > rank.get(root2)) {
parent.put(root2, root1);
} else if (rank.get(root1) < rank.get(root2)) {
parent.put(root1, root2);
} else {
parent.put(root2, root1);
rank.put(root1, rank.get(root1) + 1);
}
}
}
public Map<String, String> getParent() {
return parent;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment