git 5 éve
szülő
commit
720cd0398b

+ 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);
 

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

@@ -68,5 +68,7 @@ public class UserPO {
     @Column(name="U_UNIT")
     private String unit;
 
+    @Column(name="U_COUNTY")
+    private String county;
 
 }

+ 7 - 4
site/src/main/java/com/mooctest/crowd/site/controller/PersonalDataController.java

@@ -2,12 +2,10 @@ 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.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 
 @RestController
@@ -21,4 +19,9 @@ public class PersonalDataController {
     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);
+    }
 }

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

@@ -32,6 +32,7 @@ public class UserVO {
     private String detailedAddress;
     private String personalCompetence;
     private String unit;
+    private String county;
 
     public UserVO(User user){
         BeanUtils.copyProperties(user, this);

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

@@ -70,4 +70,6 @@ public interface ViewMediator {
     List<TechnicalArticlesVO>  articlesRanking();
 
     UserDTO getInformation(long userId);
+
+    UserDTO updateInformation(long userId, UserVO userVO);
 }

+ 17 - 0
site/src/main/java/com/mooctest/crowd/site/mediator/impl/WebMediatorImpl.java

@@ -755,6 +755,7 @@ public class WebMediatorImpl implements ViewMediator {
             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);
@@ -763,6 +764,22 @@ public class WebMediatorImpl implements ViewMediator {
         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)

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

@@ -1,8 +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);
 }

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

@@ -17,4 +17,9 @@ public class PersonalDataServiceImpl implements PersonalDataService {
     public UserDTO getInformation(long id) {
         return viewMediator.getInformation(id);
     }
+
+    @Override
+    public UserDTO updateInformation(long userId, UserVO userVO) {
+        return viewMediator.updateInformation(userId,userVO);
+    }
 }