springCloud+Vue改造品优购第一章--------工程模块简介及controller和REST返回结果封装

本博客介绍了对品优购商城从Dubbo到SpringCloud的架构改造,并详细讲解了项目的工程模块划分,包括BaseController的封装,以及REST接口的返回结果实体和状态码定义,旨在提升系统的微服务化和前端Vue交互体验。
摘要由CSDN通过智能技术生成


项目简介

本项目是基于对品优购商城的改造,将原有后台的Dubbo架构改造为springCloud,前端采用Vue


项目工程模块简介

模块 模块说明
pyg-eureka 服务注册中心
pyg-parent 父工程,统一管理依赖版本,打包构建项目
pyg-common 公共模块,包含基类的封装
pyg-entity 抽取出的整个项目需要的实体类
pyg-dao 数据访问模块
pyg-goods-interface 商品服务接口
pyg-goods-service 商品服务
pyg-manage-web 商城后台管理服务
pyg-shop-web 商家后台管理服务

BaseController的封装

package com.pyg.base.controller;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.WebRequest;

/**
 * create on 2018年8月9日 下午8:59:26
 * 
 * @Author: Wq E-mail: 1432114216@qq.com
 */
public class BaseController {
   

    /**
     * 获取request对象
     * 
     * @return HttpServletRequest
     */
    protected HttpServletRequest getRequest() {
        HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes())
                .getRequest();
        return request;
    }

    /**
     * 获取缓存的key
     * 
     * @return x-token
     * @throws Exception
     */
    protected String getToken() throws Exception {
        String token = getReque
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值