提交 70c26a5e 编写于 作者: 小傅哥's avatar 小傅哥

小傅哥,feat:架构的本质之 MVC 架构

上级 0b2c1b2b
...@@ -2,7 +2,7 @@ package cn.bugstack.xfg.frame.controller; ...@@ -2,7 +2,7 @@ package cn.bugstack.xfg.frame.controller;
import cn.bugstack.xfg.frame.common.Result; import cn.bugstack.xfg.frame.common.Result;
import cn.bugstack.xfg.frame.domain.res.UserRes; import cn.bugstack.xfg.frame.domain.res.UserRes;
import cn.bugstack.xfg.frame.domain.vo.UserInfo; import cn.bugstack.xfg.frame.domain.vo.UserVO;
import cn.bugstack.xfg.frame.service.IUserService; import cn.bugstack.xfg.frame.service.IUserService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -25,8 +25,8 @@ public class UserController { ...@@ -25,8 +25,8 @@ public class UserController {
public UserRes queryUserInfo() { public UserRes queryUserInfo() {
try { try {
log.info("查询用户信息"); log.info("查询用户信息");
List<UserInfo> userInfoList = userService.queryUserList(); List<UserVO> userVOList = userService.queryUserList();
return UserRes.builder().userInfos(userInfoList).result(Result.buildSuccess()).build(); return UserRes.builder().userVOList(userVOList).result(Result.buildSuccess()).build();
} catch (Exception e) { } catch (Exception e) {
log.error("查询用户信息失败", e); log.error("查询用户信息失败", e);
return UserRes.builder().result(Result.buildSuccess()).build(); return UserRes.builder().result(Result.buildSuccess()).build();
......
package cn.bugstack.xfg.frame.domain.res; package cn.bugstack.xfg.frame.domain.res;
import cn.bugstack.xfg.frame.common.Result; import cn.bugstack.xfg.frame.common.Result;
import cn.bugstack.xfg.frame.domain.vo.UserInfo; import cn.bugstack.xfg.frame.domain.vo.UserVO;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
...@@ -16,6 +16,6 @@ import java.util.List; ...@@ -16,6 +16,6 @@ import java.util.List;
public class UserRes { public class UserRes {
private Result result; private Result result;
private List<UserInfo> userInfos; private List<UserVO> userVOList;
} }
...@@ -11,7 +11,7 @@ import java.util.Date; ...@@ -11,7 +11,7 @@ import java.util.Date;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@Builder @Builder
public class UserInfo { public class UserVO {
/** 用户名称 */ /** 用户名称 */
private String userId; private String userId;
......
package cn.bugstack.xfg.frame.service; package cn.bugstack.xfg.frame.service;
import cn.bugstack.xfg.frame.domain.req.UserReq; import cn.bugstack.xfg.frame.domain.vo.UserVO;
import cn.bugstack.xfg.frame.domain.vo.UserInfo;
import java.util.List; import java.util.List;
public interface IUserService { public interface IUserService {
List<UserInfo> queryUserList(); List<UserVO> queryUserList();
UserInfo queryUserInfo(String uId); UserVO queryUserInfo(String uId);
} }
...@@ -2,7 +2,7 @@ package cn.bugstack.xfg.frame.service.impl; ...@@ -2,7 +2,7 @@ package cn.bugstack.xfg.frame.service.impl;
import cn.bugstack.xfg.frame.dao.IUserDao; import cn.bugstack.xfg.frame.dao.IUserDao;
import cn.bugstack.xfg.frame.domain.po.User; import cn.bugstack.xfg.frame.domain.po.User;
import cn.bugstack.xfg.frame.domain.vo.UserInfo; import cn.bugstack.xfg.frame.domain.vo.UserVO;
import cn.bugstack.xfg.frame.service.IUserService; import cn.bugstack.xfg.frame.service.IUserService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -19,11 +19,11 @@ public class UserServiceImpl implements IUserService { ...@@ -19,11 +19,11 @@ public class UserServiceImpl implements IUserService {
private IUserDao userDao; private IUserDao userDao;
@Override @Override
public List<UserInfo> queryUserList() { public List<UserVO> queryUserList() {
List<UserInfo> userInfoList = new ArrayList<>(); List<UserVO> userInfoList = new ArrayList<>();
List<User> users = userDao.queryUserList(); List<User> users = userDao.queryUserList();
for (User user : users) { for (User user : users) {
UserInfo userInfo = UserInfo.builder() UserVO userInfo = UserVO.builder()
.userId(user.getUserId()) .userId(user.getUserId())
.userNickname(user.getUserNickname()) .userNickname(user.getUserNickname())
.createTime(user.getCreateTime()) .createTime(user.getCreateTime())
...@@ -34,9 +34,9 @@ public class UserServiceImpl implements IUserService { ...@@ -34,9 +34,9 @@ public class UserServiceImpl implements IUserService {
} }
@Override @Override
public UserInfo queryUserInfo(String uId) { public UserVO queryUserInfo(String uId) {
log.info("查询用户信息:{}", uId); log.info("查询用户信息:{}", uId);
return new UserInfo(); return new UserVO();
} }
} }
package cn.bugstack.xfg.frame.test; package cn.bugstack.xfg.frame.test;
import cn.bugstack.xfg.frame.domain.vo.UserInfo; import cn.bugstack.xfg.frame.domain.vo.UserVO;
import cn.bugstack.xfg.frame.service.IUserService; import cn.bugstack.xfg.frame.service.IUserService;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -22,8 +22,8 @@ public class ApiTest { ...@@ -22,8 +22,8 @@ public class ApiTest {
@Test @Test
public void test_queryUserList() { public void test_queryUserList() {
List<UserInfo> userInfoList = userService.queryUserList(); List<UserVO> userVOList = userService.queryUserList();
log.info("测试结果:{}", JSON.toJSONString(userInfoList)); log.info("测试结果:{}", JSON.toJSONString(userVOList));
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册