From b5800856fb239b16cbe2c2788a75f7eecd3a69a9 Mon Sep 17 00:00:00 2001 From: macro Date: Sat, 20 Apr 2019 10:18:46 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BB=93=E6=9E=84=E6=94=B9?= =?UTF-8?q?=E9=80=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mall-admin/pom.xml | 55 ++------ mall-common/pom.xml | 39 ++++++ .../macro/mall/common/api}/CommonPage.java | 21 +++- .../macro/mall/common/api/CommonResult.java | 118 ++++++++++++++++++ .../com/macro/mall/common/api/IErrorCode.java | 11 ++ .../com/macro/mall/common/api/ResultCode.java | 28 +++++ mall-demo/pom.xml | 49 +------- .../mall/demo/controller/DemoController.java | 5 +- .../RestTemplateDemoController.java | 2 +- .../com/macro/mall/demo/dto/CommonResult.java | 71 ----------- mall-mbg/pom.xml | 5 + mall-portal/pom.xml | 48 ++----- .../component/OrderTimeOutCancelTask.java | 2 +- .../portal/controller/HomeController.java | 24 ++-- .../controller/MemberAttentionController.java | 18 +-- .../MemberCollectionController.java | 29 ++--- .../MemberReadHistoryController.java | 30 ++--- .../controller/OmsCartItemController.java | 50 ++++---- .../controller/OmsPortalOrderController.java | 10 +- .../OmsPortalOrderReturnApplyController.java | 8 +- .../controller/UmsMemberController.java | 13 +- .../controller/UmsMemberCouponController.java | 12 +- .../UmsMemberReceiveAddressController.java | 37 +++--- .../mall/portal/domain/CommonResult.java | 97 -------------- .../portal/service/OmsPortalOrderService.java | 2 +- .../service/UmsMemberCouponService.java | 2 +- .../mall/portal/service/UmsMemberService.java | 2 +- .../impl/OmsPortalOrderServiceImpl.java | 96 +++++++------- .../impl/UmsMemberCouponServiceImpl.java | 12 +- .../service/impl/UmsMemberServiceImpl.java | 16 +-- mall-search/pom.xml | 41 +----- .../controller/EsProductController.java | 59 ++++----- .../mall/search/domain/CommonResult.java | 81 ------------ pom.xml | 41 +++++- 34 files changed, 500 insertions(+), 634 deletions(-) create mode 100644 mall-common/pom.xml rename {mall-demo/src/main/java/com/macro/mall/demo/dto => mall-common/src/main/java/com/macro/mall/common/api}/CommonPage.java (63%) create mode 100644 mall-common/src/main/java/com/macro/mall/common/api/CommonResult.java create mode 100644 mall-common/src/main/java/com/macro/mall/common/api/IErrorCode.java create mode 100644 mall-common/src/main/java/com/macro/mall/common/api/ResultCode.java delete mode 100644 mall-demo/src/main/java/com/macro/mall/demo/dto/CommonResult.java delete mode 100644 mall-portal/src/main/java/com/macro/mall/portal/domain/CommonResult.java delete mode 100644 mall-search/src/main/java/com/macro/mall/search/domain/CommonResult.java diff --git a/mall-admin/pom.xml b/mall-admin/pom.xml index 8f32452..47dc14c 100644 --- a/mall-admin/pom.xml +++ b/mall-admin/pom.xml @@ -4,19 +4,12 @@ com.macro.mall mall-admin - 0.0.1-SNAPSHOT + 1.0-SNAPSHOT jar mall-admin mall-admin project for mall - - org.springframework.boot - spring-boot-starter-parent - 2.1.3.RELEASE - - - UTF-8 UTF-8 @@ -24,50 +17,22 @@ true + + com.macro.mall + mall + 1.0-SNAPSHOT + + com.macro.mall mall-mbg 1.0-SNAPSHOT - - org.springframework.boot - spring-boot-starter-web - org.springframework.boot spring-boot-starter-security - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-aop - - - org.springframework.boot - spring-boot-starter-test - test - - - - com.github.pagehelper - pagehelper-spring-boot-starter - 1.2.10 - - - - io.springfox - springfox-swagger2 - 2.6.1 - - - io.springfox - springfox-swagger-ui - 2.6.1 - io.jsonwebtoken @@ -86,12 +51,6 @@ logstash-logback-encoder 4.8 - - - com.alibaba - druid-spring-boot-starter - 1.1.10 - org.projectlombok diff --git a/mall-common/pom.xml b/mall-common/pom.xml new file mode 100644 index 0000000..9933140 --- /dev/null +++ b/mall-common/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + com.macro.mall + mall-common + 1.0-SNAPSHOT + jar + + mall-common + mall-common project for mall + + + + com.github.pagehelper + pagehelper + 5.1.8 + + + + io.springfox + springfox-swagger2 + 2.7.0 + + + io.springfox + springfox-swagger-ui + 2.7.0 + + + org.springframework.data + spring-data-commons + 2.1.5.RELEASE + compile + + + + \ No newline at end of file diff --git a/mall-demo/src/main/java/com/macro/mall/demo/dto/CommonPage.java b/mall-common/src/main/java/com/macro/mall/common/api/CommonPage.java similarity index 63% rename from mall-demo/src/main/java/com/macro/mall/demo/dto/CommonPage.java rename to mall-common/src/main/java/com/macro/mall/common/api/CommonPage.java index 134c750..6136005 100644 --- a/mall-demo/src/main/java/com/macro/mall/demo/dto/CommonPage.java +++ b/mall-common/src/main/java/com/macro/mall/common/api/CommonPage.java @@ -1,6 +1,7 @@ -package com.macro.mall.demo.dto; +package com.macro.mall.common.api; import com.github.pagehelper.PageInfo; +import org.springframework.data.domain.Page; import java.util.List; @@ -14,11 +15,11 @@ public class CommonPage { private List list; /** - * 将PageHelper分页后的list转为分页信息 + * 将PageHelper分页后的list转为分页信息 */ public static CommonPage restPage(List list) { - CommonPage result = new CommonPage<>(); - PageInfo pageInfo = new PageInfo<>(list); + CommonPage result = new CommonPage(); + PageInfo pageInfo = new PageInfo(list); result.setTotalPage(pageInfo.getTotal() / pageInfo.getPageSize()); result.setPageNum(pageInfo.getPageNum()); result.setPageSize(pageInfo.getPageSize()); @@ -26,6 +27,18 @@ public class CommonPage { return result; } + /** + * 将SpringData分页后的list转为分页信息 + */ + public static CommonPage restPage(Page pageInfo) { + CommonPage result = new CommonPage(); + result.setTotalPage((long) pageInfo.getTotalPages()); + result.setPageNum(pageInfo.getNumber()); + result.setPageSize(pageInfo.getSize()); + result.setList(pageInfo.getContent()); + return result; + } + public Integer getPageNum() { return pageNum; } diff --git a/mall-common/src/main/java/com/macro/mall/common/api/CommonResult.java b/mall-common/src/main/java/com/macro/mall/common/api/CommonResult.java new file mode 100644 index 0000000..2d6d9c3 --- /dev/null +++ b/mall-common/src/main/java/com/macro/mall/common/api/CommonResult.java @@ -0,0 +1,118 @@ +package com.macro.mall.common.api; + +/** + * 通用返回对象 + */ +public class CommonResult { + private long code; + private String message; + private T data; + + /** + * 普通成功返回 + * + * @param data 获取的数据 + */ + public static CommonResult success(T data) { + CommonResult result = new CommonResult(); + result.setCode(ResultCode.SUCCESS.getCode()); + result.setMessage(ResultCode.SUCCESS.getMsg()); + result.setData(data); + return result; + } + + /** + * 普通成功返回 + * + * @param data 获取的数据 + */ + public static CommonResult success(T data,String message) { + CommonResult result = new CommonResult(); + result.setCode(ResultCode.SUCCESS.getCode()); + result.setMessage(message); + result.setData(data); + return result; + } + + /** + * 通过错误码对象构造返回结果 + */ + public static CommonResult failed(IErrorCode errorCode) { + CommonResult result = new CommonResult(); + result.setCode(errorCode.getCode()); + result.setMessage(errorCode.getMsg()); + return result; + } + + /** + * 普通失败提示信息 + */ + public static CommonResult failed(String message) { + CommonResult result = new CommonResult(); + result.setCode(ResultCode.FAILED.getCode()); + result.setMessage(message); + return result; + } + + /** + * 普通操作失败 + */ + public static CommonResult failed() { + return failed(ResultCode.FAILED); + } + + /** + * 参数验证失败使用 + */ + public static CommonResult validateFailed() { + return failed(ResultCode.VALIDATE_FAILED); + } + + /** + * 参数验证失败使用 + */ + public static CommonResult validateFailed(String message) { + CommonResult result = new CommonResult(); + result.setCode(ResultCode.FAILED.getCode()); + result.setMessage(message); + return result; + } + + /** + * 用户没有登录 + */ + public static CommonResult unauthorized() { + return failed(ResultCode.UNAUTHORIZED); + } + + /** + * 用户没有相应权限 + */ + public static CommonResult forbidden() { + return failed(ResultCode.UNAUTHORIZED); + } + + public long getCode() { + return code; + } + + public void setCode(long 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; + } +} diff --git a/mall-common/src/main/java/com/macro/mall/common/api/IErrorCode.java b/mall-common/src/main/java/com/macro/mall/common/api/IErrorCode.java new file mode 100644 index 0000000..ce08f92 --- /dev/null +++ b/mall-common/src/main/java/com/macro/mall/common/api/IErrorCode.java @@ -0,0 +1,11 @@ +package com.macro.mall.common.api; + +/** + * 封装API的错误码 + * Created by macro on 2019/4/19. + */ +public interface IErrorCode { + long getCode(); + + String getMsg(); +} diff --git a/mall-common/src/main/java/com/macro/mall/common/api/ResultCode.java b/mall-common/src/main/java/com/macro/mall/common/api/ResultCode.java new file mode 100644 index 0000000..b076f3e --- /dev/null +++ b/mall-common/src/main/java/com/macro/mall/common/api/ResultCode.java @@ -0,0 +1,28 @@ +package com.macro.mall.common.api; + +/** + * 枚举了一些常用API操作码 + * Created by macro on 2019/4/19. + */ +public enum ResultCode implements IErrorCode { + SUCCESS(200, "操作成功"), + FAILED(500, "操作失败"), + VALIDATE_FAILED(404, "参数检验失败"), + UNAUTHORIZED(401, "暂未登录或token已经过期"), + FORBIDDEN(403, "没有相关权限"); + private long code; + private String msg; + + private ResultCode(long code, String msg) { + this.code = code; + this.msg = msg; + } + + public long getCode() { + return code; + } + + public String getMsg() { + return msg; + } +} diff --git a/mall-demo/pom.xml b/mall-demo/pom.xml index f399286..5483d95 100644 --- a/mall-demo/pom.xml +++ b/mall-demo/pom.xml @@ -5,35 +5,28 @@ com.macro.mall mall-demo - 0.0.1-SNAPSHOT + 1.0-SNAPSHOT jar mall-demo Demo project for Spring Boot - - org.springframework.boot - spring-boot-starter-parent - 2.1.3.RELEASE - - - UTF-8 UTF-8 1.8 - + + com.macro.mall + mall + 1.0-SNAPSHOT + com.macro.mall mall-mbg 1.0-SNAPSHOT - - org.springframework.boot - spring-boot-starter-web - org.springframework.boot spring-boot-starter-thymeleaf @@ -42,36 +35,6 @@ org.springframework.boot spring-boot-starter-security - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-aop - - - org.springframework.boot - spring-boot-starter-test - test - - - - com.github.pagehelper - pagehelper-spring-boot-starter - 1.2.10 - - - - io.springfox - springfox-swagger2 - 2.6.1 - - - io.springfox - springfox-swagger-ui - 2.6.1 - net.logstash.logback diff --git a/mall-demo/src/main/java/com/macro/mall/demo/controller/DemoController.java b/mall-demo/src/main/java/com/macro/mall/demo/controller/DemoController.java index cd858f8..1f361f2 100644 --- a/mall-demo/src/main/java/com/macro/mall/demo/controller/DemoController.java +++ b/mall-demo/src/main/java/com/macro/mall/demo/controller/DemoController.java @@ -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.*; diff --git a/mall-demo/src/main/java/com/macro/mall/demo/controller/RestTemplateDemoController.java b/mall-demo/src/main/java/com/macro/mall/demo/controller/RestTemplateDemoController.java index 80e73b3..1948cd5 100644 --- a/mall-demo/src/main/java/com/macro/mall/demo/controller/RestTemplateDemoController.java +++ b/mall-demo/src/main/java/com/macro/mall/demo/controller/RestTemplateDemoController.java @@ -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; diff --git a/mall-demo/src/main/java/com/macro/mall/demo/dto/CommonResult.java b/mall-demo/src/main/java/com/macro/mall/demo/dto/CommonResult.java deleted file mode 100644 index af841db..0000000 --- a/mall-demo/src/main/java/com/macro/mall/demo/dto/CommonResult.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.macro.mall.demo.dto; - -/** - * 通用返回对象 - */ -public class CommonResult { - 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 CommonResult success(T data) { - CommonResult result = new CommonResult(); - result.setCode(SUCCESS); - result.setData(data); - return result; - } - - /** - * 普通失败提示信息 - */ - public static CommonResult failed(String message) { - CommonResult result = new CommonResult(); - result.setCode(FAILED); - result.setMessage(message); - return result; - } - - /** - * 参数验证失败使用 - * - * @param message 错误信息 - */ - public static CommonResult 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; - } -} diff --git a/mall-mbg/pom.xml b/mall-mbg/pom.xml index 9e50890..a2c3055 100644 --- a/mall-mbg/pom.xml +++ b/mall-mbg/pom.xml @@ -13,6 +13,11 @@ mall-mbg project for mall + + com.macro.mall + mall-common + 1.0-SNAPSHOT + org.mybatis.generator diff --git a/mall-portal/pom.xml b/mall-portal/pom.xml index 999706f..81f2a6b 100644 --- a/mall-portal/pom.xml +++ b/mall-portal/pom.xml @@ -5,19 +5,12 @@ com.macro.mall mall-portal - 0.0.1-SNAPSHOT + 1.0-SNAPSHOT jar mall-portal Demo project for Spring Boot - - org.springframework.boot - spring-boot-starter-parent - 2.1.3.RELEASE - - - UTF-8 UTF-8 @@ -25,6 +18,13 @@ true + + com.macro.mall + mall + 1.0-SNAPSHOT + + + com.macro.mall @@ -35,47 +35,15 @@ org.springframework.boot spring-boot-starter-data-mongodb - - org.springframework.boot - spring-boot-starter-web - org.springframework.boot spring-boot-starter-security - - org.springframework.boot - spring-boot-starter-test - test - - - - com.github.pagehelper - pagehelper-spring-boot-starter - 1.2.10 - - - - io.springfox - springfox-swagger2 - 2.6.1 - - - io.springfox - springfox-swagger-ui - 2.6.1 - org.springframework.boot spring-boot-starter-data-redis - - - com.alibaba - druid-spring-boot-starter - 1.1.10 - org.springframework.boot diff --git a/mall-portal/src/main/java/com/macro/mall/portal/component/OrderTimeOutCancelTask.java b/mall-portal/src/main/java/com/macro/mall/portal/component/OrderTimeOutCancelTask.java index 8ee4c54..c174458 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/component/OrderTimeOutCancelTask.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/component/OrderTimeOutCancelTask.java @@ -1,6 +1,6 @@ package com.macro.mall.portal.component; -import com.macro.mall.portal.domain.CommonResult; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.portal.service.OmsPortalOrderService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/mall-portal/src/main/java/com/macro/mall/portal/controller/HomeController.java b/mall-portal/src/main/java/com/macro/mall/portal/controller/HomeController.java index 58e49d4..4d9af1c 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/controller/HomeController.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/controller/HomeController.java @@ -1,9 +1,9 @@ package com.macro.mall.portal.controller; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.model.CmsSubject; import com.macro.mall.model.PmsProduct; import com.macro.mall.model.PmsProductCategory; -import com.macro.mall.portal.domain.CommonResult; import com.macro.mall.portal.domain.HomeContentResult; import com.macro.mall.portal.service.HomeService; import io.swagger.annotations.Api; @@ -28,35 +28,35 @@ public class HomeController { @ApiOperation("首页内容页信息展示") @RequestMapping(value = "/content", method = RequestMethod.GET) @ResponseBody - public Object content() { + public CommonResult content() { HomeContentResult contentResult = homeService.content(); - return new CommonResult().success(contentResult); + return CommonResult.success(contentResult); } @ApiOperation("分页获取推荐商品") @RequestMapping(value = "/recommendProductList", method = RequestMethod.GET) @ResponseBody - public Object recommendProductList(@RequestParam(value = "pageSize", defaultValue = "4") Integer pageSize, - @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) { + public CommonResult> recommendProductList(@RequestParam(value = "pageSize", defaultValue = "4") Integer pageSize, + @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) { List productList = homeService.recommendProductList(pageSize, pageNum); - return new CommonResult().success(productList); + return CommonResult.success(productList); } @ApiOperation("获取首页商品分类") @RequestMapping(value = "/productCateList/{parentId}", method = RequestMethod.GET) @ResponseBody - public Object getProductCateList(@PathVariable Long parentId) { + public CommonResult> getProductCateList(@PathVariable Long parentId) { List productCategoryList = homeService.getProductCateList(parentId); - return new CommonResult().success(productCategoryList); + return CommonResult.success(productCategoryList); } @ApiOperation("根据分类获取专题") @RequestMapping(value = "/subjectList", method = RequestMethod.GET) @ResponseBody - public Object getSubjectList(@RequestParam(required = false) Long cateId, - @RequestParam(value = "pageSize", defaultValue = "4") Integer pageSize, - @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) { + public CommonResult> getSubjectList(@RequestParam(required = false) Long cateId, + @RequestParam(value = "pageSize", defaultValue = "4") Integer pageSize, + @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) { List subjectList = homeService.getSubjectList(cateId,pageSize,pageNum); - return new CommonResult().success(subjectList); + return CommonResult.success(subjectList); } } diff --git a/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberAttentionController.java b/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberAttentionController.java index 7841817..c5947df 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberAttentionController.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberAttentionController.java @@ -1,6 +1,6 @@ package com.macro.mall.portal.controller; -import com.macro.mall.portal.domain.CommonResult; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.portal.domain.MemberBrandAttention; import com.macro.mall.portal.service.MemberAttentionService; import io.swagger.annotations.Api; @@ -24,32 +24,32 @@ public class MemberAttentionController { @ApiOperation("添加品牌关注") @RequestMapping(value = "/add", method = RequestMethod.POST) @ResponseBody - public Object add(@RequestBody MemberBrandAttention memberBrandAttention) { + public CommonResult add(@RequestBody MemberBrandAttention memberBrandAttention) { int count = memberAttentionService.add(memberBrandAttention); if(count>0){ - return new CommonResult().success(count); + return CommonResult.success(count); }else{ - return new CommonResult().failed(); + return CommonResult.failed(); } } @ApiOperation("取消关注") @RequestMapping(value = "/delete", method = RequestMethod.POST) @ResponseBody - public Object delete(Long memberId, Long brandId) { + public CommonResult delete(Long memberId, Long brandId) { int count = memberAttentionService.delete(memberId,brandId); if(count>0){ - return new CommonResult().success(count); + return CommonResult.success(count); }else{ - return new CommonResult().failed(); + return CommonResult.failed(); } } @ApiOperation("显示关注列表") @RequestMapping(value = "/list/{memberId}", method = RequestMethod.GET) @ResponseBody - public Object list(@PathVariable Long memberId) { + public CommonResult> list(@PathVariable Long memberId) { List memberBrandAttentionList = memberAttentionService.list(memberId); - return new CommonResult().success(memberBrandAttentionList); + return CommonResult.success(memberBrandAttentionList); } } diff --git a/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberCollectionController.java b/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberCollectionController.java index 8863811..63d3fac 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberCollectionController.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberCollectionController.java @@ -1,6 +1,6 @@ package com.macro.mall.portal.controller; -import com.macro.mall.portal.domain.CommonResult; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.portal.domain.MemberProductCollection; import com.macro.mall.portal.service.MemberCollectionService; import io.swagger.annotations.Api; @@ -21,35 +21,36 @@ import java.util.List; public class MemberCollectionController { @Autowired private MemberCollectionService memberCollectionService; + @ApiOperation("添加商品收藏") @RequestMapping(value = "/addProduct", method = RequestMethod.POST) @ResponseBody - public Object addProduct(@RequestBody MemberProductCollection productCollection) { + public CommonResult addProduct(@RequestBody MemberProductCollection productCollection) { int count = memberCollectionService.addProduct(productCollection); - if(count>0){ - return new CommonResult().success(count); - }else{ - return new CommonResult().failed(); + if (count > 0) { + return CommonResult.success(count); + } else { + return CommonResult.failed(); } } @ApiOperation("删除收藏商品") @RequestMapping(value = "/deleteProduct", method = RequestMethod.POST) @ResponseBody - public Object deleteProduct(Long memberId, Long productId) { - int count = memberCollectionService.deleteProduct(memberId,productId); - if(count>0){ - return new CommonResult().success(count); - }else{ - return new CommonResult().failed(); + public CommonResult deleteProduct(Long memberId, Long productId) { + int count = memberCollectionService.deleteProduct(memberId, productId); + if (count > 0) { + return CommonResult.success(count); + } else { + return CommonResult.failed(); } } @ApiOperation("显示关注列表") @RequestMapping(value = "/listProduct/{memberId}", method = RequestMethod.GET) @ResponseBody - public Object listProduct(@PathVariable Long memberId) { + public CommonResult> listProduct(@PathVariable Long memberId) { List memberProductCollectionList = memberCollectionService.listProduct(memberId); - return new CommonResult().success(memberProductCollectionList); + return CommonResult.success(memberProductCollectionList); } } diff --git a/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberReadHistoryController.java b/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberReadHistoryController.java index 5808e58..8393408 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberReadHistoryController.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/controller/MemberReadHistoryController.java @@ -1,6 +1,6 @@ package com.macro.mall.portal.controller; -import com.macro.mall.portal.domain.CommonResult; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.portal.domain.MemberReadHistory; import com.macro.mall.portal.service.MemberReadHistoryService; import io.swagger.annotations.Api; @@ -25,32 +25,32 @@ public class MemberReadHistoryController { @ApiOperation("创建浏览记录") @RequestMapping(value = "/create", method = RequestMethod.POST) @ResponseBody - public Object create(@RequestBody MemberReadHistory memberReadHistory) { - int count = memberReadHistoryService.create(memberReadHistory); - if(count>0){ - return new CommonResult().success(count); - }else{ - return new CommonResult().failed(); + public CommonResult create(@RequestBody MemberReadHistory memberReadHistory) { + int count = memberReadHistoryService.create(memberReadHistory); + if (count > 0) { + return CommonResult.success(count); + } else { + return CommonResult.failed(); } } @ApiOperation("删除浏览记录") @RequestMapping(value = "/delete", method = RequestMethod.POST) @ResponseBody - public Object delete(@RequestParam("ids") List ids) { - int count = memberReadHistoryService.delete(ids); - if(count>0){ - return new CommonResult().success(count); - }else{ - return new CommonResult().failed(); + public CommonResult delete(@RequestParam("ids") List ids) { + int count = memberReadHistoryService.delete(ids); + if (count > 0) { + return CommonResult.success(count); + } else { + return CommonResult.failed(); } } @ApiOperation("展示浏览记录") @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseBody - public Object list(Long memberId) { + public CommonResult> list(Long memberId) { List memberReadHistoryList = memberReadHistoryService.list(memberId); - return new CommonResult().success(memberReadHistoryList); + return CommonResult.success(memberReadHistoryList); } } diff --git a/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsCartItemController.java b/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsCartItemController.java index a177ba2..74af308 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsCartItemController.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsCartItemController.java @@ -1,9 +1,9 @@ package com.macro.mall.portal.controller; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.model.OmsCartItem; import com.macro.mall.portal.domain.CartProduct; import com.macro.mall.portal.domain.CartPromotionItem; -import com.macro.mall.portal.domain.CommonResult; import com.macro.mall.portal.service.OmsCartItemService; import com.macro.mall.portal.service.UmsMemberService; import io.swagger.annotations.Api; @@ -30,80 +30,80 @@ public class OmsCartItemController { @ApiOperation("添加商品到购物车") @RequestMapping(value = "/add", method = RequestMethod.POST) @ResponseBody - public Object add(@RequestBody OmsCartItem cartItem) { + public CommonResult add(@RequestBody OmsCartItem cartItem) { int count = cartItemService.add(cartItem); if (count > 0) { - return new CommonResult().success(count); + return CommonResult.success(count); } - return new CommonResult().failed(); + return CommonResult.failed(); } @ApiOperation("获取某个会员的购物车列表") @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseBody - public Object list() { + public CommonResult> list() { List cartItemList = cartItemService.list(memberService.getCurrentMember().getId()); - return new CommonResult().success(cartItemList); + return CommonResult.success(cartItemList); } @ApiOperation("获取某个会员的购物车列表,包括促销信息") @RequestMapping(value = "/list/promotion", method = RequestMethod.GET) @ResponseBody - public Object listPromotion() { + public CommonResult> listPromotion() { List cartPromotionItemList = cartItemService.listPromotion(memberService.getCurrentMember().getId()); - return new CommonResult().success(cartPromotionItemList); + return CommonResult.success(cartPromotionItemList); } @ApiOperation("修改购物车中某个商品的数量") @RequestMapping(value = "/update/quantity", method = RequestMethod.GET) @ResponseBody - public Object updateQuantity(@RequestParam Long id, - @RequestParam Integer quantity) { - int count = cartItemService.updateQuantity(id,memberService.getCurrentMember().getId(),quantity); + public CommonResult updateQuantity(@RequestParam Long id, + @RequestParam Integer quantity) { + int count = cartItemService.updateQuantity(id, memberService.getCurrentMember().getId(), quantity); if (count > 0) { - return new CommonResult().success(count); + return CommonResult.success(count); } - return new CommonResult().failed(); + return CommonResult.failed(); } @ApiOperation("获取购物车中某个商品的规格,用于重选规格") @RequestMapping(value = "/getProduct/{productId}", method = RequestMethod.GET) @ResponseBody - public Object getCartProduct(@PathVariable Long productId) { + public CommonResult getCartProduct(@PathVariable Long productId) { CartProduct cartProduct = cartItemService.getCartProduct(productId); - return new CommonResult().success(cartProduct); + return CommonResult.success(cartProduct); } @ApiOperation("修改购物车中商品的规格") @RequestMapping(value = "/update/attr", method = RequestMethod.POST) @ResponseBody - public Object updateAttr(@RequestBody OmsCartItem cartItem) { + public CommonResult updateAttr(@RequestBody OmsCartItem cartItem) { int count = cartItemService.updateAttr(cartItem); if (count > 0) { - return new CommonResult().success(count); + return CommonResult.success(count); } - return new CommonResult().failed(); + return CommonResult.failed(); } @ApiOperation("删除购物车中的某个商品") @RequestMapping(value = "/delete", method = RequestMethod.POST) @ResponseBody - public Object delete(@RequestParam("ids") List ids) { - int count = cartItemService.delete(memberService.getCurrentMember().getId(),ids); + public CommonResult delete(@RequestParam("ids") List ids) { + int count = cartItemService.delete(memberService.getCurrentMember().getId(), ids); if (count > 0) { - return new CommonResult().success(count); + return CommonResult.success(count); } - return new CommonResult().failed(); + return CommonResult.failed(); } @ApiOperation("清空购物车") @RequestMapping(value = "/clear", method = RequestMethod.POST) @ResponseBody - public Object clear() { + public CommonResult clear() { int count = cartItemService.clear(memberService.getCurrentMember().getId()); if (count > 0) { - return new CommonResult().success(count); + return CommonResult.success(count); } - return new CommonResult().failed(); + return CommonResult.failed(); } } diff --git a/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsPortalOrderController.java b/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsPortalOrderController.java index 883e1a2..78ec7cb 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsPortalOrderController.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsPortalOrderController.java @@ -1,6 +1,6 @@ package com.macro.mall.portal.controller; -import com.macro.mall.portal.domain.CommonResult; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.portal.domain.ConfirmOrderResult; import com.macro.mall.portal.domain.OrderParam; import com.macro.mall.portal.service.OmsPortalOrderService; @@ -23,9 +23,9 @@ public class OmsPortalOrderController { @ApiOperation("根据购物车信息生成确认单信息") @RequestMapping(value = "/generateConfirmOrder",method = RequestMethod.POST) @ResponseBody - public Object generateConfirmOrder(){ + public CommonResult generateConfirmOrder(){ ConfirmOrderResult confirmOrderResult = portalOrderService.generateConfirmOrder(); - return new CommonResult().success(confirmOrderResult); + return CommonResult.success(confirmOrderResult); } @ApiOperation("根据购物车信息生成订单") @@ -51,8 +51,8 @@ public class OmsPortalOrderController { @ApiOperation("取消单个超时订单") @RequestMapping(value = "/cancelOrder",method = RequestMethod.POST) @ResponseBody - public Object cancelOrder(Long orderId){ + public CommonResult cancelOrder(Long orderId){ portalOrderService.sendDelayMessageCancelOrder(orderId); - return new CommonResult().success(null); + return CommonResult.success(null); } } diff --git a/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsPortalOrderReturnApplyController.java b/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsPortalOrderReturnApplyController.java index 0cda83d..ba832cc 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsPortalOrderReturnApplyController.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/controller/OmsPortalOrderReturnApplyController.java @@ -1,6 +1,6 @@ package com.macro.mall.portal.controller; -import com.macro.mall.portal.domain.CommonResult; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.portal.domain.OmsOrderReturnApplyParam; import com.macro.mall.portal.service.OmsPortalOrderReturnApplyService; import io.swagger.annotations.Api; @@ -26,11 +26,11 @@ public class OmsPortalOrderReturnApplyController { @ApiOperation("申请退货") @RequestMapping(value = "/create", method = RequestMethod.POST) @ResponseBody - public Object create(@RequestBody OmsOrderReturnApplyParam returnApply) { + public CommonResult create(@RequestBody OmsOrderReturnApplyParam returnApply) { int count = returnApplyService.create(returnApply); if (count > 0) { - return new CommonResult().success(count); + return CommonResult.success(count); } - return new CommonResult().failed(); + return CommonResult.failed(); } } diff --git a/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberController.java b/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberController.java index d71e768..655b9f9 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberController.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberController.java @@ -1,5 +1,6 @@ package com.macro.mall.portal.controller; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.portal.service.UmsMemberService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -24,24 +25,24 @@ public class UmsMemberController { @ApiOperation("注册") @RequestMapping(value = "/register", method = RequestMethod.POST) @ResponseBody - public Object register(@RequestParam String username, - @RequestParam String password, - @RequestParam String telephone, - @RequestParam String authCode) { + public CommonResult register(@RequestParam String username, + @RequestParam String password, + @RequestParam String telephone, + @RequestParam String authCode) { return memberService.register(username, password, telephone, authCode); } @ApiOperation("获取验证码") @RequestMapping(value = "/getAuthCode", method = RequestMethod.GET) @ResponseBody - public Object getAuthCode(@RequestParam String telephone) { + public CommonResult getAuthCode(@RequestParam String telephone) { return memberService.generateAuthCode(telephone); } @ApiOperation("修改密码") @RequestMapping(value = "/updatePassword", method = RequestMethod.POST) @ResponseBody - public Object updatePassword(@RequestParam String telephone, + public CommonResult updatePassword(@RequestParam String telephone, @RequestParam String password, @RequestParam String authCode) { return memberService.updatePassword(telephone,password,authCode); diff --git a/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberCouponController.java b/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberCouponController.java index 9ebfbf8..c088cd0 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberCouponController.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberCouponController.java @@ -1,8 +1,8 @@ package com.macro.mall.portal.controller; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.model.SmsCouponHistory; import com.macro.mall.portal.domain.CartPromotionItem; -import com.macro.mall.portal.domain.CommonResult; import com.macro.mall.portal.domain.SmsCouponHistoryDetail; import com.macro.mall.portal.service.OmsCartItemService; import com.macro.mall.portal.service.UmsMemberCouponService; @@ -34,7 +34,7 @@ public class UmsMemberCouponController { @ApiOperation("领取指定优惠券") @RequestMapping(value = "/add/{couponId}", method = RequestMethod.POST) @ResponseBody - public Object add(@PathVariable Long couponId) { + public CommonResult add(@PathVariable Long couponId) { return memberCouponService.add(couponId); } @@ -43,9 +43,9 @@ public class UmsMemberCouponController { allowableValues = "0,1,2", paramType = "query", dataType = "integer") @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseBody - public Object list(@RequestParam(value = "useStatus", required = false) Integer useStatus) { + public CommonResult> list(@RequestParam(value = "useStatus", required = false) Integer useStatus) { List couponHistoryList = memberCouponService.list(useStatus); - return new CommonResult().success(couponHistoryList); + return CommonResult.success(couponHistoryList); } @ApiOperation("获取登录会员购物车的相关优惠券") @@ -53,9 +53,9 @@ public class UmsMemberCouponController { defaultValue = "1", allowableValues = "0,1", paramType = "query", dataType = "integer") @RequestMapping(value = "/list/cart/{type}", method = RequestMethod.GET) @ResponseBody - public Object listCart(@PathVariable Integer type) { + public CommonResult> listCart(@PathVariable Integer type) { List cartPromotionItemList = cartItemService.listPromotion(memberService.getCurrentMember().getId()); List couponHistoryList = memberCouponService.listCart(cartPromotionItemList, type); - return new CommonResult().success(couponHistoryList); + return CommonResult.success(couponHistoryList); } } diff --git a/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberReceiveAddressController.java b/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberReceiveAddressController.java index b7a7170..76cfb33 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberReceiveAddressController.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/controller/UmsMemberReceiveAddressController.java @@ -1,7 +1,7 @@ package com.macro.mall.portal.controller; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.model.UmsMemberReceiveAddress; -import com.macro.mall.portal.domain.CommonResult; import com.macro.mall.portal.service.UmsMemberReceiveAddressService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -21,52 +21,53 @@ import java.util.List; public class UmsMemberReceiveAddressController { @Autowired private UmsMemberReceiveAddressService memberReceiveAddressService; + @ApiOperation("添加收货地址") @RequestMapping(value = "/add", method = RequestMethod.POST) @ResponseBody - public Object add(@RequestBody UmsMemberReceiveAddress address) { + public CommonResult add(@RequestBody UmsMemberReceiveAddress address) { int count = memberReceiveAddressService.add(address); - if(count>0){ - return new CommonResult().success(count); + if (count > 0) { + return CommonResult.success(count); } - return new CommonResult().failed(); + return CommonResult.failed(); } @ApiOperation("删除收货地址") @RequestMapping(value = "/delete/{id}", method = RequestMethod.POST) @ResponseBody - public Object delete(@PathVariable Long id) { + public CommonResult delete(@PathVariable Long id) { int count = memberReceiveAddressService.delete(id); - if(count>0){ - return new CommonResult().success(count); + if (count > 0) { + return CommonResult.success(count); } - return new CommonResult().failed(); + return CommonResult.failed(); } @ApiOperation("修改收货地址") @RequestMapping(value = "/update/{id}", method = RequestMethod.POST) @ResponseBody - public Object update(@PathVariable Long id,@RequestBody UmsMemberReceiveAddress address) { - int count = memberReceiveAddressService.update(id,address); - if(count>0){ - return new CommonResult().success(count); + public CommonResult update(@PathVariable Long id, @RequestBody UmsMemberReceiveAddress address) { + int count = memberReceiveAddressService.update(id, address); + if (count > 0) { + return CommonResult.success(count); } - return new CommonResult().failed(); + return CommonResult.failed(); } @ApiOperation("显示所有收货地址") @RequestMapping(value = "/list", method = RequestMethod.GET) @ResponseBody - public Object list() { + public CommonResult> list() { List addressList = memberReceiveAddressService.list(); - return new CommonResult().success(addressList); + return CommonResult.success(addressList); } @ApiOperation("显示所有收货地址") @RequestMapping(value = "/{id}", method = RequestMethod.GET) @ResponseBody - public Object getItem(@PathVariable Long id) { + public CommonResult getItem(@PathVariable Long id) { UmsMemberReceiveAddress address = memberReceiveAddressService.getItem(id); - return new CommonResult().success(address); + return CommonResult.success(address); } } diff --git a/mall-portal/src/main/java/com/macro/mall/portal/domain/CommonResult.java b/mall-portal/src/main/java/com/macro/mall/portal/domain/CommonResult.java deleted file mode 100644 index 2d9abd4..0000000 --- a/mall-portal/src/main/java/com/macro/mall/portal/domain/CommonResult.java +++ /dev/null @@ -1,97 +0,0 @@ -package com.macro.mall.portal.domain; - -import org.springframework.data.domain.Page; - -import java.util.HashMap; -import java.util.Map; - -/** - * 通用返回对象 - * Created by macro on 2018/4/26. - */ -public class CommonResult { - //操作成功 - public static final int SUCCESS = 200; - //操作失败 - public static final int FAILED = 500; - private int code; - private String message; - private Object data; - - /** - * 普通成功返回 - * - * @param data 获取的数据 - */ - public CommonResult success(Object data) { - this.code = SUCCESS; - this.message = "操作成功"; - this.data = data; - return this; - } - - /** - * 普通成功返回 - */ - public CommonResult success(String message,Object data) { - this.code = SUCCESS; - this.message = message; - this.data = data; - return this; - } - - /** - * 返回分页成功数据 - */ - public CommonResult pageSuccess(Page pageInfo) { - Map result = new HashMap<>(); - result.put("pageSize", pageInfo.getSize()); - result.put("totalPage", pageInfo.getTotalPages()); - result.put("total", pageInfo.getTotalElements()); - result.put("pageNum", pageInfo.getNumber()); - result.put("list", pageInfo.getContent()); - this.code = SUCCESS; - this.message = "操作成功"; - this.data = result; - return this; - } - - /** - * 普通失败提示信息 - */ - public CommonResult failed() { - this.code = FAILED; - this.message = "操作失败"; - return this; - } - - public CommonResult failed(String message){ - this.code = FAILED; - this.message = message; - return this; - } - - 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 Object getData() { - return data; - } - - public void setData(Object data) { - this.data = data; - } -} diff --git a/mall-portal/src/main/java/com/macro/mall/portal/service/OmsPortalOrderService.java b/mall-portal/src/main/java/com/macro/mall/portal/service/OmsPortalOrderService.java index d66e345..b4cc956 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/service/OmsPortalOrderService.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/service/OmsPortalOrderService.java @@ -1,6 +1,6 @@ package com.macro.mall.portal.service; -import com.macro.mall.portal.domain.CommonResult; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.portal.domain.ConfirmOrderResult; import com.macro.mall.portal.domain.OrderParam; import org.springframework.transaction.annotation.Transactional; diff --git a/mall-portal/src/main/java/com/macro/mall/portal/service/UmsMemberCouponService.java b/mall-portal/src/main/java/com/macro/mall/portal/service/UmsMemberCouponService.java index 62f62cf..98ac7d5 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/service/UmsMemberCouponService.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/service/UmsMemberCouponService.java @@ -1,8 +1,8 @@ package com.macro.mall.portal.service; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.model.SmsCouponHistory; import com.macro.mall.portal.domain.CartPromotionItem; -import com.macro.mall.portal.domain.CommonResult; import com.macro.mall.portal.domain.SmsCouponHistoryDetail; import org.springframework.transaction.annotation.Transactional; diff --git a/mall-portal/src/main/java/com/macro/mall/portal/service/UmsMemberService.java b/mall-portal/src/main/java/com/macro/mall/portal/service/UmsMemberService.java index eee8d1b..4a10e4d 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/service/UmsMemberService.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/service/UmsMemberService.java @@ -1,7 +1,7 @@ package com.macro.mall.portal.service; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.model.UmsMember; -import com.macro.mall.portal.domain.CommonResult; import org.springframework.transaction.annotation.Transactional; /** diff --git a/mall-portal/src/main/java/com/macro/mall/portal/service/impl/OmsPortalOrderServiceImpl.java b/mall-portal/src/main/java/com/macro/mall/portal/service/impl/OmsPortalOrderServiceImpl.java index ef7d3b5..d45c953 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/service/impl/OmsPortalOrderServiceImpl.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/service/impl/OmsPortalOrderServiceImpl.java @@ -1,5 +1,6 @@ package com.macro.mall.portal.service.impl; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.mapper.*; import com.macro.mall.model.*; import com.macro.mall.portal.component.CancelOrderSender; @@ -109,7 +110,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { } //判断购物车中商品是否都有库存 if (!hasStock(cartPromotionItemList)) { - return new CommonResult().failed("库存不足,无法下单"); + return CommonResult.failed("库存不足,无法下单"); } //判断使用使用了优惠券 if (orderParam.getCouponId() == null) { @@ -121,7 +122,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { //使用优惠券 SmsCouponHistoryDetail couponHistoryDetail = getUseCoupon(cartPromotionItemList, orderParam.getCouponId()); if (couponHistoryDetail == null) { - return new CommonResult().failed("该优惠券不可用"); + return CommonResult.failed("该优惠券不可用"); } //对下单商品的优惠券进行处理 handleCouponAmount(orderItemList, couponHistoryDetail); @@ -137,11 +138,11 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { BigDecimal totalAmount = calcTotalAmount(orderItemList); BigDecimal integrationAmount = getUseIntegrationAmount(orderParam.getUseIntegration(), totalAmount, currentMember, orderParam.getCouponId() != null); if (integrationAmount.compareTo(new BigDecimal(0)) == 0) { - return new CommonResult().failed("积分不可用"); + return CommonResult.failed("积分不可用"); } else { //可用情况下分摊到可用商品中 for (OmsOrderItem orderItem : orderItemList) { - BigDecimal perAmount = orderItem.getProductPrice().divide(totalAmount, 3,RoundingMode.HALF_EVEN).multiply(integrationAmount); + BigDecimal perAmount = orderItem.getProductPrice().divide(totalAmount, 3, RoundingMode.HALF_EVEN).multiply(integrationAmount); orderItem.setIntegrationAmount(perAmount); } } @@ -210,20 +211,20 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { } orderItemDao.insertList(orderItemList); //如使用优惠券更新优惠券使用状态 - if(orderParam.getCouponId()!=null){ - updateCouponStatus(orderParam.getCouponId(),currentMember.getId(),1); + if (orderParam.getCouponId() != null) { + updateCouponStatus(orderParam.getCouponId(), currentMember.getId(), 1); } //如使用积分需要扣除积分 - if(orderParam.getUseIntegration()!=null){ + if (orderParam.getUseIntegration() != null) { order.setUseIntegration(orderParam.getUseIntegration()); - memberService.updateIntegration(currentMember.getId(),currentMember.getIntegration()-orderParam.getUseIntegration()); + memberService.updateIntegration(currentMember.getId(), currentMember.getIntegration() - orderParam.getUseIntegration()); } //删除购物车中的下单商品 - deleteCartItemList(cartPromotionItemList,currentMember); - Map result = new HashMap<>(); - result.put("order",order); - result.put("orderItemList",orderItemList); - return new CommonResult().success("下单成功", result); + deleteCartItemList(cartPromotionItemList, currentMember); + Map result = new HashMap<>(); + result.put("order", order); + result.put("orderItemList", orderItemList); + return CommonResult.success(result, "下单成功"); } @Override @@ -237,7 +238,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { //恢复所有下单商品的锁定库存,扣减真实库存 OmsOrderDetail orderDetail = portalOrderDao.getDetail(orderId); int count = portalOrderDao.updateSkuStock(orderDetail.getOrderItemList()); - return new CommonResult().success("支付成功",count); + return CommonResult.success(count,"支付成功"); } @Override @@ -245,27 +246,27 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { OmsOrderSetting orderSetting = orderSettingMapper.selectByPrimaryKey(1L); //查询超时、未支付的订单及订单详情 List timeOutOrders = portalOrderDao.getTimeOutOrders(orderSetting.getNormalOrderOvertime()); - if(CollectionUtils.isEmpty(timeOutOrders)){ - return new CommonResult().failed("暂无超时订单"); + if (CollectionUtils.isEmpty(timeOutOrders)) { + return CommonResult.failed("暂无超时订单"); } //修改订单状态为交易取消 List ids = new ArrayList<>(); for (OmsOrderDetail timeOutOrder : timeOutOrders) { ids.add(timeOutOrder.getId()); } - portalOrderDao.updateOrderStatus(ids,4); + portalOrderDao.updateOrderStatus(ids, 4); for (OmsOrderDetail timeOutOrder : timeOutOrders) { //解除订单商品库存锁定 portalOrderDao.releaseSkuStockLock(timeOutOrder.getOrderItemList()); //修改优惠券使用状态 - updateCouponStatus(timeOutOrder.getCouponId(),timeOutOrder.getMemberId(),0); + updateCouponStatus(timeOutOrder.getCouponId(), timeOutOrder.getMemberId(), 0); //返还使用积分 - if(timeOutOrder.getUseIntegration()!=null){ + if (timeOutOrder.getUseIntegration() != null) { UmsMember member = memberService.getById(timeOutOrder.getMemberId()); - memberService.updateIntegration(timeOutOrder.getMemberId(),member.getIntegration()+timeOutOrder.getUseIntegration()); + memberService.updateIntegration(timeOutOrder.getMemberId(), member.getIntegration() + timeOutOrder.getUseIntegration()); } } - return new CommonResult().success(null); + return CommonResult.success(null); } @Override @@ -274,27 +275,27 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { OmsOrderExample example = new OmsOrderExample(); example.createCriteria().andIdEqualTo(orderId).andStatusEqualTo(0).andDeleteStatusEqualTo(0); List cancelOrderList = orderMapper.selectByExample(example); - if(CollectionUtils.isEmpty(cancelOrderList)){ + if (CollectionUtils.isEmpty(cancelOrderList)) { return; } OmsOrder cancelOrder = cancelOrderList.get(0); - if(cancelOrder!=null){ + if (cancelOrder != null) { //修改订单状态为取消 cancelOrder.setStatus(4); orderMapper.updateByPrimaryKeySelective(cancelOrder); - OmsOrderItemExample orderItemExample=new OmsOrderItemExample(); + OmsOrderItemExample orderItemExample = new OmsOrderItemExample(); orderItemExample.createCriteria().andOrderIdEqualTo(orderId); List orderItemList = orderItemMapper.selectByExample(orderItemExample); //解除订单商品库存锁定 - if(!CollectionUtils.isEmpty(orderItemList)){ + if (!CollectionUtils.isEmpty(orderItemList)) { portalOrderDao.releaseSkuStockLock(orderItemList); } //修改优惠券使用状态 - updateCouponStatus(cancelOrder.getCouponId(),cancelOrder.getMemberId(),0); + updateCouponStatus(cancelOrder.getCouponId(), cancelOrder.getMemberId(), 0); //返还使用积分 - if(cancelOrder.getUseIntegration()!=null){ + if (cancelOrder.getUseIntegration() != null) { UmsMember member = memberService.getById(cancelOrder.getMemberId()); - memberService.updateIntegration(cancelOrder.getMemberId(),member.getIntegration()+cancelOrder.getUseIntegration()); + memberService.updateIntegration(cancelOrder.getMemberId(), member.getIntegration() + cancelOrder.getUseIntegration()); } } } @@ -303,9 +304,9 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { public void sendDelayMessageCancelOrder(Long orderId) { //获取订单超时时间 OmsOrderSetting orderSetting = orderSettingMapper.selectByPrimaryKey(1L); - long delayTimes = orderSetting.getNormalOrderOvertime()*60*1000; + long delayTimes = orderSetting.getNormalOrderOvertime() * 60 * 1000; //发送延迟消息 - cancelOrderSender.sendMessage(orderId,delayTimes); + cancelOrderSender.sendMessage(orderId, delayTimes); } /** @@ -317,12 +318,12 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { String key = REDIS_KEY_PREFIX_ORDER_ID + date; Long increment = redisService.increment(key, 1); sb.append(date); - sb.append(String.format("%02d",order.getSourceType())); - sb.append(String.format("%02d",order.getPayType())); + sb.append(String.format("%02d", order.getSourceType())); + sb.append(String.format("%02d", order.getPayType())); String incrementStr = increment.toString(); - if(incrementStr.length()<=6){ - sb.append(String.format("%06d",increment)); - }else{ + if (incrementStr.length() <= 6) { + sb.append(String.format("%06d", increment)); + } else { sb.append(incrementStr); } return sb.toString(); @@ -336,16 +337,16 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { for (CartPromotionItem cartPromotionItem : cartPromotionItemList) { ids.add(cartPromotionItem.getId()); } - cartItemService.delete(currentMember.getId(),ids); + cartItemService.delete(currentMember.getId(), ids); } /** * 计算该订单赠送的成长值 */ private Integer calcGiftGrowth(List orderItemList) { - Integer sum=0; + Integer sum = 0; for (OmsOrderItem orderItem : orderItemList) { - sum=sum+orderItem.getGiftGrowth()*orderItem.getProductQuantity(); + sum = sum + orderItem.getGiftGrowth() * orderItem.getProductQuantity(); } return sum; } @@ -354,27 +355,28 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { * 计算该订单赠送的积分 */ private Integer calcGifIntegration(List orderItemList) { - int sum=0; + int sum = 0; for (OmsOrderItem orderItem : orderItemList) { - sum+=orderItem.getGiftIntegration()*orderItem.getProductQuantity(); + sum += orderItem.getGiftIntegration() * orderItem.getProductQuantity(); } return sum; } /** * 将优惠券信息更改为指定状态 - * @param couponId 优惠券id - * @param memberId 会员id + * + * @param couponId 优惠券id + * @param memberId 会员id * @param useStatus 0->未使用;1->已使用 */ - private void updateCouponStatus(Long couponId, Long memberId,Integer useStatus) { - if(couponId==null)return; + private void updateCouponStatus(Long couponId, Long memberId, Integer useStatus) { + if (couponId == null) return; //查询第一张优惠券 SmsCouponHistoryExample example = new SmsCouponHistoryExample(); example.createCriteria().andMemberIdEqualTo(memberId) - .andCouponIdEqualTo(couponId).andUseStatusEqualTo(useStatus==0?1:0); + .andCouponIdEqualTo(couponId).andUseStatusEqualTo(useStatus == 0 ? 1 : 0); List couponHistoryList = couponHistoryMapper.selectByExample(example); - if(!CollectionUtils.isEmpty(couponHistoryList)){ + if (!CollectionUtils.isEmpty(couponHistoryList)) { SmsCouponHistory couponHistory = couponHistoryList.get(0); couponHistory.setUseTime(new Date()); couponHistory.setUseStatus(useStatus); @@ -487,7 +489,7 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService { return zeroAmount; } //是否超过订单抵用最高百分比 - BigDecimal integrationAmount = new BigDecimal(useIntegration).divide(new BigDecimal(integrationConsumeSetting.getUseUnit()), 2,RoundingMode.HALF_EVEN); + BigDecimal integrationAmount = new BigDecimal(useIntegration).divide(new BigDecimal(integrationConsumeSetting.getUseUnit()), 2, RoundingMode.HALF_EVEN); BigDecimal maxPercent = new BigDecimal(integrationConsumeSetting.getMaxPercentPerOrder()).divide(new BigDecimal(100), 2, RoundingMode.HALF_EVEN); if (integrationAmount.compareTo(totalAmount.multiply(maxPercent)) > 0) { return zeroAmount; diff --git a/mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberCouponServiceImpl.java b/mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberCouponServiceImpl.java index 796b7fe..adfe3fb 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberCouponServiceImpl.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberCouponServiceImpl.java @@ -1,11 +1,11 @@ package com.macro.mall.portal.service.impl; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.mapper.SmsCouponHistoryMapper; import com.macro.mall.mapper.SmsCouponMapper; import com.macro.mall.model.*; import com.macro.mall.portal.dao.SmsCouponHistoryDao; import com.macro.mall.portal.domain.CartPromotionItem; -import com.macro.mall.portal.domain.CommonResult; import com.macro.mall.portal.domain.SmsCouponHistoryDetail; import com.macro.mall.portal.service.UmsMemberCouponService; import com.macro.mall.portal.service.UmsMemberService; @@ -35,21 +35,21 @@ public class UmsMemberCouponServiceImpl implements UmsMemberCouponService { //获取优惠券信息,判断数量 SmsCoupon coupon = couponMapper.selectByPrimaryKey(couponId); if(coupon==null){ - return new CommonResult().failed("优惠券不存在"); + return CommonResult.failed("优惠券不存在"); } if(coupon.getCount()<=0){ - return new CommonResult().failed("优惠券已经领完了"); + return CommonResult.failed("优惠券已经领完了"); } Date now = new Date(); if(now.before(coupon.getEnableTime())){ - return new CommonResult().failed("优惠券还没到领取时间"); + return CommonResult.failed("优惠券还没到领取时间"); } //判断用户领取的优惠券数量是否超过限制 SmsCouponHistoryExample couponHistoryExample = new SmsCouponHistoryExample(); couponHistoryExample.createCriteria().andCouponIdEqualTo(couponId).andMemberIdEqualTo(currentMember.getId()); int count = couponHistoryMapper.countByExample(couponHistoryExample); if(count>=coupon.getPerLimit()){ - return new CommonResult().failed("您已经领取过该优惠券"); + return CommonResult.failed("您已经领取过该优惠券"); } //生成领取优惠券历史 SmsCouponHistory couponHistory = new SmsCouponHistory(); @@ -67,7 +67,7 @@ public class UmsMemberCouponServiceImpl implements UmsMemberCouponService { coupon.setCount(coupon.getCount()-1); coupon.setReceiveCount(coupon.getReceiveCount()==null?1:coupon.getReceiveCount()+1); couponMapper.updateByPrimaryKey(coupon); - return new CommonResult().success("领取成功",null); + return CommonResult.success(null,"领取成功"); } /** diff --git a/mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberServiceImpl.java b/mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberServiceImpl.java index 78e1538..99d4f59 100644 --- a/mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberServiceImpl.java +++ b/mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberServiceImpl.java @@ -1,12 +1,12 @@ package com.macro.mall.portal.service.impl; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.mapper.UmsMemberLevelMapper; import com.macro.mall.mapper.UmsMemberMapper; import com.macro.mall.model.UmsMember; import com.macro.mall.model.UmsMemberExample; import com.macro.mall.model.UmsMemberLevel; import com.macro.mall.model.UmsMemberLevelExample; -import com.macro.mall.portal.domain.CommonResult; import com.macro.mall.portal.domain.MemberDetails; import com.macro.mall.portal.service.RedisService; import com.macro.mall.portal.service.UmsMemberService; @@ -63,7 +63,7 @@ public class UmsMemberServiceImpl implements UmsMemberService { public CommonResult register(String username, String password, String telephone, String authCode) { //验证验证码 if(!verifyAuthCode(authCode,telephone)){ - return new CommonResult().failed("验证码错误"); + return CommonResult.failed("验证码错误"); } //查询是否已有该用户 UmsMemberExample example = new UmsMemberExample(); @@ -71,7 +71,7 @@ public class UmsMemberServiceImpl implements UmsMemberService { example.or(example.createCriteria().andPhoneEqualTo(telephone)); List umsMembers = memberMapper.selectByExample(example); if (!CollectionUtils.isEmpty(umsMembers)) { - return new CommonResult().failed("该用户已经存在"); + return CommonResult.failed("该用户已经存在"); } //没有该用户进行添加操作 UmsMember umsMember = new UmsMember(); @@ -89,7 +89,7 @@ public class UmsMemberServiceImpl implements UmsMemberService { } memberMapper.insert(umsMember); umsMember.setPassword(null); - return new CommonResult().success("注册成功",null); + return CommonResult.success(null,"注册成功"); } @Override @@ -102,7 +102,7 @@ public class UmsMemberServiceImpl implements UmsMemberService { //验证码绑定手机号并存储到redis redisService.set(REDIS_KEY_PREFIX_AUTH_CODE+telephone,sb.toString()); redisService.expire(REDIS_KEY_PREFIX_AUTH_CODE+telephone,AUTH_CODE_EXPIRE_SECONDS); - return new CommonResult().success("获取验证码成功",sb.toString()); + return CommonResult.success(sb.toString(),"获取验证码成功"); } @Override @@ -111,16 +111,16 @@ public class UmsMemberServiceImpl implements UmsMemberService { example.createCriteria().andPhoneEqualTo(telephone); List memberList = memberMapper.selectByExample(example); if(CollectionUtils.isEmpty(memberList)){ - return new CommonResult().failed("该账号不存在"); + return CommonResult.failed("该账号不存在"); } //验证验证码 if(!verifyAuthCode(authCode,telephone)){ - return new CommonResult().failed("验证码错误"); + return CommonResult.failed("验证码错误"); } UmsMember umsMember = memberList.get(0); umsMember.setPassword(passwordEncoder.encode(password)); memberMapper.updateByPrimaryKeySelective(umsMember); - return new CommonResult().success("密码修改成功",null); + return CommonResult.success(null,"密码修改成功"); } @Override diff --git a/mall-search/pom.xml b/mall-search/pom.xml index 07c66ea..a8f83fd 100644 --- a/mall-search/pom.xml +++ b/mall-search/pom.xml @@ -5,17 +5,16 @@ com.macro.mall mall-search - 0.0.1-SNAPSHOT + 1.0-SNAPSHOT jar mall-search mall-search project for mall - org.springframework.boot - spring-boot-starter-parent - 2.1.3.RELEASE - + com.macro.mall + mall + 1.0-SNAPSHOT @@ -35,38 +34,6 @@ org.springframework.boot spring-boot-starter-data-elasticsearch - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-test - test - - - - com.github.pagehelper - pagehelper-spring-boot-starter - 1.2.10 - - - - io.springfox - springfox-swagger2 - 2.6.1 - - - io.springfox - springfox-swagger-ui - 2.6.1 - - - - com.alibaba - druid-spring-boot-starter - 1.1.10 - diff --git a/mall-search/src/main/java/com/macro/mall/search/controller/EsProductController.java b/mall-search/src/main/java/com/macro/mall/search/controller/EsProductController.java index a28cd26..f5ac575 100644 --- a/mall-search/src/main/java/com/macro/mall/search/controller/EsProductController.java +++ b/mall-search/src/main/java/com/macro/mall/search/controller/EsProductController.java @@ -1,6 +1,7 @@ package com.macro.mall.search.controller; -import com.macro.mall.search.domain.CommonResult; +import com.macro.mall.common.api.CommonPage; +import com.macro.mall.common.api.CommonResult; import com.macro.mall.search.domain.EsProduct; import com.macro.mall.search.domain.EsProductRelatedInfo; import com.macro.mall.search.service.EsProductService; @@ -28,47 +29,47 @@ public class EsProductController { @ApiOperation(value = "导入所有数据库中商品到ES") @RequestMapping(value = "/importAll", method = RequestMethod.POST) @ResponseBody - public Object importAllList() { + public CommonResult importAllList() { int count = esProductService.importAll(); - return new CommonResult().success(count); + return CommonResult.success(count); } @ApiOperation(value = "根据id删除商品") @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET) @ResponseBody - public Object delete(@PathVariable Long id) { + public CommonResult delete(@PathVariable Long id) { esProductService.delete(id); - return new CommonResult().success(null); + return CommonResult.success(null); } @ApiOperation(value = "根据id批量删除商品") @RequestMapping(value = "/delete/batch", method = RequestMethod.POST) @ResponseBody - public Object delete(@RequestParam("ids") List ids) { + public CommonResult delete(@RequestParam("ids") List ids) { esProductService.delete(ids); - return new CommonResult().success(null); + return CommonResult.success(null); } @ApiOperation(value = "根据id创建商品") @RequestMapping(value = "/create/{id}", method = RequestMethod.POST) @ResponseBody - public Object create(@PathVariable Long id) { + public CommonResult create(@PathVariable Long id) { EsProduct esProduct = esProductService.create(id); if (esProduct != null) { - return new CommonResult().success(esProduct); + return CommonResult.success(esProduct); } else { - return new CommonResult().failed(); + return CommonResult.failed(); } } @ApiOperation(value = "简单搜索") @RequestMapping(value = "/search/simple", method = RequestMethod.GET) @ResponseBody - public Object search(@RequestParam(required = false) String keyword, - @RequestParam(required = false, defaultValue = "0") Integer pageNum, - @RequestParam(required = false, defaultValue = "5") Integer pageSize) { + public CommonResult> search(@RequestParam(required = false) String keyword, + @RequestParam(required = false, defaultValue = "0") Integer pageNum, + @RequestParam(required = false, defaultValue = "5") Integer pageSize) { Page esProductPage = esProductService.search(keyword, pageNum, pageSize); - return new CommonResult().pageSuccess(esProductPage); + return CommonResult.success(CommonPage.restPage(esProductPage)); } @ApiOperation(value = "综合搜索、筛选、排序") @@ -76,31 +77,31 @@ public class EsProductController { defaultValue = "0", allowableValues = "0,1,2,3,4", paramType = "query", dataType = "integer") @RequestMapping(value = "/search", method = RequestMethod.GET) @ResponseBody - public Object search(@RequestParam(required = false) String keyword, - @RequestParam(required = false) Long brandId, - @RequestParam(required = false) Long productCategoryId, - @RequestParam(required = false, defaultValue = "0") Integer pageNum, - @RequestParam(required = false, defaultValue = "5") Integer pageSize, - @RequestParam(required = false, defaultValue = "0") Integer sort) { + public CommonResult> search(@RequestParam(required = false) String keyword, + @RequestParam(required = false) Long brandId, + @RequestParam(required = false) Long productCategoryId, + @RequestParam(required = false, defaultValue = "0") Integer pageNum, + @RequestParam(required = false, defaultValue = "5") Integer pageSize, + @RequestParam(required = false, defaultValue = "0") Integer sort) { Page esProductPage = esProductService.search(keyword, brandId, productCategoryId, pageNum, pageSize, sort); - return new CommonResult().pageSuccess(esProductPage); + return CommonResult.success(CommonPage.restPage(esProductPage)); } @ApiOperation(value = "根据商品id推荐商品") - @RequestMapping(value = "/recommend/{id}",method = RequestMethod.GET) + @RequestMapping(value = "/recommend/{id}", method = RequestMethod.GET) @ResponseBody - public Object recommend(@PathVariable Long id, - @RequestParam(required = false, defaultValue = "0") Integer pageNum, - @RequestParam(required = false, defaultValue = "5") Integer pageSize){ + public CommonResult> recommend(@PathVariable Long id, + @RequestParam(required = false, defaultValue = "0") Integer pageNum, + @RequestParam(required = false, defaultValue = "5") Integer pageSize) { Page esProductPage = esProductService.recommend(id, pageNum, pageSize); - return new CommonResult().pageSuccess(esProductPage); + return CommonResult.success(CommonPage.restPage(esProductPage)); } @ApiOperation(value = "获取搜索的相关品牌、分类及筛选属性") - @RequestMapping(value = "/search/relate",method = RequestMethod.GET) + @RequestMapping(value = "/search/relate", method = RequestMethod.GET) @ResponseBody - public Object searchRelatedInfo(@RequestParam(required = false) String keyword){ + public CommonResult searchRelatedInfo(@RequestParam(required = false) String keyword) { EsProductRelatedInfo productRelatedInfo = esProductService.searchRelatedInfo(keyword); - return new CommonResult().success(productRelatedInfo); + return CommonResult.success(productRelatedInfo); } } diff --git a/mall-search/src/main/java/com/macro/mall/search/domain/CommonResult.java b/mall-search/src/main/java/com/macro/mall/search/domain/CommonResult.java deleted file mode 100644 index 88a366c..0000000 --- a/mall-search/src/main/java/com/macro/mall/search/domain/CommonResult.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.macro.mall.search.domain; - -import org.springframework.data.domain.Page; - -import java.util.HashMap; -import java.util.Map; - -/** - * 通用返回对象 - * Created by macro on 2018/4/26. - */ -public class CommonResult { - //操作成功 - public static final int SUCCESS = 200; - //操作失败 - public static final int FAILED = 500; - private int code; - private String message; - private Object data; - - /** - * 普通成功返回 - * - * @param data 获取的数据 - */ - public CommonResult success(Object data) { - this.code = SUCCESS; - this.message = "操作成功"; - this.data = data; - return this; - } - - /** - * 返回分页成功数据 - */ - public CommonResult pageSuccess(Page pageInfo) { - Map result = new HashMap<>(); - result.put("pageSize", pageInfo.getSize()); - result.put("totalPage", pageInfo.getTotalPages()); - result.put("total", pageInfo.getTotalElements()); - result.put("pageNum", pageInfo.getNumber()); - result.put("list", pageInfo.getContent()); - this.code = SUCCESS; - this.message = "操作成功"; - this.data = result; - return this; - } - - /** - * 普通失败提示信息 - */ - public CommonResult failed() { - this.code = FAILED; - this.message = "操作失败"; - return this; - } - - 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 Object getData() { - return data; - } - - public void setData(Object data) { - this.data = data; - } -} diff --git a/pom.xml b/pom.xml index dd75b03..0c85c0b 100644 --- a/pom.xml +++ b/pom.xml @@ -10,11 +10,50 @@ pom + mall-common mall-mbg + mall-demo mall-admin mall-search mall-portal - mall-demo + + org.springframework.boot + spring-boot-starter-parent + 2.1.3.RELEASE + + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-aop + + + org.springframework.boot + spring-boot-starter-test + test + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.2.10 + + + + com.alibaba + druid-spring-boot-starter + 1.1.10 + + + \ No newline at end of file