项目结构改造
This commit is contained in:
parent
cdd332a667
commit
b5800856fb
@ -4,19 +4,12 @@
|
||||
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall-admin</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>mall-admin</name>
|
||||
<description>mall-admin project for mall</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
@ -24,50 +17,22 @@
|
||||
<skipTests>true</skipTests>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall-mbg</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--MyBatis分页插件-->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.10</version>
|
||||
</dependency>
|
||||
<!--Swagger-UI API文档生产工具-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
<!--JWT(Json Web Token)登录支持-->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
@ -86,12 +51,6 @@
|
||||
<artifactId>logstash-logback-encoder</artifactId>
|
||||
<version>4.8</version>
|
||||
</dependency>
|
||||
<!--集成druid连接池-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.1.10</version>
|
||||
</dependency>
|
||||
<!--lombok依赖-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
39
mall-common/pom.xml
Normal file
39
mall-common/pom.xml
Normal file
@ -0,0 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>mall-common</name>
|
||||
<description>mall-common project for mall</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper</artifactId>
|
||||
<version>5.1.8</version>
|
||||
</dependency>
|
||||
<!--Swagger-UI API文档生产工具-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.7.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.data</groupId>
|
||||
<artifactId>spring-data-commons</artifactId>
|
||||
<version>2.1.5.RELEASE</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -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<T> {
|
||||
private List<T> list;
|
||||
|
||||
/**
|
||||
* 将PageHelper分页后的list转为分页信息
|
||||
* 将PageHelper分页后的list转为分页信息
|
||||
*/
|
||||
public static <T> CommonPage<T> restPage(List<T> list) {
|
||||
CommonPage<T> result = new CommonPage<>();
|
||||
PageInfo<T> pageInfo = new PageInfo<>(list);
|
||||
CommonPage<T> result = new CommonPage<T>();
|
||||
PageInfo<T> pageInfo = new PageInfo<T>(list);
|
||||
result.setTotalPage(pageInfo.getTotal() / pageInfo.getPageSize());
|
||||
result.setPageNum(pageInfo.getPageNum());
|
||||
result.setPageSize(pageInfo.getPageSize());
|
||||
@ -26,6 +27,18 @@ public class CommonPage<T> {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将SpringData分页后的list转为分页信息
|
||||
*/
|
||||
public static <T> CommonPage<T> restPage(Page<T> pageInfo) {
|
||||
CommonPage<T> result = new CommonPage<T>();
|
||||
result.setTotalPage((long) pageInfo.getTotalPages());
|
||||
result.setPageNum(pageInfo.getNumber());
|
||||
result.setPageSize(pageInfo.getSize());
|
||||
result.setList(pageInfo.getContent());
|
||||
return result;
|
||||
}
|
||||
|
||||
public Integer getPageNum() {
|
||||
return pageNum;
|
||||
}
|
@ -0,0 +1,118 @@
|
||||
package com.macro.mall.common.api;
|
||||
|
||||
/**
|
||||
* 通用返回对象
|
||||
*/
|
||||
public class CommonResult<T> {
|
||||
private long 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(ResultCode.SUCCESS.getCode());
|
||||
result.setMessage(ResultCode.SUCCESS.getMsg());
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通成功返回
|
||||
*
|
||||
* @param data 获取的数据
|
||||
*/
|
||||
public static <T> CommonResult<T> success(T data,String message) {
|
||||
CommonResult<T> result = new CommonResult<T>();
|
||||
result.setCode(ResultCode.SUCCESS.getCode());
|
||||
result.setMessage(message);
|
||||
result.setData(data);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过错误码对象构造返回结果
|
||||
*/
|
||||
public static <T> CommonResult<T> failed(IErrorCode errorCode) {
|
||||
CommonResult<T> result = new CommonResult<T>();
|
||||
result.setCode(errorCode.getCode());
|
||||
result.setMessage(errorCode.getMsg());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通失败提示信息
|
||||
*/
|
||||
public static <T> CommonResult<T> failed(String message) {
|
||||
CommonResult<T> result = new CommonResult<T>();
|
||||
result.setCode(ResultCode.FAILED.getCode());
|
||||
result.setMessage(message);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通操作失败
|
||||
*/
|
||||
public static <T> CommonResult<T> failed() {
|
||||
return failed(ResultCode.FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数验证失败使用
|
||||
*/
|
||||
public static <T> CommonResult<T> validateFailed() {
|
||||
return failed(ResultCode.VALIDATE_FAILED);
|
||||
}
|
||||
|
||||
/**
|
||||
* 参数验证失败使用
|
||||
*/
|
||||
public static <T> CommonResult<T> validateFailed(String message) {
|
||||
CommonResult<T> result = new CommonResult<T>();
|
||||
result.setCode(ResultCode.FAILED.getCode());
|
||||
result.setMessage(message);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户没有登录
|
||||
*/
|
||||
public static <T> CommonResult<T> unauthorized() {
|
||||
return failed(ResultCode.UNAUTHORIZED);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户没有相应权限
|
||||
*/
|
||||
public static <T> CommonResult<T> 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;
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -5,35 +5,28 @@
|
||||
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall-demo</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>mall-demo</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall-mbg</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-thymeleaf</artifactId>
|
||||
@ -42,36 +35,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--MyBatis分页插件-->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.10</version>
|
||||
</dependency>
|
||||
<!--Swagger-UI API文档生产工具-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
<!--logstash日志收集插件-->
|
||||
<dependency>
|
||||
<groupId>net.logstash.logback</groupId>
|
||||
|
@ -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.*;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -13,6 +13,11 @@
|
||||
<description>mall-mbg project for mall</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall-common</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<!-- MyBatis 生成器 -->
|
||||
<dependency>
|
||||
<groupId>org.mybatis.generator</groupId>
|
||||
|
@ -5,19 +5,12 @@
|
||||
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall-portal</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>mall-portal</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
@ -25,6 +18,13 @@
|
||||
<skipTests>true</skipTests>
|
||||
</properties>
|
||||
|
||||
<parent>
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.macro.mall</groupId>
|
||||
@ -35,47 +35,15 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-mongodb</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--MyBatis分页插件-->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.10</version>
|
||||
</dependency>
|
||||
<!--Swagger-UI API文档生产工具-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
<!--redis依赖配置-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
<!--集成druid连接池-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.1.10</version>
|
||||
</dependency>
|
||||
<!--集成消息队列-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -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;
|
||||
|
@ -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<HomeContentResult> 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<List<PmsProduct>> recommendProductList(@RequestParam(value = "pageSize", defaultValue = "4") Integer pageSize,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
List<PmsProduct> 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<List<PmsProductCategory>> getProductCateList(@PathVariable Long parentId) {
|
||||
List<PmsProductCategory> 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<List<CmsSubject>> getSubjectList(@RequestParam(required = false) Long cateId,
|
||||
@RequestParam(value = "pageSize", defaultValue = "4") Integer pageSize,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
List<CmsSubject> subjectList = homeService.getSubjectList(cateId,pageSize,pageNum);
|
||||
return new CommonResult().success(subjectList);
|
||||
return CommonResult.success(subjectList);
|
||||
}
|
||||
}
|
||||
|
@ -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<MemberBrandAttention>> list(@PathVariable Long memberId) {
|
||||
List<MemberBrandAttention> memberBrandAttentionList = memberAttentionService.list(memberId);
|
||||
return new CommonResult().success(memberBrandAttentionList);
|
||||
return CommonResult.success(memberBrandAttentionList);
|
||||
}
|
||||
}
|
||||
|
@ -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<List<MemberProductCollection>> listProduct(@PathVariable Long memberId) {
|
||||
List<MemberProductCollection> memberProductCollectionList = memberCollectionService.listProduct(memberId);
|
||||
return new CommonResult().success(memberProductCollectionList);
|
||||
return CommonResult.success(memberProductCollectionList);
|
||||
}
|
||||
}
|
||||
|
@ -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<String> 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<String> 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<MemberReadHistory>> list(Long memberId) {
|
||||
List<MemberReadHistory> memberReadHistoryList = memberReadHistoryService.list(memberId);
|
||||
return new CommonResult().success(memberReadHistoryList);
|
||||
return CommonResult.success(memberReadHistoryList);
|
||||
}
|
||||
}
|
||||
|
@ -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<OmsCartItem>> list() {
|
||||
List<OmsCartItem> 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<List<CartPromotionItem>> listPromotion() {
|
||||
List<CartPromotionItem> 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<CartProduct> 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<Long> ids) {
|
||||
int count = cartItemService.delete(memberService.getCurrentMember().getId(),ids);
|
||||
public CommonResult delete(@RequestParam("ids") List<Long> 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();
|
||||
}
|
||||
}
|
||||
|
@ -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<ConfirmOrderResult> 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);
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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<SmsCouponHistory>> list(@RequestParam(value = "useStatus", required = false) Integer useStatus) {
|
||||
List<SmsCouponHistory> 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<List<SmsCouponHistoryDetail>> listCart(@PathVariable Integer type) {
|
||||
List<CartPromotionItem> cartPromotionItemList = cartItemService.listPromotion(memberService.getCurrentMember().getId());
|
||||
List<SmsCouponHistoryDetail> couponHistoryList = memberCouponService.listCart(cartPromotionItemList, type);
|
||||
return new CommonResult().success(couponHistoryList);
|
||||
return CommonResult.success(couponHistoryList);
|
||||
}
|
||||
}
|
||||
|
@ -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<UmsMemberReceiveAddress>> list() {
|
||||
List<UmsMemberReceiveAddress> 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<UmsMemberReceiveAddress> getItem(@PathVariable Long id) {
|
||||
UmsMemberReceiveAddress address = memberReceiveAddressService.getItem(id);
|
||||
return new CommonResult().success(address);
|
||||
return CommonResult.success(address);
|
||||
}
|
||||
}
|
||||
|
@ -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<String, Object> 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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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<String,Object> result = new HashMap<>();
|
||||
result.put("order",order);
|
||||
result.put("orderItemList",orderItemList);
|
||||
return new CommonResult().success("下单成功", result);
|
||||
deleteCartItemList(cartPromotionItemList, currentMember);
|
||||
Map<String, Object> 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<OmsOrderDetail> timeOutOrders = portalOrderDao.getTimeOutOrders(orderSetting.getNormalOrderOvertime());
|
||||
if(CollectionUtils.isEmpty(timeOutOrders)){
|
||||
return new CommonResult().failed("暂无超时订单");
|
||||
if (CollectionUtils.isEmpty(timeOutOrders)) {
|
||||
return CommonResult.failed("暂无超时订单");
|
||||
}
|
||||
//修改订单状态为交易取消
|
||||
List<Long> 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<OmsOrder> 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<OmsOrderItem> 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<OmsOrderItem> 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<OmsOrderItem> 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<SmsCouponHistory> 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;
|
||||
|
@ -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,"领取成功");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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<UmsMember> 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<UmsMember> 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
|
||||
|
@ -5,17 +5,16 @@
|
||||
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall-search</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>mall-search</name>
|
||||
<description>mall-search project for mall</description>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
<groupId>com.macro.mall</groupId>
|
||||
<artifactId>mall</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
@ -35,38 +34,6 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--MyBatis分页插件-->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.10</version>
|
||||
</dependency>
|
||||
<!--Swagger-UI API文档生产工具-->
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger2</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-swagger-ui</artifactId>
|
||||
<version>2.6.1</version>
|
||||
</dependency>
|
||||
<!--集成druid连接池-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.1.10</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -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<Integer> 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<Object> 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<Long> ids) {
|
||||
public CommonResult<Object> delete(@RequestParam("ids") List<Long> 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<EsProduct> 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<CommonPage<EsProduct>> search(@RequestParam(required = false) String keyword,
|
||||
@RequestParam(required = false, defaultValue = "0") Integer pageNum,
|
||||
@RequestParam(required = false, defaultValue = "5") Integer pageSize) {
|
||||
Page<EsProduct> 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<CommonPage<EsProduct>> 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<EsProduct> 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<CommonPage<EsProduct>> recommend(@PathVariable Long id,
|
||||
@RequestParam(required = false, defaultValue = "0") Integer pageNum,
|
||||
@RequestParam(required = false, defaultValue = "5") Integer pageSize) {
|
||||
Page<EsProduct> 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<EsProductRelatedInfo> searchRelatedInfo(@RequestParam(required = false) String keyword) {
|
||||
EsProductRelatedInfo productRelatedInfo = esProductService.searchRelatedInfo(keyword);
|
||||
return new CommonResult().success(productRelatedInfo);
|
||||
return CommonResult.success(productRelatedInfo);
|
||||
}
|
||||
}
|
||||
|
@ -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<String, Object> 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;
|
||||
}
|
||||
}
|
41
pom.xml
41
pom.xml
@ -10,11 +10,50 @@
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<modules>
|
||||
<module>mall-common</module>
|
||||
<module>mall-mbg</module>
|
||||
<module>mall-demo</module>
|
||||
<module>mall-admin</module>
|
||||
<module>mall-search</module>
|
||||
<module>mall-portal</module>
|
||||
<module>mall-demo</module>
|
||||
</modules>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.1.3.RELEASE</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<!--MyBatis分页插件-->
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.2.10</version>
|
||||
</dependency>
|
||||
<!--集成druid连接池-->
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid-spring-boot-starter</artifactId>
|
||||
<version>1.1.10</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
Loading…
x
Reference in New Issue
Block a user