浏览代码

Merge branch 'feature-V2.0' of http://git.mooctest.com/crowd-2019/crowd-test-service-backend into feature-V2.0

xuxuan 5 年之前
父节点
当前提交
223f48532e

+ 2 - 1
core/src/main/java/com/mooctest/crowd/domain/dao/UserDao.java

@@ -2,13 +2,14 @@ package com.mooctest.crowd.domain.dao;
 
 import com.mooctest.crowd.domain.model.UserPO;
 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.CrudRepository;
 import org.springframework.data.repository.PagingAndSortingRepository;
 
 import javax.transaction.Transactional;
 import java.util.Optional;
 
 @Transactional
-public interface UserDao extends PagingAndSortingRepository<UserPO, Long>, JpaSpecificationExecutor<UserPO> {
+public interface UserDao extends PagingAndSortingRepository<UserPO, Long>, JpaSpecificationExecutor<UserPO> ,CrudRepository<UserPO, Long> {
 
     UserPO findByMobile(String mobile);
 

+ 16 - 0
core/src/main/java/com/mooctest/crowd/domain/model/UserPO.java

@@ -3,6 +3,7 @@ package com.mooctest.crowd.domain.model;
 import lombok.Data;
 
 import javax.persistence.*;
+import java.sql.Date;
 import java.sql.Timestamp;
 
 /**
@@ -55,4 +56,19 @@ public class UserPO {
     @Column(name = "U_CREATE_TIME")
     private Timestamp createTime;
 
+    @Column(name="U_BIRTHDAY")
+    private Date birthday;
+
+    @Column(name="U_DETAILED_ADDRESS")
+    private String  detailedAddress;
+
+    @Column(name="U_PERSONAL_COMPETENCE")
+    private String personalCompetence;
+
+    @Column(name="U_UNIT")
+    private String unit;
+
+    @Column(name="U_COUNTY")
+    private String county;
+
 }

+ 27 - 0
site/src/main/java/com/mooctest/crowd/site/controller/PersonalDataController.java

@@ -0,0 +1,27 @@
+package com.mooctest.crowd.site.controller;
+
+
+import com.mooctest.crowd.site.data.dto.UserDTO;
+import com.mooctest.crowd.site.data.vo.UserVO;
+import com.mooctest.crowd.site.service.PersonalDataService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+
+@RestController
+@RequestMapping("/api/personal")
+public class PersonalDataController {
+
+    @Autowired
+    private PersonalDataService personalDataService;
+
+    @RequestMapping(value = "/display/{userId:\\d+}", method = RequestMethod.GET)
+    public UserDTO getInformation(@PathVariable("userId") long userId){
+        return  personalDataService.getInformation(userId);
+    }
+
+    @RequestMapping(value = "/update/{userId:\\d+}", method = RequestMethod.PUT)
+    public UserDTO addUserToGroup(@PathVariable("userId") long userId, @RequestBody UserVO userVO) {
+        return  personalDataService.updateInformation(userId,userVO);
+    }
+}

+ 7 - 0
site/src/main/java/com/mooctest/crowd/site/data/vo/UserVO.java

@@ -7,6 +7,8 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 import org.springframework.beans.BeanUtils;
 
+import java.sql.Date;
+
 /**
  * @Author: xuexb
  * @Date: 2019.7.15 20:41
@@ -27,6 +29,11 @@ public class UserVO {
     private Double allProjectPrice;
     private String authType;
     private Long taskCount;
+    private Date birthday;
+    private String detailedAddress;
+    private String personalCompetence;
+    private String unit;
+    private String county;
 
     public UserVO(User user) {
         BeanUtils.copyProperties(user, this);

+ 2 - 3
site/src/main/java/com/mooctest/crowd/site/mediator/ViewMediator.java

@@ -69,8 +69,7 @@ public interface ViewMediator {
 
     List<TechnicalArticlesVO>  articlesRanking();
 
-    UserVO getinformation(long userId);
-
-
+    UserDTO getInformation(long userId);
 
+    UserDTO updateInformation(long userId, UserVO userVO);
 }

+ 28 - 3
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -742,19 +742,44 @@ public class WebMediatorImpl implements ViewMediator {
     }
 
     @Override
-    public UserVO getinformation(long userId) {
+    public UserDTO getInformation(long userId) {
+        UserDTO userDTO=new UserDTO();
         Optional<UserPO> userPO = userDao.findById(userId);
         if (userPO.isPresent()) {
             UserVO userVO = new UserVO();
+            userVO.setPhotoUrl(userPO.get().getPhotoUrl());
             userVO.setName(userPO.get().getName());
             userVO.setUserName(userPO.get().getUserName());
+            userVO.setUnit(userPO.get().getUnit());
             userVO.setGender(userPO.get().getGender());
-            userVO.setEmail(userPO.get().getEmail());
-            return userVO;
+            userVO.setBirthday(userPO.get().getBirthday());
+            userVO.setProvince(userPO.get().getProvince());
+            userVO.setCity(userPO.get().getCity());
+            userVO.setCounty(userPO.get().getCounty());
+            userVO.setDetailedAddress(userPO.get().getDetailedAddress());
+            userVO.setPersonalCompetence(userPO.get().getPersonalCompetence());
+            userDTO.setUserVO(userVO);
+            return userDTO;
         }
         return null;
     }
 
+    @Override
+    public UserDTO updateInformation(long userId, UserVO userVO) {
+        Optional<UserPO> userPO = userDao.findById(userId);
+        userPO.get().setUnit(userVO.getUnit());
+        userPO.get().setGender(userVO.getGender());
+        userPO.get().setBirthday(userVO.getBirthday());
+        userPO.get().setProvince(userVO.getProvince());
+        userPO.get().setCity(userVO.getCity());
+        userPO.get().setCounty(userVO.getCounty());
+        userPO.get().setDetailedAddress(userVO.getDetailedAddress());
+        userPO.get().setPersonalCompetence(userVO.getPersonalCompetence());
+        userDao.save(userPO.get());
+        this.getInformation(userId);
+        return this.getInformation(userId);
+    }
+
     private ProjectOperationControl initProjectPermission(CrowdTestProject project, User user) {
         ProjectOperationControl operationControl = new ProjectOperationControl();
         if (user == null)

+ 11 - 0
site/src/main/java/com/mooctest/crowd/site/service/PersonalDataService.java

@@ -0,0 +1,11 @@
+package com.mooctest.crowd.site.service;
+
+import com.mooctest.crowd.site.data.dto.UserDTO;
+import com.mooctest.crowd.site.data.vo.UserVO;
+
+
+public interface PersonalDataService {
+    UserDTO getInformation(long id);
+
+    UserDTO  updateInformation(long userId,UserVO userVO);
+}

+ 25 - 0
site/src/main/java/com/mooctest/crowd/site/service/impl/PersonalDataServiceImpl.java

@@ -0,0 +1,25 @@
+package com.mooctest.crowd.site.service.impl;
+
+import com.mooctest.crowd.site.data.dto.UserDTO;
+import com.mooctest.crowd.site.data.vo.UserVO;
+import com.mooctest.crowd.site.mediator.ViewMediator;
+import com.mooctest.crowd.site.service.PersonalDataService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class PersonalDataServiceImpl implements PersonalDataService {
+
+    @Autowired
+    private ViewMediator viewMediator;
+
+    @Override
+    public UserDTO getInformation(long id) {
+        return viewMediator.getInformation(id);
+    }
+
+    @Override
+    public UserDTO updateInformation(long userId, UserVO userVO) {
+        return viewMediator.updateInformation(userId,userVO);
+    }
+}