diff --git a/FindFriends/Server/.gitignore b/FindFriends/Server/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..549e00a2a96fa9d7c5dbc9859664a78d980158c2
--- /dev/null
+++ b/FindFriends/Server/.gitignore
@@ -0,0 +1,33 @@
+HELP.md
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
diff --git a/FindFriends/Server/README.en.md b/FindFriends/Server/README.en.md
new file mode 100644
index 0000000000000000000000000000000000000000..1ceff60e7a03c6d6b5e1c95a4979b693e5a3f365
--- /dev/null
+++ b/FindFriends/Server/README.en.md
@@ -0,0 +1,3 @@
+### Description
+
+This is a server for finding friends.
diff --git a/FindFriends/Server/README.md b/FindFriends/Server/README.md
new file mode 100644
index 0000000000000000000000000000000000000000..2e57e1a08756658e3f93f99305eebc194d78c9e3
--- /dev/null
+++ b/FindFriends/Server/README.md
@@ -0,0 +1,3 @@
+### 介绍
+
+这是一个找朋友的服务端案例。
diff --git a/FindFriends/Server/pom.xml b/FindFriends/Server/pom.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f482988ad661a27ec745680163571097c66bfbf7
--- /dev/null
+++ b/FindFriends/Server/pom.xml
@@ -0,0 +1,98 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.3.4.RELEASE
+
+
+ com.example
+ gauss
+ 0.0.1-SNAPSHOT
+ gauss
+ Demo project for Spring Boot
+
+
+ 1.8
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+ org.projectlombok
+ lombok
+ true
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+ io.springfox
+ springfox-boot-starter
+ 3.0.0
+
+
+ mysql
+ mysql-connector-java
+ 8.0.21
+
+
+ org.gauss
+ java-connector
+ 1.0.1
+
+
+ com.baomidou
+ mybatis-plus-generator
+ 3.4.0
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.4.0
+
+
+ org.apache.velocity
+ velocity-engine-core
+ 2.2
+
+
+ junit
+ junit
+ 4.12
+
+
+ javax.xml.bind
+ jaxb-api
+ 2.3.1
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/GaussApplication.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/GaussApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..c296de813e9d83cd99164add5b171aee08e9e06e
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/GaussApplication.java
@@ -0,0 +1,20 @@
+package com.lamdaer.opengauss.gauss;
+
+import org.mybatis.spring.annotation.MapperScan;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.context.annotation.ComponentScan;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/23
+ */
+@SpringBootApplication
+@ComponentScan(basePackages = "com.lamdaer")
+@MapperScan(basePackages = "com.lamdaer.opengauss.gauss.mapper")
+public class GaussApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(GaussApplication.class, args);
+
+ }
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/GaussException.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/GaussException.java
new file mode 100644
index 0000000000000000000000000000000000000000..9e5c0b408a6d9062aee729e9c5b057dff57a098e
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/GaussException.java
@@ -0,0 +1,17 @@
+package com.lamdaer.opengauss.gauss.common;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/23
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class GaussException extends RuntimeException {
+ private Integer code;
+ private String message;
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/GlobalExceptionHandler.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/GlobalExceptionHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..7230585a035854e1365f88dc4f09daa7bbcdbb12
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/GlobalExceptionHandler.java
@@ -0,0 +1,40 @@
+package com.lamdaer.opengauss.gauss.common;
+
+import org.springframework.web.bind.MethodArgumentNotValidException;
+import org.springframework.web.bind.annotation.ControllerAdvice;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.ResponseBody;
+
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/23
+ */
+@Slf4j
+@ControllerAdvice
+public class GlobalExceptionHandler {
+ @ExceptionHandler(GaussException.class)
+ @ResponseBody
+ public Result customError(GaussException e) {
+ e.printStackTrace();
+ log.error(e.toString());
+ return Result.error().message(e.getMessage());
+ }
+
+ @ExceptionHandler(MethodArgumentNotValidException.class)
+ @ResponseBody
+ public Result methodArgumentNotValid(MethodArgumentNotValidException e) {
+ e.printStackTrace();
+ log.error(e.toString());
+ return Result.error().message(e.getBindingResult().getFieldError().getDefaultMessage());
+ }
+
+ @ExceptionHandler(Exception.class)
+ @ResponseBody
+ public Result exception(Exception e) {
+ e.printStackTrace();
+ log.error(e.toString());
+ return Result.error().message(e.getMessage());
+ }
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/Result.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/Result.java
new file mode 100644
index 0000000000000000000000000000000000000000..7dfc4f2a89051b52226b6492e1e996481905e1f4
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/Result.java
@@ -0,0 +1,58 @@
+package com.lamdaer.opengauss.gauss.common;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import lombok.Data;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/23
+ */
+@Data
+public class Result {
+ private Boolean success;
+ private Integer code;
+ private String message;
+ private Map data = new HashMap<>();
+
+ private Result() {
+ }
+
+ public static Result ok() {
+ Result result = new Result();
+ result.setSuccess(true);
+ result.setCode(ResultCode.SUCCESS);
+ result.setMessage("成功");
+ return result;
+ }
+
+ public static Result error() {
+ Result result = new Result();
+ result.setSuccess(false);
+ result.setCode(ResultCode.ERROR);
+ result.setMessage("失败");
+ return result;
+ }
+
+ public Result success(Boolean success) {
+ this.setSuccess(success);
+ return this;
+ }
+
+ public Result code(Integer code) {
+ this.setCode(code);
+ return this;
+ }
+
+ public Result message(String message) {
+ this.setMessage(message);
+ return this;
+ }
+
+ public Result data(String key, Object value) {
+ this.data.put(key, value);
+ return this;
+ }
+}
+
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/ResultCode.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/ResultCode.java
new file mode 100644
index 0000000000000000000000000000000000000000..a8990079aa615f557f992d34120dee43d234667c
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/common/ResultCode.java
@@ -0,0 +1,10 @@
+package com.lamdaer.opengauss.gauss.common;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/23
+ */
+public interface ResultCode {
+ Integer SUCCESS = 20000;
+ Integer ERROR = 20001;
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/config/JacksonConfig.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/config/JacksonConfig.java
new file mode 100644
index 0000000000000000000000000000000000000000..8fa33d8a2d9cd898daed0561d5dd069854f82bb3
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/config/JacksonConfig.java
@@ -0,0 +1,27 @@
+package com.lamdaer.opengauss.gauss.config;
+
+import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/24
+ */
+@Configuration
+public class JacksonConfig {
+
+ /**
+ * Jackson 全局转化 Long 类型为String,解决前端 Long 类型精度丢失问题
+ * @return Jackson2ObjectMapperBuilderCustomizer 注入的对象
+ */
+ @Bean
+ public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
+ return jacksonObjectMapperBuilder -> {
+ jacksonObjectMapperBuilder.serializerByType(Long.TYPE, ToStringSerializer.instance);
+ jacksonObjectMapperBuilder.serializerByType(Long.class, ToStringSerializer.instance);
+ };
+ }
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/HobbyController.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/HobbyController.java
new file mode 100644
index 0000000000000000000000000000000000000000..3f0aebf0de89bf5a44770e7c16fbfafc10d48a7a
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/HobbyController.java
@@ -0,0 +1,50 @@
+package com.lamdaer.opengauss.gauss.controller;
+
+
+import java.util.List;
+
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.lamdaer.opengauss.gauss.common.Result;
+import com.lamdaer.opengauss.gauss.entity.Hobby;
+import com.lamdaer.opengauss.gauss.entity.vo.HobbyVo;
+import com.lamdaer.opengauss.gauss.service.HobbyService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ *
+ * 爱好二级分类 前端控制器
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@Api(tags = "爱好")
+@RestController
+@RequestMapping("/gauss/hobby")
+public class HobbyController {
+ @Autowired
+ private HobbyService hobbyService;
+
+ @ApiOperation("添加爱好")
+ @PostMapping
+ public Result addHobby(@RequestBody @Valid HobbyVo hobbyVo) {
+ hobbyService.addHobby(hobbyVo);
+ return Result.ok();
+ }
+ @ApiOperation("获取爱好列表")
+ @GetMapping
+ public Result getHobbyList() {
+ List hobbyList = hobbyService.getHobbyList();
+ return Result.ok().data("hobbyList", hobbyList);
+ }
+}
+
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/HobbyParentController.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/HobbyParentController.java
new file mode 100644
index 0000000000000000000000000000000000000000..c709627a4b2ffaba204ff974792ae347cb17048e
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/HobbyParentController.java
@@ -0,0 +1,57 @@
+package com.lamdaer.opengauss.gauss.controller;
+
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.lamdaer.opengauss.gauss.common.Result;
+import com.lamdaer.opengauss.gauss.entity.HobbyParent;
+import com.lamdaer.opengauss.gauss.entity.vo.HobbyParentVo;
+import com.lamdaer.opengauss.gauss.service.HobbyParentService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ *
+ * 爱好一级分类 前端控制器
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@Api(tags = "爱好一级分类")
+@RestController
+@RequestMapping("/gauss/hobby_parent")
+public class HobbyParentController {
+
+ @Autowired
+ private HobbyParentService hobbyParentService;
+
+ @ApiOperation("添加爱好一级分类")
+ @PostMapping
+ public Result addHobbyParent(String name) {
+ hobbyParentService.addHobbyParent(name);
+ return Result.ok();
+ }
+
+ @ApiOperation("获取爱好一级分类")
+ @GetMapping
+ public Result getHobbyParentList() {
+ List hobbyParentList = hobbyParentService.getHobbyParentList();
+ return Result.ok().data("hobbyParentList", hobbyParentList);
+ }
+
+ @ApiOperation("获取爱好一级分类及其子分类")
+ @GetMapping("with_children")
+ public Result getHobbyParentListWithChildren() {
+ List list = hobbyParentService.getHobbyParentListWithChildren();
+ return Result.ok().data("list", list);
+ }
+
+}
+
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/JobController.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/JobController.java
new file mode 100644
index 0000000000000000000000000000000000000000..00c8a029295de9ebc913c4251fce0b347f90f9dd
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/JobController.java
@@ -0,0 +1,49 @@
+package com.lamdaer.opengauss.gauss.controller;
+
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.lamdaer.opengauss.gauss.common.Result;
+import com.lamdaer.opengauss.gauss.entity.Job;
+import com.lamdaer.opengauss.gauss.service.JobService;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+/**
+ *
+ * 岗位 前端控制器
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@Api(tags = "岗位")
+@RestController
+@RequestMapping("/gauss/job")
+public class JobController {
+ @Autowired
+ private JobService jobService;
+
+ @ApiOperation("添加岗位")
+ @PostMapping
+ public Result addJob(@RequestParam String name) {
+ jobService.addJob(name);
+ return Result.ok();
+ }
+
+ @ApiOperation("获取岗位列表")
+ @GetMapping
+ public Result getJobList() {
+ List jobList = jobService.getJobList();
+ return Result.ok().data("jobList", jobList);
+ }
+
+}
+
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/SimilarityController.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/SimilarityController.java
new file mode 100644
index 0000000000000000000000000000000000000000..61e32a5412d3b5a17b5d01a90e9b0bef495a77d6
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/SimilarityController.java
@@ -0,0 +1,33 @@
+package com.lamdaer.opengauss.gauss.controller;
+
+import java.util.List;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.lamdaer.opengauss.gauss.common.Result;
+import com.lamdaer.opengauss.gauss.entity.UserInfo;
+import com.lamdaer.opengauss.gauss.service.SimilarityService;
+
+import io.swagger.annotations.ApiOperation;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/24
+ */
+@RestController
+@RequestMapping("/gauss/similarity")
+public class SimilarityController {
+ @Autowired
+ private SimilarityService similarityService;
+
+ @ApiOperation("相似度检测")
+ @GetMapping("{userId}")
+ public Result getSimilarUser(@PathVariable Long userId) {
+ List userList = similarityService.similarity(userId);
+ return Result.ok().data("similarUser", userList);
+ }
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/UserInfoController.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/UserInfoController.java
new file mode 100644
index 0000000000000000000000000000000000000000..bd66bdd70d00ea55092e326d998e251f06938a8f
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/controller/UserInfoController.java
@@ -0,0 +1,48 @@
+package com.lamdaer.opengauss.gauss.controller;
+
+
+import javax.validation.Valid;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.lamdaer.opengauss.gauss.common.Result;
+import com.lamdaer.opengauss.gauss.entity.UserInfo;
+import com.lamdaer.opengauss.gauss.entity.vo.UserInfoVo;
+import com.lamdaer.opengauss.gauss.service.UserInfoService;
+
+import io.swagger.annotations.ApiOperation;
+
+/**
+ *
+ * 用户信息 前端控制器
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@RestController
+@RequestMapping("/gauss/user_info")
+public class UserInfoController {
+
+ @Autowired
+ private UserInfoService userInfoService;
+
+ @ApiOperation("添加用户信息")
+ @PostMapping
+ public Result addUserInfo(@RequestBody @Valid UserInfoVo userInfoVo) {
+ Long userId = userInfoService.add(userInfoVo);
+ return Result.ok().data("userId", userId);
+ }
+
+ @GetMapping("{userId}")
+ public Result getUserInfo(@PathVariable Long userId) {
+ UserInfo userInfo = userInfoService.getById(userId);
+ return Result.ok().data("userInfo", userInfo);
+ }
+}
+
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/Hobby.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/Hobby.java
new file mode 100644
index 0000000000000000000000000000000000000000..69071237138e6ca747734736b2e4ce7377c72566
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/Hobby.java
@@ -0,0 +1,34 @@
+package com.lamdaer.opengauss.gauss.entity;
+
+import java.io.Serializable;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ *
+ * 爱好二级分类
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value = "Hobby对象", description = "爱好二级分类")
+public class Hobby implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "爱好id")
+ private Long id;
+
+ @ApiModelProperty(value = "一级分类id")
+ private Long parentId;
+
+ @ApiModelProperty(value = "爱好名称")
+ private String name;
+
+
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/HobbyParent.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/HobbyParent.java
new file mode 100644
index 0000000000000000000000000000000000000000..3a9268fdc171f5070ae7c83ac5bac8d25dce9278
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/HobbyParent.java
@@ -0,0 +1,31 @@
+package com.lamdaer.opengauss.gauss.entity;
+
+import java.io.Serializable;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ *
+ * 爱好一级分类
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value = "HobbyParent对象", description = "爱好一级分类")
+public class HobbyParent implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "爱好一级分类id")
+ private Long id;
+
+ @ApiModelProperty(value = "爱好名称")
+ private String name;
+
+
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/Job.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/Job.java
new file mode 100644
index 0000000000000000000000000000000000000000..efdfea962a0a4dc752dd6b2bb119bba9ea312e35
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/Job.java
@@ -0,0 +1,31 @@
+package com.lamdaer.opengauss.gauss.entity;
+
+import java.io.Serializable;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ *
+ * 岗位
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value = "Job对象", description = "岗位")
+public class Job implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "岗位id")
+ private Long id;
+
+ @ApiModelProperty(value = "岗位名称")
+ private String name;
+
+
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/UserInfo.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/UserInfo.java
new file mode 100644
index 0000000000000000000000000000000000000000..ceab0c948f1f7384d24405a6c18a18e8d14f0b96
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/UserInfo.java
@@ -0,0 +1,56 @@
+package com.lamdaer.opengauss.gauss.entity;
+
+import java.io.Serializable;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ *
+ * 用户信息
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value = "UserInfo对象", description = "用户信息")
+public class UserInfo implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ @ApiModelProperty(value = "用户id")
+ @TableId(value = "user_id", type = IdType.ASSIGN_ID)
+ private Long userId;
+
+ @ApiModelProperty(value = "岗位id")
+ private Long jobId;
+
+ @ApiModelProperty(value = "爱好id")
+ private String hobbyIdList;
+
+ @ApiModelProperty(value = "性别 1 男性 2女性")
+ private Integer sex;
+
+ @ApiModelProperty(value = "姓名")
+ private String name;
+
+ @ApiModelProperty(value = "年龄")
+ private Integer age;
+
+ @ApiModelProperty(value = "手机号")
+ private String phoneNumber;
+
+ @ApiModelProperty(value = "昵称")
+ private String nickName;
+
+ @ApiModelProperty(value = "头像url")
+ private String avatarUrl;
+
+
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/HobbyListVo.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/HobbyListVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..289f097d8df625db2579a3b49aa3c869b6ed8b13
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/HobbyListVo.java
@@ -0,0 +1,25 @@
+package com.lamdaer.opengauss.gauss.entity.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/24
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class HobbyListVo {
+ @ApiModelProperty(value = "爱好id")
+ private Long id;
+
+ @ApiModelProperty(value = "一级分类id")
+ private Long parentId;
+
+ @ApiModelProperty(value = "爱好名称")
+ private String text;
+
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/HobbyParentVo.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/HobbyParentVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..4c4a4be861c0b3800972ef5014ab6d51e02e44ff
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/HobbyParentVo.java
@@ -0,0 +1,28 @@
+package com.lamdaer.opengauss.gauss.entity.vo;
+
+import java.util.List;
+
+import com.lamdaer.opengauss.gauss.entity.Hobby;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/24
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class HobbyParentVo {
+ @ApiModelProperty(value = "爱好一级分类id")
+ private Long id;
+
+ @ApiModelProperty(value = "爱好名称")
+ private String text;
+
+ @ApiModelProperty(value = "爱好二级分类列表")
+ private List children;
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/HobbyVo.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/HobbyVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..8e778c0678f31e80f884cba706fc2feee36d9149
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/HobbyVo.java
@@ -0,0 +1,28 @@
+package com.lamdaer.opengauss.gauss.entity.vo;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/24
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class HobbyVo {
+ @NotNull(message = "patentId can not be empty.")
+ @ApiModelProperty(value = "一级分类id")
+ private Long parentId;
+
+ @NotBlank(message = "name can not be empty.")
+ @ApiModelProperty(value = "爱好名称")
+ private String name;
+
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/UserInfoVo.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/UserInfoVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..5a60641203a812130330dd16f462d5acb9dc4e2a
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/entity/vo/UserInfoVo.java
@@ -0,0 +1,57 @@
+package com.lamdaer.opengauss.gauss.entity.vo;
+
+import java.util.List;
+
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/24
+ */
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class UserInfoVo {
+ @ApiModelProperty(value = "岗位id")
+ @NotNull(message = "jobId can not be empty.")
+ private Long jobId;
+
+ @ApiModelProperty(value = "爱好id")
+ @NotEmpty(message = "hobbyIdList can not be empty.")
+ private List hobbyIdList;
+
+ @ApiModelProperty(value = "性别 1 男性 2女性")
+ @NotNull(message = "sex can not be empty.")
+ @Min(value = 1, message = "Illegal parameter.")
+ @Max(value = 2, message = "Illegal parameter.")
+ private Integer sex;
+
+ @ApiModelProperty(value = "年龄")
+ @NotNull(message = "age can not be empty.")
+ private Integer age;
+
+ @ApiModelProperty(value = "姓名")
+ @NotBlank(message = "name can not be empty.")
+ private String name;
+
+ @ApiModelProperty(value = "手机号")
+ @NotBlank(message = "phoneNumber can not be empty.")
+ private String phoneNumber;
+
+ @ApiModelProperty(value = "昵称")
+ @NotBlank(message = "nickName can not be empty.")
+ private String nickName;
+
+ @ApiModelProperty(value = "头像url")
+ @NotBlank(message = "avatarUrl can not be empty.")
+ private String avatarUrl;
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/HobbyMapper.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/HobbyMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..ddc9c8b8a40a8e826a235b9baa104473e3f9cd88
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/HobbyMapper.java
@@ -0,0 +1,15 @@
+package com.lamdaer.opengauss.gauss.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.lamdaer.opengauss.gauss.entity.Hobby;
+
+/**
+ *
+ * 爱好二级分类 Mapper 接口
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+public interface HobbyMapper extends BaseMapper {
+
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/HobbyParentMapper.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/HobbyParentMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..6f269f99adfc4eb7f7bffb93fb169214f5af5a5b
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/HobbyParentMapper.java
@@ -0,0 +1,15 @@
+package com.lamdaer.opengauss.gauss.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.lamdaer.opengauss.gauss.entity.HobbyParent;
+
+/**
+ *
+ * 爱好一级分类 Mapper 接口
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+public interface HobbyParentMapper extends BaseMapper {
+
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/JobMapper.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/JobMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..46e1943f9b4509d04bb7048de24551c2a474c93d
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/JobMapper.java
@@ -0,0 +1,15 @@
+package com.lamdaer.opengauss.gauss.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.lamdaer.opengauss.gauss.entity.Job;
+
+/**
+ *
+ * 岗位 Mapper 接口
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+public interface JobMapper extends BaseMapper {
+
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/UserInfoMapper.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/UserInfoMapper.java
new file mode 100644
index 0000000000000000000000000000000000000000..c625e4713040ef956c86266361838bc8789bf8d1
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/UserInfoMapper.java
@@ -0,0 +1,16 @@
+package com.lamdaer.opengauss.gauss.mapper;
+
+import com.lamdaer.opengauss.gauss.entity.UserInfo;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ *
+ * 用户信息 Mapper 接口
+ *
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+public interface UserInfoMapper extends BaseMapper {
+
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/HobbyMapper.xml b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/HobbyMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..251eac743f644f2ad842fce1028db1639b99cd83
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/HobbyMapper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/HobbyParentMapper.xml b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/HobbyParentMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..efb9b5e086da1d3ecd608bb01ed3667b4b6502a2
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/HobbyParentMapper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/JobMapper.xml b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/JobMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..34cba2570e62e40b49503531b600c347cffb9322
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/JobMapper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/UserInfoMapper.xml b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/UserInfoMapper.xml
new file mode 100644
index 0000000000000000000000000000000000000000..6c2bd7e69d142bda81498b814db6e1c956dbb647
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/mapper/xml/UserInfoMapper.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/HobbyParentService.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/HobbyParentService.java
new file mode 100644
index 0000000000000000000000000000000000000000..57ba45e6e887bd9ae9bbb0bb0b138428d1ad4045
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/HobbyParentService.java
@@ -0,0 +1,35 @@
+package com.lamdaer.opengauss.gauss.service;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.lamdaer.opengauss.gauss.entity.HobbyParent;
+import com.lamdaer.opengauss.gauss.entity.vo.HobbyParentVo;
+
+/**
+ *
+ * 爱好一级分类 服务类
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+public interface HobbyParentService extends IService {
+ /**
+ * 添加爱好一级分类
+ * @param name 一级分类名称
+ * @return
+ */
+ Boolean addHobbyParent(String name);
+
+ /**
+ * 获取爱好一级分类列表
+ * @return
+ */
+ List getHobbyParentList();
+
+ /**
+ * 获取爱好一级分类及其对应的二级分类列表
+ * @return
+ */
+ List getHobbyParentListWithChildren();
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/HobbyService.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/HobbyService.java
new file mode 100644
index 0000000000000000000000000000000000000000..780787e4159d7f0e760f54ff2a447592db6e1a3d
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/HobbyService.java
@@ -0,0 +1,30 @@
+package com.lamdaer.opengauss.gauss.service;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.lamdaer.opengauss.gauss.entity.Hobby;
+import com.lamdaer.opengauss.gauss.entity.vo.HobbyVo;
+
+/**
+ *
+ * 爱好二级分类 服务类
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+public interface HobbyService extends IService {
+
+ /**
+ * 添加爱好
+ * @param hobbyVo 爱好vo
+ * @return
+ */
+ Boolean addHobby(HobbyVo hobbyVo);
+
+ /**
+ * 获取爱好列表
+ * @return
+ */
+ List getHobbyList();
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/JobService.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/JobService.java
new file mode 100644
index 0000000000000000000000000000000000000000..a63b0370503e2f098eee066ca45dba7ef1372cc9
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/JobService.java
@@ -0,0 +1,29 @@
+package com.lamdaer.opengauss.gauss.service;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.lamdaer.opengauss.gauss.entity.Job;
+
+/**
+ *
+ * 岗位 服务类
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+public interface JobService extends IService {
+
+ /**
+ * 添加岗位
+ * @param name 岗位名称
+ * @return
+ */
+ Boolean addJob(String name);
+
+ /**
+ * 获取岗位列表
+ * @return
+ */
+ List getJobList();
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/SimilarityService.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/SimilarityService.java
new file mode 100644
index 0000000000000000000000000000000000000000..5385a7bf5a93e35d293a3ca31074fa6ef8011b69
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/SimilarityService.java
@@ -0,0 +1,18 @@
+package com.lamdaer.opengauss.gauss.service;
+
+import java.util.List;
+
+import com.lamdaer.opengauss.gauss.entity.UserInfo;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/24
+ */
+public interface SimilarityService {
+ /**
+ * 相似度计算
+ * @param userId
+ * @return
+ */
+ List similarity(Long userId);
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/UserInfoService.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/UserInfoService.java
new file mode 100644
index 0000000000000000000000000000000000000000..083883d9e1a3229e8120643965a2baf23c8b59b1
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/UserInfoService.java
@@ -0,0 +1,21 @@
+package com.lamdaer.opengauss.gauss.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.lamdaer.opengauss.gauss.entity.UserInfo;
+import com.lamdaer.opengauss.gauss.entity.vo.UserInfoVo;
+
+/**
+ *
+ * 用户信息 服务类
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+public interface UserInfoService extends IService {
+ /**
+ * 添加用户信息
+ * @param userInfoVo
+ * @return
+ */
+ Long add(UserInfoVo userInfoVo);
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/HobbyParentServiceImpl.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/HobbyParentServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..8ffdde7fe4f633644b39d45ddeab2dc51852e03f
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/HobbyParentServiceImpl.java
@@ -0,0 +1,78 @@
+package com.lamdaer.opengauss.gauss.service.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.lamdaer.opengauss.gauss.common.GaussException;
+import com.lamdaer.opengauss.gauss.entity.Hobby;
+import com.lamdaer.opengauss.gauss.entity.HobbyParent;
+import com.lamdaer.opengauss.gauss.entity.vo.HobbyListVo;
+import com.lamdaer.opengauss.gauss.entity.vo.HobbyParentVo;
+import com.lamdaer.opengauss.gauss.mapper.HobbyParentMapper;
+import com.lamdaer.opengauss.gauss.service.HobbyParentService;
+import com.lamdaer.opengauss.gauss.service.HobbyService;
+
+/**
+ *
+ * 爱好一级分类 服务实现类
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@Service
+public class HobbyParentServiceImpl extends ServiceImpl implements HobbyParentService {
+ @Autowired
+ private HobbyService hobbyService;
+
+ @Override
+ public Boolean addHobbyParent(String name) {
+ if (StringUtils.isEmpty(name) || name.trim() == "") {
+ throw new GaussException(20001, "Illegal parameter.");
+ }
+ HobbyParent hobbyParent = new HobbyParent();
+ hobbyParent.setName(name);
+ int insert = baseMapper.insert(hobbyParent);
+ return insert > 0;
+ }
+
+ @Override
+ public List getHobbyParentList() {
+ List hobbyParents = baseMapper.selectList(null);
+ return hobbyParents;
+ }
+
+ @Override
+ public List getHobbyParentListWithChildren() {
+ List hobbyParentList = this.getHobbyParentList();
+ List hobbyParentVoList = new ArrayList<>();
+ for (HobbyParent parent : hobbyParentList) {
+ Long parentId = parent.getId();
+
+ // 通过一级爱好 ID 查询子爱好
+ QueryWrapper hobbyQueryWrapper = new QueryWrapper<>();
+ hobbyQueryWrapper.eq("parent_id", parentId);
+ List hobbies = hobbyService.getBaseMapper().selectList(hobbyQueryWrapper);
+ List hobbyListVos = new ArrayList<>();
+ for (Hobby hobby : hobbies) {
+ HobbyListVo hobbyListVo = new HobbyListVo();
+ BeanUtils.copyProperties(hobby, hobbyListVo);
+ hobbyListVo.setText(hobby.getName());
+ hobbyListVos.add(hobbyListVo);
+ }
+
+ HobbyParentVo hobbyParentVo = new HobbyParentVo();
+ BeanUtils.copyProperties(parent, hobbyParentVo);
+ hobbyParentVo.setText(parent.getName());
+ hobbyParentVo.setChildren(hobbyListVos);
+ hobbyParentVoList.add(hobbyParentVo);
+ }
+ return hobbyParentVoList;
+ }
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/HobbyServiceImpl.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/HobbyServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..a4ca3fd50b8a6e7fcbccb726410d985e1435d14e
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/HobbyServiceImpl.java
@@ -0,0 +1,47 @@
+package com.lamdaer.opengauss.gauss.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.lamdaer.opengauss.gauss.common.GaussException;
+import com.lamdaer.opengauss.gauss.entity.Hobby;
+import com.lamdaer.opengauss.gauss.entity.HobbyParent;
+import com.lamdaer.opengauss.gauss.entity.vo.HobbyVo;
+import com.lamdaer.opengauss.gauss.mapper.HobbyMapper;
+import com.lamdaer.opengauss.gauss.service.HobbyParentService;
+import com.lamdaer.opengauss.gauss.service.HobbyService;
+
+/**
+ *
+ * 爱好二级分类 服务实现类
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@Service
+public class HobbyServiceImpl extends ServiceImpl implements HobbyService {
+ @Autowired
+ private HobbyParentService hobbyParentService;
+
+ @Override
+ public Boolean addHobby(HobbyVo hobbyVo) {
+ HobbyParent hobbyParent = hobbyParentService.getById(hobbyVo.getParentId());
+ if (hobbyParent == null) {
+ throw new GaussException(20001, "hobby parent is not exist.");
+ }
+ Hobby hobby = new Hobby();
+ BeanUtils.copyProperties(hobbyVo, hobby);
+ int insert = baseMapper.insert(hobby);
+ return insert > 0;
+ }
+
+ @Override
+ public List getHobbyList() {
+ List hobbies = baseMapper.selectList(null);
+ return hobbies;
+ }
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/JobServiceImpl.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/JobServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..f1b63d2fef26a684e6a202ec464a70574d1e30c8
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/JobServiceImpl.java
@@ -0,0 +1,39 @@
+package com.lamdaer.opengauss.gauss.service.impl;
+
+import java.util.List;
+
+import org.springframework.stereotype.Service;
+import org.springframework.util.StringUtils;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.lamdaer.opengauss.gauss.common.GaussException;
+import com.lamdaer.opengauss.gauss.entity.Job;
+import com.lamdaer.opengauss.gauss.mapper.JobMapper;
+import com.lamdaer.opengauss.gauss.service.JobService;
+
+/**
+ *
+ * 岗位 服务实现类
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@Service
+public class JobServiceImpl extends ServiceImpl implements JobService {
+ @Override
+ public Boolean addJob(String name) {
+ if (StringUtils.isEmpty(name) || name.trim() == "") {
+ throw new GaussException(20001, "Illegal parameter.");
+ }
+ Job job = new Job();
+ job.setName(name);
+ int insert = baseMapper.insert(job);
+ return insert > 0;
+ }
+
+ @Override
+ public List getJobList() {
+ List jobList = baseMapper.selectList(null);
+ return jobList;
+ }
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/SimilarityServiceImpl.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/SimilarityServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..55bce0b3c8168b026fcb8ada458f15d86af3977d
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/SimilarityServiceImpl.java
@@ -0,0 +1,122 @@
+package com.lamdaer.opengauss.gauss.service.impl;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.lamdaer.opengauss.gauss.common.GaussException;
+import com.lamdaer.opengauss.gauss.entity.Hobby;
+import com.lamdaer.opengauss.gauss.entity.UserInfo;
+import com.lamdaer.opengauss.gauss.service.HobbyService;
+import com.lamdaer.opengauss.gauss.service.SimilarityService;
+import com.lamdaer.opengauss.gauss.service.UserInfoService;
+import com.lamdaer.opengauss.gauss.utils.MapUtil;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/24
+ */
+@Service
+public class SimilarityServiceImpl implements SimilarityService {
+ @Autowired
+ private UserInfoService userInfoService;
+
+ @Autowired
+ private HobbyService hobbyService;
+
+
+ @Override
+ public List similarity(Long userId) {
+ if (userId == null) {
+ throw new GaussException(20001, "Illegal parameter.");
+ }
+ UserInfo userInfo = userInfoService.getById(userId);
+ Long jobId = userInfo.getJobId();
+ Integer age = userInfo.getAge();
+ Integer sex = userInfo.getSex();
+ List hobbyList = hobbyService.getHobbyList();
+ List userInfoList = userInfoService.getBaseMapper().selectList(null);
+ Map result = new HashMap<>(userInfoList.size());
+ for (UserInfo user : userInfoList) {
+ if (user.getUserId().equals(userId)) {
+ continue;
+ }
+ int count = 0;
+
+ // 岗位相似度
+ if (user.getJobId().equals(jobId)) {
+ count += 4;
+ }
+
+ // 性别
+ if (!user.getSex().equals(sex)){
+ count += 10;
+ }
+
+ // 年龄相似度
+ int differenceAge = Math.abs(age - user.getAge());
+ switch (differenceAge) {
+ case 0:
+ count += 5;
+ break;
+ case 1:
+ case 2:
+ case 3:
+ count += 4;
+ break;
+ case 4:
+ case 5:
+ case 6:
+ count += 3;
+ break;
+ case 7:
+ case 8:
+ case 9:
+ count += 2;
+ break;
+ default:
+ count += 1;
+ }
+
+ // 爱好相似度
+ String[] split = user.getHobbyIdList().split(",");
+ List hobbies = Arrays.stream(split).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
+ if (user.getJobId().equals(jobId)) {
+ count += 4;
+ }
+ Set same = new HashSet<>();
+ Set temp = new HashSet<>();
+ for (int i = 0; i < hobbyList.size(); i++) {
+ temp.add(hobbyList.get(i).getId());
+ }
+ for (int j = 0; j < hobbies.size(); j++) {
+ if (!temp.add(hobbies.get(j))) {
+ same.add(hobbies.get(j));
+ }
+ }
+ count += same.size() * 5;
+
+ result.put(user.getUserId(), count);
+
+ }
+ Map longIntegerMap = MapUtil.sortByValueDesc(result);
+ Set userIds = longIntegerMap.keySet();
+ List userIdList = new ArrayList<>(userIds);
+ List userInfos = new ArrayList<>();
+ for (Long id : userIdList.subList(0, 3)) {
+ UserInfo user = userInfoService.getById(id);
+ userInfos.add(user);
+ }
+ return userInfos;
+ }
+
+
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/UserInfoServiceImpl.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/UserInfoServiceImpl.java
new file mode 100644
index 0000000000000000000000000000000000000000..355e826c8a0fa33153525d00904ca3a1fe74dfac
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/service/impl/UserInfoServiceImpl.java
@@ -0,0 +1,72 @@
+package com.lamdaer.opengauss.gauss.service.impl;
+
+import java.util.List;
+
+import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.lamdaer.opengauss.gauss.common.GaussException;
+import com.lamdaer.opengauss.gauss.entity.Hobby;
+import com.lamdaer.opengauss.gauss.entity.Job;
+import com.lamdaer.opengauss.gauss.entity.UserInfo;
+import com.lamdaer.opengauss.gauss.entity.vo.UserInfoVo;
+import com.lamdaer.opengauss.gauss.mapper.UserInfoMapper;
+import com.lamdaer.opengauss.gauss.service.HobbyService;
+import com.lamdaer.opengauss.gauss.service.JobService;
+import com.lamdaer.opengauss.gauss.service.UserInfoService;
+
+/**
+ *
+ * 用户信息 服务实现类
+ *
+ * @author Lamdaer
+ * @since 2020-10-24
+ */
+@Service
+public class UserInfoServiceImpl extends ServiceImpl implements UserInfoService {
+ @Autowired
+ private HobbyService hobbyService;
+
+ @Autowired
+ private JobService jobService;
+
+ @Override
+ public Long add(UserInfoVo userInfoVo) {
+ Long jobId = userInfoVo.getJobId();
+ List hobbyIdList = userInfoVo.getHobbyIdList();
+
+ // 检查岗位是否存在
+ Job job = jobService.getById(jobId);
+ if (job == null) {
+ throw new GaussException(20001, "job is not exist.");
+ }
+
+ // 检查爱好是否存在
+ for (Long hobbyId : hobbyIdList) {
+ Hobby hobby = hobbyService.getById(hobbyId);
+ if (hobby == null) {
+ throw new GaussException(20001, "hobby is not exist.");
+ }
+ }
+ UserInfo userInfo = new UserInfo();
+ BeanUtils.copyProperties(userInfoVo, userInfo);
+ StringBuilder stringBuilder = new StringBuilder();
+
+ // 爱好id列表转换为字符串 格式如:[11111,22222]
+ for (int i = 0; i < hobbyIdList.size(); i++) {
+ stringBuilder.append(hobbyIdList.get(i));
+ if (i != hobbyIdList.size() - 1) {
+ stringBuilder.append(",");
+ }
+ }
+ String str = stringBuilder.toString();
+ userInfo.setHobbyIdList(str);
+ int insert = baseMapper.insert(userInfo);
+ if (insert > 0) {
+ return userInfo.getUserId();
+ }
+ return null;
+ }
+}
diff --git a/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/utils/MapUtil.java b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/utils/MapUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..472d3a6932df0d8db0c519666ff5a2ef1ad69cec
--- /dev/null
+++ b/FindFriends/Server/src/main/java/com/lamdaer/opengauss/gauss/utils/MapUtil.java
@@ -0,0 +1,54 @@
+package com.lamdaer.opengauss.gauss.utils;
+
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * @author lamdaer
+ * @createTime 2020/10/24
+ */
+public class MapUtil {
+ private static Comparator comparatorByValueAsc = (Map.Entry o1, Map.Entry o2) -> {
+ if (o1.getValue() instanceof Comparable) {
+ return ((Comparable) o1.getValue()).compareTo(o2.getValue());
+ }
+ throw new UnsupportedOperationException("值的类型尚未实现Comparable接口");
+ };
+
+
+ private static Comparator comparatorByValueDesc = (Map.Entry o1, Map.Entry o2) -> {
+ if (o1.getValue() instanceof Comparable) {
+ return ((Comparable) o2.getValue()).compareTo(o1.getValue());
+ }
+ throw new UnsupportedOperationException("值的类型尚未实现Comparable接口");
+ };
+
+ /**
+ * 按值升序排列
+ */
+ public static Map sortByValueAsc(Map originMap) {
+ if (originMap == null) {
+ return null;
+ }
+ return sort(originMap, comparatorByValueAsc);
+ }
+
+ /**
+ * 按值降序排列
+ */
+ public static Map sortByValueDesc(Map originMap) {
+ if (originMap == null) {
+ return null;
+ }
+ return sort(originMap, comparatorByValueDesc);
+ }
+
+ private static Map sort(Map originMap, Comparator comparator) {
+ return originMap.entrySet()
+ .stream()
+ .sorted(comparator)
+ .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e2, LinkedHashMap::new));
+ }
+}
diff --git a/FindFriends/Server/src/main/resources/application-dev.yml b/FindFriends/Server/src/main/resources/application-dev.yml
new file mode 100644
index 0000000000000000000000000000000000000000..7fa61853ecc0691c558c1234d4ed5323f7a57a8d
--- /dev/null
+++ b/FindFriends/Server/src/main/resources/application-dev.yml
@@ -0,0 +1,23 @@
+server:
+ port: 8001
+#生产环境设为 false
+springfox:
+ documentation:
+ swagger-ui:
+ enabled: true
+spring:
+ datasource:
+ url:
+ username:
+ password:
+ driver-class-name:
+ jackson:
+ date-format: yyyy-MM-dd HH:mm:ss
+ time-zone: GMT+8
+ application:
+ name: opengauss
+
+mybatis-plus:
+ global-config:
+ db-config:
+ logic-delete-field: isDeleted
\ No newline at end of file
diff --git a/FindFriends/Server/src/main/resources/application.yml b/FindFriends/Server/src/main/resources/application.yml
new file mode 100644
index 0000000000000000000000000000000000000000..caf4dfcd647483863672818bd860d4ec4767e8de
--- /dev/null
+++ b/FindFriends/Server/src/main/resources/application.yml
@@ -0,0 +1,3 @@
+spring:
+ profiles:
+ active: dev
\ No newline at end of file
diff --git a/FindFriends/Server/src/test/java/com/example/gauss/GaussApplicationTests.java b/FindFriends/Server/src/test/java/com/example/gauss/GaussApplicationTests.java
new file mode 100644
index 0000000000000000000000000000000000000000..c18ebc7f9f597b0448779d704a41f5929074212d
--- /dev/null
+++ b/FindFriends/Server/src/test/java/com/example/gauss/GaussApplicationTests.java
@@ -0,0 +1,13 @@
+package com.example.gauss;
+
+import org.junit.jupiter.api.Test;
+import org.springframework.boot.test.context.SpringBootTest;
+
+@SpringBootTest
+class GaussApplicationTests {
+
+ @Test
+ void contextLoads() {
+ }
+
+}