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

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

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