diff --git a/src/main/java/com/monkeyk/sos/domain/dto/UserDto.java b/src/main/java/com/monkeyk/sos/domain/dto/UserDto.java new file mode 100644 index 0000000..38a302f --- /dev/null +++ b/src/main/java/com/monkeyk/sos/domain/dto/UserDto.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2015 MONKEYK Information Technology Co. Ltd + * www.monkeyk.com + * All rights reserved. + * + * This software is the confidential and proprietary information of + * MONKEYK Information Technology Co. Ltd ("Confidential Information"). + * You shall not disclose such Confidential Information and shall use + * it only in accordance with the terms of the license agreement you + * entered into with MONKEYK Information Technology Co. Ltd. + */ +package com.monkeyk.sos.domain.dto; + +import com.monkeyk.sos.domain.user.Privilege; +import com.monkeyk.sos.domain.user.User; + +import java.io.Serializable; +import java.time.format.DateTimeFormatter; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * 2016/3/12 + * + * @author Shengzhao Li + */ +public class UserDto implements Serializable { + private static final long serialVersionUID = -2502329463915439215L; + + + private String guid; + + private String username; + + private String phone; + private String email; + + private String createTime; + + private List privileges = new ArrayList<>(); + + + public UserDto() { + } + + + public UserDto(User user) { + this.guid = user.guid(); + this.username = user.username(); + this.phone = user.phone(); + this.email = user.email(); + + this.privileges = user.privileges(); + this.createTime = user.createTime().format(DateTimeFormatter.ISO_LOCAL_DATE_TIME); + } + + public String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getGuid() { + return guid; + } + + public void setGuid(String guid) { + this.guid = guid; + } + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public List getPrivileges() { + return privileges; + } + + public void setPrivileges(List privileges) { + this.privileges = privileges; + } +} diff --git a/src/main/java/com/monkeyk/sos/domain/dto/UserOverviewDto.java b/src/main/java/com/monkeyk/sos/domain/dto/UserOverviewDto.java new file mode 100644 index 0000000..9ca0fa3 --- /dev/null +++ b/src/main/java/com/monkeyk/sos/domain/dto/UserOverviewDto.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2015 MONKEYK Information Technology Co. Ltd + * www.monkeyk.com + * All rights reserved. + * + * This software is the confidential and proprietary information of + * MONKEYK Information Technology Co. Ltd ("Confidential Information"). + * You shall not disclose such Confidential Information and shall use + * it only in accordance with the terms of the license agreement you + * entered into with MONKEYK Information Technology Co. Ltd. + */ +package com.monkeyk.sos.domain.dto; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * 2016/3/12 + * + * @author Shengzhao Li + */ +public class UserOverviewDto implements Serializable { + private static final long serialVersionUID = 2023379587030489248L; + + + private String username; + + + private List userDtos = new ArrayList<>(); + + + public UserOverviewDto() { + } + + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public List getUserDtos() { + return userDtos; + } + + public void setUserDtos(List userDtos) { + this.userDtos = userDtos; + } +} diff --git a/src/main/java/com/monkeyk/sos/service/UserService.java b/src/main/java/com/monkeyk/sos/service/UserService.java index e27e6b6..e8719ff 100644 --- a/src/main/java/com/monkeyk/sos/service/UserService.java +++ b/src/main/java/com/monkeyk/sos/service/UserService.java @@ -1,6 +1,7 @@ package com.monkeyk.sos.service; import com.monkeyk.sos.domain.dto.UserJsonDto; +import com.monkeyk.sos.domain.dto.UserOverviewDto; import org.springframework.security.core.userdetails.UserDetailsService; /** @@ -9,4 +10,6 @@ import org.springframework.security.core.userdetails.UserDetailsService; public interface UserService extends UserDetailsService { UserJsonDto loadCurrentUserJsonDto(); + + UserOverviewDto loadUserOverviewDto(UserOverviewDto overviewDto); } \ No newline at end of file diff --git a/src/main/java/com/monkeyk/sos/service/impl/UserServiceImpl.java b/src/main/java/com/monkeyk/sos/service/impl/UserServiceImpl.java index 6b9cf1f..3d7aaea 100644 --- a/src/main/java/com/monkeyk/sos/service/impl/UserServiceImpl.java +++ b/src/main/java/com/monkeyk/sos/service/impl/UserServiceImpl.java @@ -1,6 +1,7 @@ package com.monkeyk.sos.service.impl; import com.monkeyk.sos.domain.dto.UserJsonDto; +import com.monkeyk.sos.domain.dto.UserOverviewDto; import com.monkeyk.sos.domain.shared.security.WdcyUserDetails; import com.monkeyk.sos.domain.user.User; import com.monkeyk.sos.domain.user.UserRepository; @@ -49,6 +50,12 @@ public class UserServiceImpl implements UserService { } } + @Override + public UserOverviewDto loadUserOverviewDto(UserOverviewDto overviewDto) { + + return overviewDto; + } + private UserJsonDto loadOauthUserJsonDto(OAuth2Authentication oAuth2Authentication) { UserJsonDto userJsonDto = new UserJsonDto(); diff --git a/src/main/java/com/monkeyk/sos/web/controller/UserController.java b/src/main/java/com/monkeyk/sos/web/controller/UserController.java index f39fda8..24f9e95 100644 --- a/src/main/java/com/monkeyk/sos/web/controller/UserController.java +++ b/src/main/java/com/monkeyk/sos/web/controller/UserController.java @@ -1,6 +1,10 @@ package com.monkeyk.sos.web.controller; +import com.monkeyk.sos.domain.dto.UserOverviewDto; +import com.monkeyk.sos.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; /** @@ -11,6 +15,8 @@ import org.springframework.web.bind.annotation.RequestMapping; public class UserController { + @Autowired + private UserService userService; /** * Just forward to page @@ -18,7 +24,9 @@ public class UserController { * @return View page */ @RequestMapping("overview") - public String overview() { + public String overview(UserOverviewDto overviewDto, Model model) { + overviewDto = userService.loadUserOverviewDto(overviewDto); + model.addAttribute("overviewDto", overviewDto); return "user_overview"; }