项目结构改造

This commit is contained in:
macro
2019-04-20 10:18:46 +08:00
parent cdd332a667
commit b5800856fb
34 changed files with 500 additions and 634 deletions

View File

@@ -1,7 +1,7 @@
package com.macro.mall.demo.controller;
import com.macro.mall.demo.dto.CommonPage;
import com.macro.mall.demo.dto.CommonResult;
import com.macro.mall.common.api.CommonPage;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.demo.dto.PmsBrandDto;
import com.macro.mall.demo.service.DemoService;
import com.macro.mall.model.PmsBrand;
@@ -11,7 +11,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

View File

@@ -1,6 +1,6 @@
package com.macro.mall.demo.controller;
import com.macro.mall.demo.dto.CommonResult;
import com.macro.mall.common.api.CommonResult;
import com.macro.mall.model.PmsBrand;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

View File

@@ -1,60 +0,0 @@
package com.macro.mall.demo.dto;
import com.github.pagehelper.PageInfo;
import java.util.List;
/**
* 分页数据封装类
*/
public class CommonPage<T> {
private Integer pageNum;
private Integer pageSize;
private Long totalPage;
private List<T> list;
/**
* 将PageHelper分页后的list转为分页信息
*/
public static <T> CommonPage<T> restPage(List<T> list) {
CommonPage<T> result = new CommonPage<>();
PageInfo<T> pageInfo = new PageInfo<>(list);
result.setTotalPage(pageInfo.getTotal() / pageInfo.getPageSize());
result.setPageNum(pageInfo.getPageNum());
result.setPageSize(pageInfo.getPageSize());
result.setList(pageInfo.getList());
return result;
}
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
public Long getTotalPage() {
return totalPage;
}
public void setTotalPage(Long totalPage) {
this.totalPage = totalPage;
}
public List<T> getList() {
return list;
}
public void setList(List<T> list) {
this.list = list;
}
}

View File

@@ -1,71 +0,0 @@
package com.macro.mall.demo.dto;
/**
* 通用返回对象
*/
public class CommonResult<T> {
public static final int SUCCESS = 0;
public static final int FAILED = 1;
public static final int VALIDATE_FAILED = 2;
private int code;
private String message;
private T data;
/**
* 普通成功返回
*
* @param data 获取的数据
*/
public static <T> CommonResult<T> success(T data) {
CommonResult<T> result = new CommonResult<T>();
result.setCode(SUCCESS);
result.setData(data);
return result;
}
/**
* 普通失败提示信息
*/
public static <T> CommonResult<T> failed(String message) {
CommonResult result = new CommonResult();
result.setCode(FAILED);
result.setMessage(message);
return result;
}
/**
* 参数验证失败使用
*
* @param message 错误信息
*/
public static <T> CommonResult<T> validateFailed(String message) {
CommonResult result = new CommonResult();
result.setCode(VALIDATE_FAILED);
result.setMessage(message);
return result;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}