diff --git a/.idea/encodings.xml b/.idea/encodings.xml index 2b1474b..0665a46 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -2,8 +2,13 @@ + + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml index 67e1e61..307f0b0 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -5,8 +5,15 @@ + \ No newline at end of file diff --git a/bwie-auth/src/main/java/com/bwie/AuthApp.java b/bwie-auth/src/main/java/com/bwie/AuthApp.java new file mode 100644 index 0000000..d4707b2 --- /dev/null +++ b/bwie-auth/src/main/java/com/bwie/AuthApp.java @@ -0,0 +1,28 @@ +package com.bwie; + +import com.bwie.common.handler.GlobalExceptionHandle; +import com.bwie.common.redis.RedisCache; + +import com.bwie.common.remote.system.RemoteUserService; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.context.annotation.Import; + +@SpringBootApplication(exclude = DataSourceAutoConfiguration.class) +@EnableDiscoveryClient +@EnableFeignClients("com.bwie.**") +@Import({GlobalExceptionHandle.class, RedisCache.class, RemoteUserService.class}) +public class AuthApp { + + public static void main(String[] args) { + + SpringApplication.run(AuthApp.class,args); + + } + +} + + diff --git a/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java b/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java new file mode 100644 index 0000000..1c1754f --- /dev/null +++ b/bwie-auth/src/main/java/com/bwie/auth/controller/AuthController.java @@ -0,0 +1,92 @@ +package com.bwie.auth.controller; + +import com.bwie.auth.service.AuthService; +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.LoginRequest; +import com.bwie.common.domain.request.PhoneLoginRequest; +import com.bwie.common.domain.request.UserReq; +import com.bwie.common.domain.request.UserResponse; +import com.bwie.common.result.Result; +import org.springframework.web.bind.annotation.*; + + +@RestController +public class AuthController { + + + private final AuthService authService; + + public AuthController(AuthService authService) { + this.authService = authService; + } + + /** + * 登录 + * @param loginRequest + * @return + */ + @PostMapping("/login") + public Result login(@RequestBody LoginRequest loginRequest){ + return Result.success( + authService.login(loginRequest) + ); + } + + /** + * 注册 + * @param userReq + * @return + */ + @PostMapping("/reg") + public Result regUser(@RequestBody UserReq userReq){ + return authService.reg(userReq); + } + + /** + * 发送验证码 + * @param userPhone + * @return + */ + @GetMapping("/sendCode/{userPhone}") + public Result sencCode(@PathVariable("userPhone") String userPhone){ + return authService.sendCode(userPhone); + } + + /** + * 手机号登录 + * @param userPhone + * @return + */ + @PostMapping("/sendCode/{userPhone}") + public Result sendCode(@PathVariable String userPhone){ + + Result result = authService.sencCode(userPhone); + + return result; + + } + + /** + * 获取验证码 + * @param phoneLoginRequest + * @return + */ + @PostMapping("/phoneLogin") + public Result phoneLogin1(@RequestBody PhoneLoginRequest phoneLoginRequest){ + Result result = authService.phoneLogin(phoneLoginRequest); + + return Result.success(result); + } + + /** + * 获取用户信息 + * @return + */ + @GetMapping("/info") + public Result getInfo(){ + return Result.success( + authService.getInfo() + ); + } + +} diff --git a/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java b/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java new file mode 100644 index 0000000..b283bca --- /dev/null +++ b/bwie-auth/src/main/java/com/bwie/auth/service/AuthService.java @@ -0,0 +1,25 @@ +package com.bwie.auth.service; + +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.LoginRequest; +import com.bwie.common.domain.request.PhoneLoginRequest; +import com.bwie.common.domain.request.UserReq; +import com.bwie.common.domain.request.UserResponse; +import com.bwie.common.result.Result; + +public interface AuthService { + + + + Result reg(UserReq userReq); + + Result sendCode(String userPhone); + + UserResponse login(LoginRequest loginRequest); + + User getInfo(); + + Result sencCode(String userPhone); + + Result phoneLogin(PhoneLoginRequest phoneLoginRequest); +} diff --git a/bwie-auth/src/main/java/com/bwie/auth/service/impl/AuthServiceImpl.java b/bwie-auth/src/main/java/com/bwie/auth/service/impl/AuthServiceImpl.java new file mode 100644 index 0000000..bb6d414 --- /dev/null +++ b/bwie-auth/src/main/java/com/bwie/auth/service/impl/AuthServiceImpl.java @@ -0,0 +1,159 @@ +package com.bwie.auth.service.impl; + +import cn.hutool.core.lang.Assert; +import cn.hutool.core.util.RandomUtil; +import cn.hutool.crypto.SecureUtil; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.bwie.auth.service.AuthService; +import com.bwie.common.constant.JwtConstants; +import com.bwie.common.constant.TokenConstants; + +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.LoginRequest; + +import com.bwie.common.domain.request.PhoneLoginRequest; +import com.bwie.common.domain.request.UserReq; +import com.bwie.common.domain.request.UserResponse; +import com.bwie.common.redis.RedisCache; +import com.bwie.common.remote.system.RemoteUserService; +import com.bwie.common.result.BizException; +import com.bwie.common.result.Result; +import com.bwie.common.utils.JwtUtils; +import com.bwie.common.utils.SecurityUtils; +import com.bwie.common.utils.StringUtils; +import io.jsonwebtoken.Claims; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.redis.core.StringRedisTemplate; +import org.springframework.stereotype.Service; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.UUID; +import java.util.concurrent.TimeUnit; + +@Service +public class AuthServiceImpl implements AuthService { + + @Autowired + private RemoteUserService remoteLoginService; + + @Autowired + private StringRedisTemplate redisTemplate; + + @Autowired + private RedisCache redisCache; + + @Autowired + private HttpServletRequest request; + + + @Override + public UserResponse login(LoginRequest loginRequest) { + + Assert.isTrue( + !StringUtils.isAnyBlank(loginRequest.getUserPwd(), + loginRequest.getUserName()),"账号或密码不能为空" + ); + Result result = remoteLoginService.login(loginRequest); + User user = result.getData(); + Assert.notNull(user,"该账号不是系统用户"); + + HashMap map = new HashMap<>(); + String userKey = UUID.randomUUID().toString().replaceAll("-", ""); + map.put(JwtConstants.USER_KEY,userKey); + map.put(JwtConstants.DETAILS_USERNAME,user.getUserName()); + map.put(JwtConstants.DETAILS_USER_ID,user.getUserId()); + String token = JwtUtils.createToken(map); + redisCache.setCacheObject( + TokenConstants.LOGIN_TOKEN_KEY+userKey, + JSON.toJSONString(user), + TokenConstants.EXPIRATION, + TimeUnit.SECONDS + ); + return UserResponse.builder() + .token(token) + .expired(TokenConstants.EXPIRATION) + .build(); + } + + @Override + public Result reg(UserReq userReq) { + String password = SecureUtil.md5(userReq.getUserPwd() + "|" +""); + Result result = remoteLoginService.register( + User.builder() + .userName(userReq.getUserName()) + .userPwd(password) + .userPhone(userReq.getUserPhone()) + .userRole(userReq.getUserRole()) + .build() + ); + return result; + } + + @Override + public Result sendCode(String userPhone) { + Result result = remoteLoginService.findByPhone(userPhone); + User user = result.getData(); + if(null == user){ + throw new BizException(408,"请先注册手机号"); + } + String code = RandomUtil.randomNumbers(4); + redisCache.setCacheObject("Send_sms_"+userPhone,code); + + return Result.success("验证码为:"+code,"发送成功"); + } + + + @Override + public Result sencCode(String userPhone) { + Result result = remoteLoginService.phoneLogin(userPhone); + if(StringUtils.isNull(result.getData())){ + return Result.error("手机号不存在"); + } + String code = RandomUtil.randomNumbers(4); + System.out.println("验证码为:"+code); + redisTemplate.opsForValue().set(userPhone,code,5,TimeUnit.MINUTES); + + return result; + } + + + @Override + public Result phoneLogin(PhoneLoginRequest phoneLoginRequest) { + Result result = remoteLoginService.phoneLogin(phoneLoginRequest.getUserPhone()); + User user = result.getData(); + if(null==user){ + return Result.error("手机号不存在"); + } + if(!redisTemplate.hasKey(phoneLoginRequest.getUserPhone())){ + return Result.error("验证码过期"); + } + String code = redisTemplate.opsForValue().get(phoneLoginRequest.getUserPhone()); + if(!phoneLoginRequest.getUserCode().equals(code)){ + return Result.error("验证码错误"); + } + HashMap map = new HashMap<>(); + String userKey = UUID.randomUUID().toString().replaceAll("-",""); + map.put(JwtConstants.DETAILS_USERNAME,user.getUserName()); + map.put(JwtConstants.DETAILS_USER_ID,user.getUserId()); + map.put(JwtConstants.USER_KEY,userKey); + String token = JwtUtils.createToken(map); + redisCache.setCacheObject(TokenConstants.LOGIN_TOKEN_KEY, user, TokenConstants.EXPIRATION, TimeUnit.HOURS); + + UserResponse userResponse = new UserResponse(); + userResponse.setToken(token); + userResponse.setExpired(TokenConstants.EXPIRATION); + return Result.success(userResponse,"登陆成功"); + } + + @Override + public User getInfo() { + String token = request.getHeader(TokenConstants.TOKEN); + Claims claims = JwtUtils.parseToken(token); + String userKey = JwtUtils.getUserKey(claims); + String cacheObject = redisCache.getCacheObject(TokenConstants.LOGIN_TOKEN_KEY + userKey); + User user = JSONObject.parseObject(cacheObject, User.class); + return user; + } +} diff --git a/bwie-common/pom.xml b/bwie-common/pom.xml index 488d5b8..5b095e4 100644 --- a/bwie-common/pom.xml +++ b/bwie-common/pom.xml @@ -110,5 +110,9 @@ fastjson2 2.0.42 + + org.springframework + spring-context + diff --git a/bwie-common/src/main/java/com/bwie/common/constant/ServerNameConstants.java b/bwie-common/src/main/java/com/bwie/common/constant/ServerNameConstants.java index a555782..b5eeb3f 100644 --- a/bwie-common/src/main/java/com/bwie/common/constant/ServerNameConstants.java +++ b/bwie-common/src/main/java/com/bwie/common/constant/ServerNameConstants.java @@ -2,5 +2,5 @@ package com.bwie.common.constant; public class ServerNameConstants { - public final static String SYSTEM_NAME="bwie-system"; + public final static String SYSTEM_NAME="bwie-User"; } diff --git a/bwie-common/src/main/java/com/bwie/common/domain/BuyOrder.java b/bwie-common/src/main/java/com/bwie/common/domain/BuyOrder.java new file mode 100644 index 0000000..0a885af --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/BuyOrder.java @@ -0,0 +1,37 @@ +package com.bwie.common.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 订单表 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("order") + +public class BuyOrder { + private Long orderId; + private Long userId; + private String userPhone; + private Integer orderState; + private Integer orderInventory; + private String orderName; + private String orderNumber; + private Long attrId; + private Long addrId; + private BigDecimal orderPrice; + private Date createTime; + private Date updateTime; + private Integer isDelete; + private String orderAddr; + +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/GoodAttr.java b/bwie-common/src/main/java/com/bwie/common/domain/GoodAttr.java new file mode 100644 index 0000000..1c8b71a --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/GoodAttr.java @@ -0,0 +1,40 @@ +package com.bwie.common.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + *商品的属性 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("goods_attr") +public class GoodAttr { + + @TableId(value = "id",type = IdType.AUTO) + private Long id;//属性ID + @TableField("name") + private String name;//属性名称 + @TableField("search_type") + private Integer searchType;//是否需要检索(0.不需要,1.需要) + @TableField("icon") + private String icon;//属性图标 + @TableField("value_select") + private String valueSelect;//可选值链表(用逗号分隔) + @TableField("type") + private Integer type;//属性类型[0-销售属性,1-基本属性,2-既是销售属性又是基本属性] + @TableField("enable") + private Integer enable;//启用状态[0 - 禁用,1 - 启用] + @TableField("show_desc") + private Integer showDesc;//快速展示【是否展示在介绍上;0-否 1-是】,在sku中仍然可以调整 + @TableField("category_id") + private Long categoryId;//所属分类 +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/GoodSku.java b/bwie-common/src/main/java/com/bwie/common/domain/GoodSku.java new file mode 100644 index 0000000..911f72b --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/GoodSku.java @@ -0,0 +1,43 @@ +package com.bwie.common.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * 商品的sku + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("good_sku") +public class GoodSku { + + @TableId(value = "id",type = IdType.AUTO) + private Long id;//正常的ID + @TableField("spu_id") + private Long spuId;//spuId + @TableField("name") + private String name;//名称 + @TableField("category_id") + private Long categoryId;//类型ID + @TableField("default_image") + private String defaultImage;//图片 + @TableField("title") + private String title;//标题 + @TableField("subtitle") + private String subTitle;//副标题 + @TableField("price") + private BigDecimal price; + @TableField("weight") + private Integer weight; + +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/GoodSpu.java b/bwie-common/src/main/java/com/bwie/common/domain/GoodSpu.java new file mode 100644 index 0000000..86ff205 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/GoodSpu.java @@ -0,0 +1,51 @@ +package com.bwie.common.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * 商品的spu + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("goods_spu") +public class GoodSpu { + + @TableId(value = "id",type = IdType.AUTO) + private Long id;//物品ID + @TableField("name") + private String name;//物品名称 + @TableField("good_sales") + private Integer goodSales;//物品销量 + @TableField("good_inventory") + private Integer goodInventory;//物品库存 + @TableField("category_id") + private Long categoryId;//物品类型ID + @TableField("publish_status") + private Integer publishStatus;//上架状态(0.下架,1.上架) + @TableField("keywords") + private String keyWords;//关键字 + @TableField("good_brief") + private String goodBrief;//物品简介 + @TableField("good_unit") + private String goodUnit;//物品单位 + @TableField("good_freight") + private Integer goodFreight;//运费模版 + @TableField("create_time") + private Date createTime;//创建时间字段 + @TableField("update_time") + private Date updateTime;//修改时间字段 + @TableField("is_delete") + private Integer isDelete;//逻辑删除字段 + +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/GoodsCateGory.java b/bwie-common/src/main/java/com/bwie/common/domain/GoodsCateGory.java new file mode 100644 index 0000000..ae98862 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/GoodsCateGory.java @@ -0,0 +1,30 @@ +package com.bwie.common.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品的类型 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("goods_category") +public class GoodsCateGory { + + @TableId(value = "id",type = IdType.AUTO) + private Long id;//正常的Id + @TableField("name") + private String name;//名称 + @TableField("parent_id") + private Long parentId;//父类ID + @TableField("status") + private Long status;//是否显示(0.不显示,1.显示) +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/GoodsSkuAttrValue.java b/bwie-common/src/main/java/com/bwie/common/domain/GoodsSkuAttrValue.java new file mode 100644 index 0000000..c0acf85 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/GoodsSkuAttrValue.java @@ -0,0 +1,31 @@ +package com.bwie.common.domain; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品sku的属性名称 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("goods_sku_attr_value") +public class GoodsSkuAttrValue { + + @TableField("id") + private Long id;//正常主键ID + @TableField("skuId") + private Long skuId;//skuId + @TableField("attrId") + private Long attrId;//属性的ID + @TableField("attrName") + private String attrName;//属性名称 + @TableField("attrValue") + private String attrValue;//属性值 + +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/GoodsSpuAttrValue.java b/bwie-common/src/main/java/com/bwie/common/domain/GoodsSpuAttrValue.java new file mode 100644 index 0000000..2988f8f --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/GoodsSpuAttrValue.java @@ -0,0 +1,33 @@ +package com.bwie.common.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 商品spu的属性名称 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("goods_spu_attr_value") +public class GoodsSpuAttrValue { + + @TableId(value = "id",type = IdType.AUTO) + private Long id;//Id + @TableField("spu_id") + private Long spuId;//商品ID + @TableField("attr_id") + private Long attrId;//属性ID + @TableField("attr_name") + private String attrName;//属性名字 + @TableField("attr_value") + private String attrValue;//属性值 + +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/GoodsSpuImages.java b/bwie-common/src/main/java/com/bwie/common/domain/GoodsSpuImages.java new file mode 100644 index 0000000..43a6a65 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/GoodsSpuImages.java @@ -0,0 +1,26 @@ +package com.bwie.common.domain; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 添加商品的图片及其图片类型 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("goods_spu_images") +public class GoodsSpuImages { + @TableField("id") + private Long id;//正常主键的ID + @TableField("spuId") + private Long spuId;//spuId + @TableField("url") + private String url;//图片的路径 + @TableField("default_status") + private Integer defaultStatus;//(0.封面图,1.轮播图) +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/PaymentEntity.java b/bwie-common/src/main/java/com/bwie/common/domain/PaymentEntity.java new file mode 100644 index 0000000..81a6084 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/PaymentEntity.java @@ -0,0 +1,42 @@ +package com.bwie.common.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 支付明细表 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("trade") +public class PaymentEntity { + + + private Long tradeId; + private String tradeNum; + private String ordersNumber; + private BigDecimal tradeMoney; + private Integer tradeStatus; + private String thirdNum; + private Integer thirdStatus; + private String thirdMessage; + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date backTime; + private String tradeType; + private Integer isDelete; + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date updTime; + private Long userId; + +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/User.java b/bwie-common/src/main/java/com/bwie/common/domain/User.java new file mode 100644 index 0000000..47bde15 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/User.java @@ -0,0 +1,32 @@ +package com.bwie.common.domain; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + *登录表 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +@TableName("user") +public class User { + + + private Long userId;//用户名Id + private String userName;//用户名 + private String userPwd;//密码 + private String userPhone;//手机号 + private Integer userRole;//角色 + private Integer userGrade;//用户等级 + private Date createTime;//创建时间 + private Date updateTime;//修改时间 + private Integer isDelete;//逻辑删除 + +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/request/LoginRequest.java b/bwie-common/src/main/java/com/bwie/common/domain/request/LoginRequest.java new file mode 100644 index 0000000..754a5e6 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/request/LoginRequest.java @@ -0,0 +1,17 @@ +package com.bwie.common.domain.request; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class LoginRequest { + + + private String userName; + private String userPwd; +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/request/PhoneLoginRequest.java b/bwie-common/src/main/java/com/bwie/common/domain/request/PhoneLoginRequest.java new file mode 100644 index 0000000..02ec2f2 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/request/PhoneLoginRequest.java @@ -0,0 +1,16 @@ +package com.bwie.common.domain.request; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class PhoneLoginRequest { + + private String userPhone; + private String userCode; +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/request/UserReq.java b/bwie-common/src/main/java/com/bwie/common/domain/request/UserReq.java new file mode 100644 index 0000000..3beed18 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/request/UserReq.java @@ -0,0 +1,53 @@ +package com.bwie.common.domain.request; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class UserReq { + private String userName; + /* + 密码 + */ + private String userPwd; + /* + 手机号 + */ + private String userPhone; + /* + 用户等级() + */ + private Integer userGrade; + /* + 登陆人身份【0-经纪人 1-用户】 + */ + private Integer userRole; + /* + 入职时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private Date createTime; + /* + 最新修改时间 + */ + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") + private Date updateTime; + /* + 逻辑删除字段 + */ + private Integer isDelete; + + + +} diff --git a/bwie-common/src/main/java/com/bwie/common/domain/request/UserResponse.java b/bwie-common/src/main/java/com/bwie/common/domain/request/UserResponse.java new file mode 100644 index 0000000..9cbc300 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/domain/request/UserResponse.java @@ -0,0 +1,16 @@ +package com.bwie.common.domain.request; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class UserResponse { + + private String token; + private Long expired; +} diff --git a/bwie-common/src/main/java/com/bwie/common/remote/system/RemoteUserService.java b/bwie-common/src/main/java/com/bwie/common/remote/system/RemoteUserService.java index 834c798..03a7c8f 100644 --- a/bwie-common/src/main/java/com/bwie/common/remote/system/RemoteUserService.java +++ b/bwie-common/src/main/java/com/bwie/common/remote/system/RemoteUserService.java @@ -1,11 +1,43 @@ package com.bwie.common.remote.system; import com.bwie.common.constant.ServerNameConstants; +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.LoginRequest; +import com.bwie.common.remote.system.factory.RemoteUserFactory; +import com.bwie.common.result.Result; import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; @FeignClient( - name = ServerNameConstants.SYSTEM_NAME, - fallbackFactory = RemoteUserService.class + name = "bwie-User", + fallbackFactory = RemoteUserFactory.class ) public interface RemoteUserService { + + @PostMapping("/login") + public Result login(@RequestBody LoginRequest loginRequest); + + + @PostMapping("/register") + public Result register(@RequestBody User user); + + + @GetMapping("/findByPhone/{userPhone}") + public Result findByPhone(@PathVariable("userPhone") String userPhone); + + + @PostMapping("/phoneLogin/{userPhone}") + public Result phoneLogin(@PathVariable("userPhone") String userPhone); + + + + + + + + + } diff --git a/bwie-common/src/main/java/com/bwie/common/remote/system/factory/RemoteUserFactory.java b/bwie-common/src/main/java/com/bwie/common/remote/system/factory/RemoteUserFactory.java index 2635713..7cf1029 100644 --- a/bwie-common/src/main/java/com/bwie/common/remote/system/factory/RemoteUserFactory.java +++ b/bwie-common/src/main/java/com/bwie/common/remote/system/factory/RemoteUserFactory.java @@ -1,15 +1,50 @@ package com.bwie.common.remote.system.factory; +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.LoginRequest; import com.bwie.common.remote.system.RemoteUserService; +import com.bwie.common.result.Result; import lombok.extern.log4j.Log4j2; import org.springframework.cloud.openfeign.FallbackFactory; import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; @Component @Log4j2 public class RemoteUserFactory implements FallbackFactory { @Override public RemoteUserService create(Throwable cause) { - return null; + + return new RemoteUserService() { + + @Override + public Result login(@RequestBody LoginRequest loginRequest){ + log.error("用户登录失败:[{}]",cause.getMessage(),cause); + return Result.error(cause.getMessage()); + } + @Override + public Result register(@RequestBody User user){ + log.error("用户登录失败:[{}]",cause.getMessage(),cause); + return Result.error(cause.getMessage()); + } + @Override + public Result findByPhone(@PathVariable("userPhone") String userPhone){ + log.error("手机号登录失败:[{}]",cause.getMessage(),cause); + return Result.error(cause.getMessage()); + } + @Override + public Result phoneLogin(@PathVariable String userPhone){ + log.error("手机号登录失败:[{}]",cause.getMessage(),cause); + return Result.error(cause.getMessage()); + } + + + + + }; + + + } } diff --git a/bwie-common/src/main/java/com/bwie/common/result/BizException.java b/bwie-common/src/main/java/com/bwie/common/result/BizException.java new file mode 100644 index 0000000..2028aa1 --- /dev/null +++ b/bwie-common/src/main/java/com/bwie/common/result/BizException.java @@ -0,0 +1,56 @@ +package com.bwie.common.result; + +/** + * @ClassName + * @Description 描述 + * @Author XuWen.Luo + * @Date + */ + +public class BizException extends RuntimeException { + + private static final long serialVersionUID = 1L; + + private String msg; + private int code = 500; + + public BizException(String msg) { + super(msg); + this.msg = msg; + } + + public BizException(String msg, Throwable e) { + super(msg, e); + this.msg = msg; + } + + public BizException(int code, String msg) { + super(msg); + this.msg = msg; + this.code = code; + } + + public BizException(String msg, int code, Throwable e) { + super(msg, e); + this.msg = msg; + this.code = code; + } + + + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public int getCode() { + return code; + } + + public void setCode(int code) { + this.code = code; + } +} diff --git a/bwie-modules/bwie-xxl/pom.xml b/bwie-modules/bwie-alipay/pom.xml similarity index 65% rename from bwie-modules/bwie-xxl/pom.xml rename to bwie-modules/bwie-alipay/pom.xml index 7b1d590..3c52a51 100644 --- a/bwie-modules/bwie-xxl/pom.xml +++ b/bwie-modules/bwie-alipay/pom.xml @@ -9,14 +9,20 @@ 1.0.0 - bwie-xxl + bwie-alipay - 17 - 17 + 8 + 8 UTF-8 + + + com.alipay.sdk + alipay-sdk-java + 4.39.2.ALL + com.bwie @@ -58,11 +64,26 @@ spring-boot-starter-test test - - com.xuxueli - xxl-job-core - 2.4.0 + org.mybatis + mybatis-spring + 2.1.1 + compile + + + com.bwie + bwie-common + 1.0.0 + + + org.springframework.boot + spring-boot-test + 2.7.18 + + + org.junit.jupiter + junit-jupiter-api + 5.8.2 diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/AlipayApplication.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/AlipayApplication.java new file mode 100644 index 0000000..4e6695c --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/AlipayApplication.java @@ -0,0 +1,16 @@ +package com.bwie.alipay; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableScheduling; + +@SpringBootApplication +@MapperScan("com.bwie.alipay.mapper") +public class AlipayApplication { + public static void main(String[] args) { + SpringApplication.run(AlipayApplication.class); + } +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/config/AlipayConfig.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/config/AlipayConfig.java new file mode 100644 index 0000000..9984529 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/config/AlipayConfig.java @@ -0,0 +1,62 @@ +package com.bwie.alipay.config; +import com.alipay.api.AlipayClient; +import com.alipay.api.AlipayConstants; +import com.alipay.api.DefaultAlipayClient; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +@Component +@Data +@ConfigurationProperties(prefix = "alipay") +public class AlipayConfig { + + /** + * 商户appid + */ + private String appId; + + /** + * 商户PID,卖家支付宝账号ID + */ + private String sellerId; + + /** + * 私钥 pkcs8格式的,rsc中的私钥 + */ + private String privateKey; + + /** + * 支付宝公钥 + */ + private String publicKey; + + /** + * 请求网关地址 + */ + private String serverUrl; + + /** + * 页面跳转同步通知(可以直接返回前端页面、或者通过后端进行跳转) + */ + private String returnUrl; + + /** + * 服务器异步通知 + */ + private String notifyUrl; + + /** + * 获得初始化的AlipayClient + * + * @return + */ + @Bean + public AlipayClient alipayClien() { + // 获得初始化的AlipayClient + return new DefaultAlipayClient(serverUrl, appId, privateKey, + AlipayConstants.FORMAT_JSON, AlipayConstants.CHARSET_UTF8, + publicKey, AlipayConstants.SIGN_TYPE_RSA2); + } +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/controller/AlipayController.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/controller/AlipayController.java new file mode 100644 index 0000000..f8a5caf --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/controller/AlipayController.java @@ -0,0 +1,9 @@ +package com.bwie.alipay.controller; + + +import org.springframework.web.bind.annotation.*; + +@RestController +@RequestMapping("/alipay") +public class AlipayController { +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/controller/AlipayWayController.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/controller/AlipayWayController.java new file mode 100644 index 0000000..63fb1c0 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/controller/AlipayWayController.java @@ -0,0 +1,132 @@ +package com.bwie.alipay.controller; +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayConstants; +import com.alipay.api.internal.util.AlipaySignature; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.bwie.alipay.service.AlimentPayService; +import com.bwie.alipay.service.AlipayWayService; +import com.bwie.alipay.utils.service.AlipayWay; +import com.bwie.alipay.utils.PayServive; +import com.bwie.alipay.vo.Alipay; +import com.bwie.common.domain.BuyOrder; +import com.bwie.common.domain.PaymentEntity; +import com.bwie.common.result.BizException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationContext; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.RestController; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.nio.charset.StandardCharsets; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +@Slf4j +@RestController +public class AlipayWayController { + @Autowired + private AlipayWay alipayWay; + @Autowired + private AlipayWayService alipayWayService;//buyOrder + @Autowired + private AlimentPayService alimentPayService;//PaymentEntity + + @Autowired + private ApplicationContext applicationContext; + @ResponseBody + @GetMapping("/pay") + public String pay(Long buyOrderId,String type) throws AlipayApiException { + BuyOrder buyOrder = alipayWayService.getOne( + new LambdaQueryWrapper().eq(BuyOrder::getOrderId, buyOrderId)); + + + if(buyOrder.getOrderState().equals(3)){ + throw new BizException(500,"不能重复支付!!!!!"); + } + PaymentEntity paymentEntity = PaymentEntity.builder() + .ordersNumber(buyOrder.getOrderNumber()) + .userId(buyOrder.getUserId()) + .tradeMoney(buyOrder.getOrderPrice()) + .backTime(new Date()) + .tradeStatus(1).build(); + //添加到数据库 + alimentPayService.save(paymentEntity); + + + alipayWayService.updateById( + BuyOrder.builder() + .orderId(buyOrder.getOrderId()) + .orderState(2).build() + ); + PayServive bean = (PayServive)applicationContext.getBean(type); + return bean.alipay(buyOrder); + } + + @Resource + private Alipay alipay; + @Transactional + @RequestMapping("/notifyUrl") + public void notifyUrl(HttpServletRequest request, HttpServletResponse response) throws Exception { + + request.setCharacterEncoding("utf-8"); + + HashMap params = new HashMap<>(8); + + Map requestParams = request.getParameterMap(); + + for (Map.Entry stringEntry : requestParams.entrySet()) { + + String[] values = stringEntry.getValue(); + + String valueStr=""; + for (int i = 0; i < values.length; i++) { + valueStr = (i == values.length - 1) ? valueStr + values[i] + : valueStr + values[i] + ","; + } + System.out.println("key="+stringEntry.getKey()+" value="+valueStr); + params.put(stringEntry.getKey(), valueStr); + } + boolean signVerified = AlipaySignature.rsaCheckV1(params,alipay.getAlipayPublicKey(), AlipayConstants.CHARSET_UTF8, AlipayConstants.SIGN_TYPE_RSA2); + if(!signVerified){ + log.error("验签失败!!!!"); + } + String orderSn = new String(params.get("out_trade_no").getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8); + BuyOrder buyOrder = alipayWayService.getOne( + new LambdaQueryWrapper() + .eq(BuyOrder::getOrderNumber, orderSn) + ); + if(buyOrder.getOrderState().equals(3)){ + throw new BizException(500,"已经支付成功,禁止重复回掉"); + } + List paymentEntityList = alimentPayService.list( + new LambdaQueryWrapper() + .eq(PaymentEntity::getOrdersNumber, buyOrder.getOrderNumber()) + ); + paymentEntityList.forEach(c->{ + if(c.getTradeStatus().equals(2)){ + throw new BizException(500,"已经支付成功,禁止重复回掉"); + } + }); + paymentEntityList.forEach(c->{ + if(c.getTradeStatus().equals(1)){ //正在支付 + alimentPayService.updateById( + PaymentEntity.builder() + .tradeId(c.getTradeId()) + .thirdStatus(2).build() + ); //修改为已支付 + } + }); + alipayWayService.updateById( + buyOrder.builder() + .orderId(buyOrder.getOrderId()) + .orderState(3).build() + ); + response.setStatus(HttpServletResponse.SC_OK); + } +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/controller/Test01.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/controller/Test01.java new file mode 100644 index 0000000..b8704f6 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/controller/Test01.java @@ -0,0 +1,15 @@ +package com.bwie.alipay.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class Test01 { + + @GetMapping("/test") + public String aaaa(){ + return "succerr"; + } +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/ListenerPer.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/ListenerPer.java new file mode 100644 index 0000000..18fba29 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/ListenerPer.java @@ -0,0 +1,7 @@ +package com.bwie.alipay.demo; + +public interface ListenerPer { + + + public void test03(String message); +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/MonitorPer.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/MonitorPer.java new file mode 100644 index 0000000..1ea0854 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/MonitorPer.java @@ -0,0 +1,9 @@ +package com.bwie.alipay.demo; + +public interface MonitorPer { + + void test01(ListenerPer listenerPer); + void test02(ListenerPer listenerPer); + + void test04(String message); +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/Newspaper.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/Newspaper.java new file mode 100644 index 0000000..682d0a6 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/Newspaper.java @@ -0,0 +1,21 @@ +package com.bwie.alipay.demo; + +public interface Newspaper { + /** + * 添加订阅者 + * @param subscriber + */ + void addSubscriber(Subscriber subscriber); + + /** + * 移除订阅者 + * @param subscriber + */ + void removeSubscriber(Subscriber subscriber); + + /** + * 通知订阅者 + * @param message + */ + void notifySubscribers(String message); +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/Subscriber.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/Subscriber.java new file mode 100644 index 0000000..cf832c3 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/Subscriber.java @@ -0,0 +1,6 @@ +package com.bwie.alipay.demo; + +public interface Subscriber { + + public void update(String message); +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/controller/TestObserver.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/controller/TestObserver.java new file mode 100644 index 0000000..d5c691e --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/controller/TestObserver.java @@ -0,0 +1,49 @@ +package com.bwie.alipay.demo.controller; +import com.bwie.alipay.demo.MonitorPer; +import com.bwie.alipay.demo.Newspaper; +import com.bwie.alipay.demo.Subscriber; +import com.bwie.alipay.demo.service.ListenerImpl; +import com.bwie.alipay.demo.service.MonitorImpl; +import com.bwie.alipay.demo.service.NewspaperImpl; +import com.bwie.alipay.demo.service.SubscriberImpl; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +public class TestObserver { + @Test + void testObserver() { + Newspaper newspaper = new NewspaperImpl(); + + Subscriber li = new SubscriberImpl("李老头"); + Subscriber wang = new SubscriberImpl("王奶奶"); + //李老头和王奶奶订阅了报纸 + newspaper.addSubscriber(li); + + newspaper.addSubscriber(wang); + //报纸到了,通知订阅者 + newspaper.notifySubscribers("今天的报纸到了!!!"); + //李老头取消订阅了,移除 + newspaper.removeSubscriber(li); + + newspaper.notifySubscribers("明天的报纸还是这个点到!!!"); + } + + @Test + void test04(){ + MonitorPer monitor = new MonitorImpl(); + + ListenerImpl listener = new ListenerImpl("佩奇佩奇"); + ListenerImpl listener1 = new ListenerImpl("狗嘉狗嘉"); + monitor.test01(listener); + monitor.test04("我爱你,爱你爱你"); + monitor.test02(listener); + monitor.test01(listener1); + monitor.test04("我想拉拉手,拉拉手,拉拉手"); + } + + + + + +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/ListenerImpl.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/ListenerImpl.java new file mode 100644 index 0000000..6e4c6a1 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/ListenerImpl.java @@ -0,0 +1,18 @@ +package com.bwie.alipay.demo.service; + +import com.bwie.alipay.demo.ListenerPer; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class ListenerImpl implements ListenerPer { + + private String name; + + @Override + public void test03(String message){ + System.out.println(name+"本次收到的内容是: "+message); + } + +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/MonitorImpl.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/MonitorImpl.java new file mode 100644 index 0000000..742a58b --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/MonitorImpl.java @@ -0,0 +1,31 @@ +package com.bwie.alipay.demo.service; + +import com.bwie.alipay.demo.ListenerPer; +import com.bwie.alipay.demo.MonitorPer; + +import java.util.ArrayList; + +public class MonitorImpl implements MonitorPer{ + + + ArrayList arrayList = new ArrayList<>(); + //添加 + @Override + public void test01(ListenerPer listenerPer){ + arrayList.add(listenerPer); + } + //删除 + @Override + public void test02(ListenerPer listenerPer){ + arrayList.remove(listenerPer); + } + //通知 + @Override + public void test04(String message){ + for (ListenerPer s : arrayList) { + s.test03(message); + } + } + + +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/NewspaperImpl.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/NewspaperImpl.java new file mode 100644 index 0000000..2024b47 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/NewspaperImpl.java @@ -0,0 +1,28 @@ +package com.bwie.alipay.demo.service; + +import com.bwie.alipay.demo.Newspaper; +import com.bwie.alipay.demo.Subscriber; + +import java.util.ArrayList; +import java.util.List; + +public class NewspaperImpl implements Newspaper { + List subscribers = new ArrayList<>(); + //添加订阅者 + @Override + public void addSubscriber(Subscriber subscriber) { + subscribers.add(subscriber); + } + //移除订阅者 + @Override + public void removeSubscriber(Subscriber subscriber) { + subscribers.remove(subscriber); + } + //通知订阅者 + @Override + public void notifySubscribers(String message) { + for (Subscriber s : subscribers) { + s.update(message); + } + } +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/SubscriberImpl.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/SubscriberImpl.java new file mode 100644 index 0000000..1e6e8e0 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/demo/service/SubscriberImpl.java @@ -0,0 +1,17 @@ +package com.bwie.alipay.demo.service; + +import com.bwie.alipay.demo.Subscriber; +import lombok.AllArgsConstructor; +import lombok.Data; + +@Data +@AllArgsConstructor +public class SubscriberImpl implements Subscriber { + private String name; + + @Override + public void update(String message) { + System.out.println(name + "---接到消息: " + message); + } + +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/mapper/AlimentPayMapper.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/mapper/AlimentPayMapper.java new file mode 100644 index 0000000..879e9ac --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/mapper/AlimentPayMapper.java @@ -0,0 +1,10 @@ +package com.bwie.alipay.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bwie.common.domain.PaymentEntity; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface AlimentPayMapper extends BaseMapper { + +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/mapper/AlipayMapper.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/mapper/AlipayMapper.java new file mode 100644 index 0000000..665a78e --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/mapper/AlipayMapper.java @@ -0,0 +1,7 @@ +package com.bwie.alipay.mapper; + +import org.apache.ibatis.annotations.Mapper; +@Mapper +public interface AlipayMapper{ + +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/mapper/AlipayWayMapper.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/mapper/AlipayWayMapper.java new file mode 100644 index 0000000..68d5210 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/mapper/AlipayWayMapper.java @@ -0,0 +1,9 @@ +package com.bwie.alipay.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bwie.common.domain.BuyOrder; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface AlipayWayMapper extends BaseMapper { + +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/AlimentPayService.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/AlimentPayService.java new file mode 100644 index 0000000..5f7bd1f --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/AlimentPayService.java @@ -0,0 +1,8 @@ +package com.bwie.alipay.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bwie.common.domain.PaymentEntity; + +public interface AlimentPayService extends IService { + +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/AlipayService.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/AlipayService.java new file mode 100644 index 0000000..406080b --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/AlipayService.java @@ -0,0 +1,10 @@ +package com.bwie.alipay.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bwie.common.domain.BuyOrder; +import com.bwie.common.domain.PaymentEntity; +import com.bwie.common.result.Result; + +public interface AlipayService { + +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/AlipayWayService.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/AlipayWayService.java new file mode 100644 index 0000000..22c883e --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/AlipayWayService.java @@ -0,0 +1,7 @@ +package com.bwie.alipay.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.bwie.common.domain.BuyOrder; + +public interface AlipayWayService extends IService { +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/impl/AlimentPayServiceImpl.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/impl/AlimentPayServiceImpl.java new file mode 100644 index 0000000..82eb669 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/impl/AlimentPayServiceImpl.java @@ -0,0 +1,14 @@ +package com.bwie.alipay.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bwie.alipay.mapper.AlimentPayMapper; +import com.bwie.alipay.mapper.AlipayWayMapper; +import com.bwie.alipay.service.AlimentPayService; +import com.bwie.common.domain.PaymentEntity; +import org.springframework.stereotype.Service; + +@Service +public class AlimentPayServiceImpl extends ServiceImpl implements AlimentPayService { + + +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/impl/AlipayServiceImpl.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/impl/AlipayServiceImpl.java new file mode 100644 index 0000000..03db767 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/impl/AlipayServiceImpl.java @@ -0,0 +1,10 @@ +package com.bwie.alipay.service.impl; + +import com.bwie.alipay.service.AlipayService; + +import org.springframework.stereotype.Service; + + +@Service +public class AlipayServiceImpl implements AlipayService { +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/impl/AlipayWayServiceImpl.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/impl/AlipayWayServiceImpl.java new file mode 100644 index 0000000..580e391 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/service/impl/AlipayWayServiceImpl.java @@ -0,0 +1,10 @@ +package com.bwie.alipay.service.impl; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bwie.alipay.mapper.AlipayWayMapper; +import com.bwie.alipay.service.AlipayWayService; +import com.bwie.common.domain.BuyOrder; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Service; +@Service +public class AlipayWayServiceImpl extends ServiceImpl implements AlipayWayService { +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/time/CreateTime.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/time/CreateTime.java new file mode 100644 index 0000000..8f18016 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/time/CreateTime.java @@ -0,0 +1,60 @@ +package com.bwie.alipay.time; + +import com.bwie.alipay.service.AlimentPayService; +import com.bwie.alipay.service.AlipayWayService; +import com.bwie.alipay.utils.service.AlipayWay; +import lombok.extern.log4j.Log4j2; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +@Log4j2 +@Component +public class CreateTime { + + @Autowired + private AlipayWayService alipayWayService; + @Autowired + private AlipayWay alipayWay; + + @Autowired + private AlimentPayService alimentPayService; +// @Scheduled(cron = "0/5 * * * * *") +// public void findOrderSn(){ +// List buyOrderList = alipayWayService.list( +// new LambdaQueryWrapper() +// .eq(BuyOrder::getBuyOrderZt, 3) +// +// ); +// buyOrderList.forEach(c->{ +// try { +// OrderSnRequest buyOrderDh = alipayWay.findBuyOrderDh(c.getBuyOrderDh()); +// OrderSnRequest.AlipayTradeQueryResponseBean queryResponse = buyOrderDh.getAlipay_trade_query_response(); +// String tradeStatus = queryResponse.getTrade_status(); +// if(tradeStatus.equals("TRADE_SUCCESS")){ +// alipayWayService.updateById( +// BuyOrder.builder() +// .buyOrderId(c.getBuyOrderId()) +// .buyOrderZt(c.getBuyOrderZt()) +// .build() +// ); +// } +// alimentPayService.list( +// new LambdaQueryWrapper() +// .eq(PaymentEntity::getPaymentDh,c.getBuyOrderDh()) +// ).forEach(s->{ +// if(s.getPaymentState().equals(2)){ +// alimentPayService.updateById( +// PaymentEntity.builder() +// .paymentId(s.getPaymentId()) +// .paymentState(3) +// .build() +// ); +// } +// }); +// }catch(AlipayApiException e) { +// throw new RuntimeException(e); +// } +// } +// ); +// } +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/PayServive.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/PayServive.java new file mode 100644 index 0000000..454592b --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/PayServive.java @@ -0,0 +1,10 @@ +package com.bwie.alipay.utils; + + +import com.alipay.api.AlipayApiException; +import com.bwie.common.domain.BuyOrder; + +public interface PayServive{ + + public String alipay(BuyOrder buyOrder) throws AlipayApiException; +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/service/AlipayWay.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/service/AlipayWay.java new file mode 100644 index 0000000..b104a4b --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/service/AlipayWay.java @@ -0,0 +1,86 @@ +package com.bwie.alipay.utils.service; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.alipay.api.AlipayApiException; +import com.alipay.api.AlipayClient; +import com.alipay.api.AlipayConfig; +import com.alipay.api.DefaultAlipayClient; +import com.alipay.api.domain.AlipayTradeQueryModel; +import com.alipay.api.request.AlipayTradePagePayRequest; +import com.alipay.api.response.AlipayTradePagePayResponse; +import com.bwie.alipay.vo.OrderSnRequest; +import com.bwie.alipay.utils.PayServive; +import com.bwie.alipay.vo.Alipay; +import com.bwie.common.domain.BuyOrder; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.ArrayList; + +@Component("Alipay") +public class AlipayWay implements PayServive { + @Autowired + private Alipay alipay; + public String alipay(BuyOrder buyOrder) throws AlipayApiException { + AlipayConfig alipayConfig = new AlipayConfig(); + alipayConfig.setServerUrl(alipay.getServerUrl()); + alipayConfig.setAppId(alipay.getAppId()); + alipayConfig.setPrivateKey(alipay.getPrivateKey()); + alipayConfig.setFormat("json"); + alipayConfig.setAlipayPublicKey(alipay.getAlipayPublicKey()); + alipayConfig.setCharset(alipay.getCharset()); + alipayConfig.setSignType(alipay.getSignType()); + AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig); + AlipayTradePagePayRequest request = new AlipayTradePagePayRequest(); + JSONObject bizContent = new JSONObject(); + //商户订单号,商家自定义,保持唯一性 + bizContent.put("out_trade_no", buyOrder.getOrderNumber()); + //支付金额,最小值0.01元 + bizContent.put("total_amount",buyOrder.getOrderPrice()); + //订单标题,不可使用特殊符号 + bizContent.put("subject", buyOrder.getOrderName()); + //电脑网站支付场景固定传值FAST_INSTANT_TRADE_PAY + bizContent.put("product_code", "FAST_INSTANT_TRADE_PAY"); + request.setBizContent(bizContent.toString()); + request.setNotifyUrl(" http://eeh7ds.natappfree.cc/notifyUrl"); + AlipayTradePagePayResponse response = alipayClient.pageExecute(request, "GET"); + String pageRedirectionData = response.getBody(); + System.out.println(pageRedirectionData); + if (response.isSuccess()) { + System.out.println("调用成功!!!!"); + } else { + System.out.printf("调用失败!!!!"); + } + return pageRedirectionData; + } + + public OrderSnRequest findBuyOrderDh(String buyOrderDh) throws AlipayApiException { + AlipayConfig alipayConfig = new AlipayConfig(); + alipayConfig.setServerUrl(alipay.getServerUrl()); + alipayConfig.setAppId(alipay.getAppId()); + alipayConfig.setPrivateKey(alipay.getPrivateKey()); + alipayConfig.setFormat("json"); + alipayConfig.setAlipayPublicKey(alipay.getAlipayPublicKey()); + alipayConfig.setCharset(alipay.getCharset()); + alipayConfig.setSignType(alipay.getSignType()); + AlipayClient alipayClient = new DefaultAlipayClient(alipayConfig); + + AlipayTradePagePayRequest request = new AlipayTradePagePayRequest(); + + AlipayTradeQueryModel model = new AlipayTradeQueryModel(); + model.setOutTradeNo(buyOrderDh); + + ArrayList arrayList = new ArrayList<>(); + arrayList.add("trade_settle_info"); + model.setQueryOptions(arrayList); + request.setBizModel(model); + AlipayTradePagePayResponse response = alipayClient.execute(request); + OrderSnRequest orderSnRequest = JSON.parseObject(response.getBody().toString(), OrderSnRequest.class); + if (response.isSuccess()) { + System.out.println("调用成功!!!!"); + } else { + System.out.printf("调用失败!!!!"); + } + return orderSnRequest; + } +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/service/UnionWay.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/service/UnionWay.java new file mode 100644 index 0000000..abd66e9 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/service/UnionWay.java @@ -0,0 +1,12 @@ +package com.bwie.alipay.utils.service; + +import com.bwie.common.domain.BuyOrder; +import org.springframework.stereotype.Component; + +@Component("UnionPay") +public class UnionWay { + + public String alipay(BuyOrder buyOrder){ + return "你好消费者,这是银联支付奥,支付金额是: "+buyOrder.getOrderPrice()+"元,支付的名称是: "+buyOrder.getOrderName()+",支付的单号是: "+buyOrder.getOrderNumber(); + } +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/service/Wechpay.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/service/Wechpay.java new file mode 100644 index 0000000..ae928d7 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/utils/service/Wechpay.java @@ -0,0 +1,14 @@ +package com.bwie.alipay.utils.service; + +import com.bwie.alipay.utils.PayServive; +import com.bwie.common.domain.BuyOrder; +import org.springframework.stereotype.Component; + +@Component("Wechpay") +public class Wechpay implements PayServive { + + + public String alipay(BuyOrder buyOrder){ + return "你好消费者,这是微信支付奥,支付金额是: "+buyOrder.getOrderPrice()+"元,支付的名称是: "+buyOrder.getOrderName()+",支付的单号是: "+buyOrder.getOrderNumber(); + } +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/vo/Alipay.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/vo/Alipay.java new file mode 100644 index 0000000..0def3d5 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/vo/Alipay.java @@ -0,0 +1,35 @@ +package com.bwie.alipay.vo; + +import com.alipay.api.AlipayClient; +import com.alipay.api.AlipayConstants; +import com.alipay.api.DefaultAlipayClient; +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.stereotype.Component; + +import java.math.BigDecimal; + +@Component +@ConfigurationProperties(prefix = "zhipay") +@Data +public class Alipay { + private String privateKey;//私钥 + private String alipayPublicKey;//支付宝公钥 + private String appId;//商户ID + private String notifyUrl;// + private String returnUrl;// + private String serverUrl; + private String charset; + private String signType; + private BigDecimal ordersPrice; + @Bean + public AlipayClient alipayClient() { + // 获得初始化的AlipayClient + return new DefaultAlipayClient(serverUrl, appId, privateKey, + AlipayConstants.FORMAT_JSON, AlipayConstants.CHARSET_UTF8, + alipayPublicKey, AlipayConstants.SIGN_TYPE_RSA2); + } + +} diff --git a/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/vo/OrderSnRequest.java b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/vo/OrderSnRequest.java new file mode 100644 index 0000000..7445579 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/java/com/bwie/alipay/vo/OrderSnRequest.java @@ -0,0 +1,46 @@ +package com.bwie.alipay.vo; +import lombok.Data; +import lombok.ToString; +import java.util.List; +/** + * + */ +@ToString +@Data +public class OrderSnRequest { + private AlipayTradeQueryResponseBean alipay_trade_query_response; + private String sign; + @ToString + @Data + public static class AlipayTradeQueryResponseBean { + private String code; + private String msg; + private String trade_no; + private String out_trade_no; + private String buyer_logon_id; + private String trade_status; + private String total_amount; + private String buyer_pay_amount; + private String point_amount; + private String invoice_amount; + private String send_pay_date; + private String receipt_amount; + private String store_id; + private String terminal_id; + private String store_name; + private String buyer_user_id; + private String buyer_open_id; + private String buyer_user_type; + private String mdiscount_amount; + private String discount_amount; + private String ext_infos; + private List fund_bill_list; + @ToString + @Data + public static class FundBillListBean { + private String fund_channel; + private String amount; + private String real_amount; + } + } +} diff --git a/bwie-modules/bwie-alipay/src/main/resources/bootstrap.yml b/bwie-modules/bwie-alipay/src/main/resources/bootstrap.yml new file mode 100644 index 0000000..e80f731 --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/resources/bootstrap.yml @@ -0,0 +1,42 @@ +# Tomcat +server: + port: 9090 +# Spring +spring: + # datasource: +# url: jdbc:mysql:xm_house//localhost:3306/mydatabase +# username: root +# password: admin111. + main: + allow-circular-references: true + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + application: + # 应用名称 + name: bwie-alipay + profiles: + # 环境配置 + active: dev + cloud: + nacos: + discovery: + # 服务注册地址 + server-addr: 124.221.30.134:8848 + config: + # 配置中心地址 + server-addr: 124.221.30.134:8848 + # 配置文件格式 + file-extension: yml + # 共享配置 + shared-configs: + - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +zhipay: + serverUrl: "https://openapi-sandbox.dl.alipaydev.com/gateway.do" + charset: "UTF-8" + signType: "RSA2" + appId: "9021000135679979" + privateKey: "MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCx8r9WaFV7CujWc9AzpbgsCq8axYJWm4s7x2eDcJXC+qhDXWsFW0xDX+xs4JCuVJ54+FGiflB24BeqgFDLNOchtkocK65BJohG5ojVONHq/ciruqbzAD0W6x96h8fKqlVuvz3EotMXuejg5J1gbDRmgTvPx7mYq94TXjxt75CUEserThSMF0geB0DJhrPxNe5JLAPKA5pRXd2e6wDybi2yKL2s2j4YuaTgDZuNAnlBYAiV6Pk7WpFB06LtbGg7JiM+Jawn3N64fL/24d4VIzcJD3AxWbGDZAXtW9+XZtsDa8z6ik3OGpbrSKu+RK0jjWzT2ETHnb/BdhtDJzFBo4dnAgMBAAECggEBAKWvrWIqATVwof1Tlk8QhVxUklfuAP7dExYVA5fJ01fZhaQ7rjMtn+O3w+5YZb48QdXG+FPBIvCclMyHbzLVzkOAdJ6oOTamRwslCdDmd+ZCaH8lat8loLvfLs8q7+cPFD7qx/t30+7qhiAoHTSza1LqD6PWhkPV+w+zlbaS8d471COE8P7XyxouFZ70qe9Aa7uVLEClxQemviSqIYOuHTFkNjWMleQR48tL2HA2ifKpa309Ifnbf3kGktyNaiG7plC5x3gUU3dSQdWZpnRHq/wh65TBhJHgLrjsIPhnfB9mmwCMZ66EJiUKajuqlvEjC/J0dkduMO6uPLYzTkejxbkCgYEA4arhCQgLquzRJDk5pI94ZzBiSWXaP3JUzfYEHQbbzcNvRPZBYJLDBUXNRVReujjt6efIcyrCi1zD3XvHfN2QmaNubeD5yF7aObYPVwoxDCvqHzZDVbYd9ZUGR2yIa+jdkVc5py0vmyfyxLSx3RvMuSP+rYtzhCJbowQiCkN4XUMCgYEAyd3efuY/0f59XF2DBSu8vCEaer7Wkieit980VZm06jxwt/3b5UcRlknKpum32n+mGlbpu4M/r5Zbpta+uuWbx6ajbIjc43rMuElkK6cz5d6AUTm6AsOKq8ARQPh4F5pzI18vrNAQrNyVpxwDMXIdmyArHD0Dv4NeIjlwucCT2Q0CgYBTAXGoysbP5i+/bTUgrI0TF57vdIFkmP9MitNUgfNTqjFBYnsFtLX7OIOansABK3OHd/QpOG86p7J7w03LRgwsFwtFa101MH6Af9EAqQUFfxmsxV7bJhO7A0e9+dPsLUlibn0MWviJz5XieLx7ogAZkX3aA9NHpQOj4J9MuyiI1QKBgQC/NyIuNG5ZvWYEGzQjrsVtszHA+YqJEXBqGc0aFKoxgyUGtDoamdJH+Qg0SYl1OJsfshpfG7k02wlgJWSv5xVD7k45Xf9Wn5jSK/rt+skHQldsGXFgctelTx9I2tPvD8dmxyCC4ugYxi4gCEHiEYWHztXnPsiRHaAKbTyhR5EE9QKBgGQRjcds+qeZeNTKrwSPFG/KD8h/kI0jTnFfeKMm1WXfuXcadTavbaruGUihLzveO9/dsizKJm38Pc2j5xNyBxGYUdbSxGZtC5uNmYuIsR3u8gy2oT3qFBPaFp/Y1PoHzLu6QTAYeo8Cz0TG+U8ah/81O9JPzZWyrkGLHIp5XyKq" + alipayPublicKey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkVyIo6qyxzk0YWnBo3ueKIpcpUPnrX0MuhdaUAoyJPtp19u2M67g8jSw7BWqppJ0Vso8sm7Px6VS3rOunlmgW5lyN0uMgy6+mE76gW8+2msjwR/DrzNL7aQn2idu9NgxxKk2BnLzajpR7W5Tk+sXmB9woLffbQ9hJW+SWJ6DnMtAbaB+3E/xaDO4o5yjTFbY063Vr2mgyt+PfK5i3unb3ffZj9jtqICWsDfpoY42fxxrRsKa3eLCJVO6sqUz3XLRex8WV7vcjtAuMsp6rFbwTPT5ELSYHXEY3uWuHHJChDE4eAKUpvavYj/hTZhlsOyTe1xPOAbnkAQ2B+kA+XHDRQIDAQAB" + notifyUrl: "http://m8gu77.natappfree.cc/notifyUrl" +# returnUrl: "http://m8gu77.natappfree.cc/notifyUrl" diff --git a/bwie-modules/bwie-alipay/src/main/resources/logback.xml b/bwie-modules/bwie-alipay/src/main/resources/logback.xml new file mode 100644 index 0000000..a24908d --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/resources/logback.xml @@ -0,0 +1,28 @@ + + + + logback + + + + + %d{HH:mm:ss.SSS} %contextName [%thread] %-5level %logger{36} - %msg%n + + + + + ${log.path} + + ${log.path}.%d{yyyy-MM-dd}.zip + + + %date %level [%thread] %logger{36} [%file : %line] %msg%n + + + + + + + + + diff --git a/bwie-modules/bwie-alipay/src/main/resources/mapper/AlipayWayMapper.xml b/bwie-modules/bwie-alipay/src/main/resources/mapper/AlipayWayMapper.xml new file mode 100644 index 0000000..979880c --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/resources/mapper/AlipayWayMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/bwie-modules/bwie-alipay/src/main/resources/mapper/AlipaymentPayMapper.xml b/bwie-modules/bwie-alipay/src/main/resources/mapper/AlipaymentPayMapper.xml new file mode 100644 index 0000000..e70dddb --- /dev/null +++ b/bwie-modules/bwie-alipay/src/main/resources/mapper/AlipaymentPayMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/bwie-modules/bwie-system/src/main/resources/mapper/SysMapper.xml b/bwie-modules/bwie-alipay/src/main/resources/mapper/SeeHouseMapper.xml similarity index 73% rename from bwie-modules/bwie-system/src/main/resources/mapper/SysMapper.xml rename to bwie-modules/bwie-alipay/src/main/resources/mapper/SeeHouseMapper.xml index d8da7bb..9805a97 100644 --- a/bwie-modules/bwie-system/src/main/resources/mapper/SysMapper.xml +++ b/bwie-modules/bwie-alipay/src/main/resources/mapper/SeeHouseMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/bwie-modules/bwie-xxl/src/main/java/com/bwie/xxl/XxlApp.java b/bwie-modules/bwie-system/src/main/java/com/bwie/UserApp.java similarity index 70% rename from bwie-modules/bwie-xxl/src/main/java/com/bwie/xxl/XxlApp.java rename to bwie-modules/bwie-system/src/main/java/com/bwie/UserApp.java index f10a1e4..972b253 100644 --- a/bwie-modules/bwie-xxl/src/main/java/com/bwie/xxl/XxlApp.java +++ b/bwie-modules/bwie-system/src/main/java/com/bwie/UserApp.java @@ -1,4 +1,4 @@ -package com.bwie.xxl; +package com.bwie; import org.mybatis.spring.annotation.MapperScan; import org.springframework.boot.SpringApplication; @@ -8,8 +8,14 @@ import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient -public class XxlApp { +@EnableFeignClients("com.bwie.**") +@MapperScan("com.bwie.user.mapper") +public class UserApp { + public static void main(String[] args) { - SpringApplication.run(XxlApp.class); + + SpringApplication.run(UserApp.class,args); + } + } diff --git a/bwie-modules/bwie-system/src/main/java/com/bwie/user/controller/UserController.java b/bwie-modules/bwie-system/src/main/java/com/bwie/user/controller/UserController.java new file mode 100644 index 0000000..4734d24 --- /dev/null +++ b/bwie-modules/bwie-system/src/main/java/com/bwie/user/controller/UserController.java @@ -0,0 +1,53 @@ +package com.bwie.user.controller; + + +import com.alibaba.nacos.shaded.org.checkerframework.checker.units.qual.A; +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.LoginRequest; +import com.bwie.common.result.Result; +import com.bwie.user.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.Past; + +@RestController +public class UserController { + + + @Autowired + private UserService userService; + + + public UserController(UserService userService) { + this.userService = userService; + } + + + @PostMapping("/login") + public Result login(@RequestBody LoginRequest loginRequest){ + + return Result.success( + userService.login(loginRequest) + + ); + } + + @PostMapping("/register") + public Result register(@RequestBody User user){ + userService.register(user); + return Result.success(); + } + + @GetMapping("/findByPhone/{userPhone}") + public Result findByPhone(@PathVariable("userPhone") String userPhone){ + return userService.findByPhone(userPhone); + } + + @PostMapping("/phoneLogin/{userPhone}") + public Result phoneLogin(@PathVariable String userPhone){ + User user = userService.phoneLogin(userPhone); + + return Result.success(user); + } +} diff --git a/bwie-modules/bwie-system/src/main/java/com/bwie/user/mapper/UserMapper.java b/bwie-modules/bwie-system/src/main/java/com/bwie/user/mapper/UserMapper.java new file mode 100644 index 0000000..50f8763 --- /dev/null +++ b/bwie-modules/bwie-system/src/main/java/com/bwie/user/mapper/UserMapper.java @@ -0,0 +1,13 @@ +package com.bwie.user.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bwie.common.domain.User; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +@Mapper +public interface UserMapper extends BaseMapper { + + + User phoneLogin(@Param("userPhone") String userPhone); +} diff --git a/bwie-modules/bwie-system/src/main/java/com/bwie/user/service/UserService.java b/bwie-modules/bwie-system/src/main/java/com/bwie/user/service/UserService.java new file mode 100644 index 0000000..81ea69d --- /dev/null +++ b/bwie-modules/bwie-system/src/main/java/com/bwie/user/service/UserService.java @@ -0,0 +1,19 @@ +package com.bwie.user.service; + +import com.baomidou.mybatisplus.extension.service.IService; + +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.LoginRequest; +import com.bwie.common.result.Result; + +public interface UserService extends IService { + + + User login(LoginRequest loginRequest); + + void register(User user); + + Result findByPhone(String userPhone); + + User phoneLogin(String userPhone); +} diff --git a/bwie-modules/bwie-system/src/main/java/com/bwie/user/service/impl/UserServiceImpl.java b/bwie-modules/bwie-system/src/main/java/com/bwie/user/service/impl/UserServiceImpl.java new file mode 100644 index 0000000..02124c9 --- /dev/null +++ b/bwie-modules/bwie-system/src/main/java/com/bwie/user/service/impl/UserServiceImpl.java @@ -0,0 +1,46 @@ +package com.bwie.user.service.impl; +import cn.hutool.crypto.SecureUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; + +import com.bwie.common.domain.User; +import com.bwie.common.domain.request.LoginRequest; +import com.bwie.common.result.Result; +import com.bwie.user.mapper.UserMapper; +import com.bwie.user.service.UserService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class UserServiceImpl extends ServiceImpl implements UserService { + + @Autowired + private UserMapper userMapper; + + @Override + public User login(LoginRequest loginRequest) { + String userPwd = SecureUtil.md5(loginRequest.getUserPwd() + "|" + ""); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(User::getUserName,loginRequest.getUserName()) + .eq(User::getUserPwd,userPwd); + return this.getOne(queryWrapper); + } + + @Override + public void register(User user) { + this.save(user); + } + + @Override + public Result findByPhone(String userPhone) { + User user = this.getOne(new LambdaQueryWrapper() + .eq(User::getUserPhone, userPhone)); + return Result.success(user); + } + + @Override + public User phoneLogin(String userPhone) { + + return userMapper.phoneLogin(userPhone); + } +} diff --git a/bwie-modules/bwie-system/src/main/resources/bootstrap.yml b/bwie-modules/bwie-system/src/main/resources/bootstrap.yml index b91ebe2..f78a8cb 100644 --- a/bwie-modules/bwie-system/src/main/resources/bootstrap.yml +++ b/bwie-modules/bwie-system/src/main/resources/bootstrap.yml @@ -11,7 +11,7 @@ spring: time-zone: GMT+8 application: # 应用名称 - name: bwie-system + name: bwie-User profiles: # 环境配置 active: dev diff --git a/bwie-modules/bwie-system/src/main/resources/mapper/MonitorPer.xml b/bwie-modules/bwie-system/src/main/resources/mapper/MonitorPer.xml new file mode 100644 index 0000000..879aec1 --- /dev/null +++ b/bwie-modules/bwie-system/src/main/resources/mapper/MonitorPer.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/bwie-modules/bwie-team/pom.xml b/bwie-modules/bwie-team/pom.xml index 6d402d8..bed0f2d 100644 --- a/bwie-modules/bwie-team/pom.xml +++ b/bwie-modules/bwie-team/pom.xml @@ -8,9 +8,7 @@ bwie-modules 1.0.0 - bwie-team - 17 17 @@ -27,7 +25,6 @@ org.springframework.boot spring-boot-starter-web - com.alibaba @@ -45,7 +42,6 @@ mybatis-spring-boot-starter 2.2.2 - com.github.pagehelper @@ -58,5 +54,46 @@ spring-boot-starter-test test + + com.alibaba + fastjson + 1.2.15 + + + org.apache.httpcomponents + httpclient + 4.2.1 + + + org.apache.httpcomponents + httpcore + 4.2.1 + + + commons-lang + commons-lang + 2.6 + + + org.eclipse.jetty + jetty-util + 9.3.7.v20160115 + + + junit + junit + 4.5 + test + + + com.github.tobato + fastdfs-client + 1.27.2 + + + com.github.tobato + fastdfs-client + 1.26.5 + diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/TeamApplication.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/TeamApplication.java new file mode 100644 index 0000000..4a042eb --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/TeamApplication.java @@ -0,0 +1,14 @@ +package com.bwie.team; + + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +//@MapperScan("com.bwie.team") +public class TeamApplication { + + public static void main(String[] args) { + SpringApplication.run(TeamApplication.class); + } +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsAttrController.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsAttrController.java new file mode 100644 index 0000000..64f10e5 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsAttrController.java @@ -0,0 +1,7 @@ +package com.bwie.team.controller; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class GoodsAttrController { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsCateGoryController.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsCateGoryController.java new file mode 100644 index 0000000..5b9cd7e --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsCateGoryController.java @@ -0,0 +1,7 @@ +package com.bwie.team.controller; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class GoodsCateGoryController { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSkuAttrValueController.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSkuAttrValueController.java new file mode 100644 index 0000000..d955ce2 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSkuAttrValueController.java @@ -0,0 +1,7 @@ +package com.bwie.team.controller; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class GoodsSkuAttrValueController { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSkuController.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSkuController.java new file mode 100644 index 0000000..5d80d10 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSkuController.java @@ -0,0 +1,7 @@ +package com.bwie.team.controller; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class GoodsSkuController{ +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSpuAttrValueController.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSpuAttrValueController.java new file mode 100644 index 0000000..a80766d --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSpuAttrValueController.java @@ -0,0 +1,7 @@ +package com.bwie.team.controller; + +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class GoodsSpuAttrValueController { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSpuController.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSpuController.java new file mode 100644 index 0000000..cdb9531 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSpuController.java @@ -0,0 +1,32 @@ +package com.bwie.team.controller; + +import com.bwie.common.domain.GoodSpu; +import com.bwie.common.result.Result; +import com.bwie.team.service.GoodsSpuService; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +public class GoodsSpuController { + + private final GoodsSpuService goodsSpuService; + + public GoodsSpuController(GoodsSpuService goodsSpuService) { + this.goodsSpuService = goodsSpuService; + } + + @PostMapping("/shouall") + public Result> shouall(){ + return Result.success(goodsSpuService.shouall()); + } + + @PostMapping("/addGoodSpu") + public Result addGoodSpu(@RequestBody GoodSpu goodSpu){ + return goodsSpuService.addGoodSpu(goodSpu); + } + + +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSpuImageController.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSpuImageController.java new file mode 100644 index 0000000..8ef97cc --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/GoodsSpuImageController.java @@ -0,0 +1,36 @@ +package com.bwie.team.controller; +import com.bwie.common.domain.GoodsSpuImages; +import com.bwie.common.result.Result; +import com.bwie.team.service.GoodsSpuImageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; +@RestController +public class GoodsSpuImageController { + @Autowired + private GoodsSpuImageService goodsSpuImageService; + @PostMapping("/addImage") + public Result addImage(@RequestBody GoodsSpuImages goodsSpuImages){ + return goodsSpuImageService.addImage(goodsSpuImages); + } + + + @PostMapping("/addImages") + public Result addImages(@RequestBody GoodsSpuImages goodsSpuImages){ + return goodsSpuImageService.addImage(goodsSpuImages); + } + + + + + + + + + + + + + +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/TeamController.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/TeamController.java deleted file mode 100644 index 2e3eefb..0000000 --- a/bwie-modules/bwie-team/src/main/java/com/bwie/team/controller/TeamController.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.bwie.team.controller; - -public class TeamController { -} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/demo/demo.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/demo/demo.java new file mode 100644 index 0000000..bd9b0a9 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/demo/demo.java @@ -0,0 +1,50 @@ +package com.bwie.team.demo; +import java.util.HashMap; +import java.util.Iterator; +public class demo { +// public static void main(String[] args) { +// String host = "https://D:\\mq\\aaaaa.jpg"; +// String path = "/iden2OCR"; +// String method = "POST"; +// String appcode = "你自己的AppCode"; +// Map headers = new HashMap(); +// //最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105 +// headers.put("Authorization", "APPCODE " + appcode); +// //根据API的要求,定义相对应的Content-Type +// headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); +// //需要给X-Ca-Nonce的值生成随机字符串,每次请求不能相同 +// headers.put("X-Ca-Nonce", UUID.randomUUID().toString()); +// Map querys = new HashMap(); +// Map bodys = new HashMap(); +// bodys.put("imgbase64", "/9j/4AAQSkZJRgABAQAA... ...3F/9k="); +// bodys.put("side", "front"); +// try { +// /** +// * 重要提示如下: +// * HttpUtils请从 +// * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/src/main/java/com/aliyun/api/gateway/demo/util/HttpUtils.java +// * 下载 +// * +// * 相应的依赖请参照 +// * https://github.com/aliyun/api-gateway-demo-sign-java/blob/master/pom.xml +// */ +// HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys); +// System.out.println(response.toString()); +// //获取response的body +// //System.out.println(EntityUtils.toString(response.getEntity())); +// } catch (Exception e) { +// e.printStackTrace(); +// } +// } + public static void main(String[] args) { + HashMap map = new HashMap<>(); + map.put("admin","admin"); + map.put("hashmao","hashmap"); + Iterator it = map.keySet().iterator(); + //获取迭代器 + while(it.hasNext()){ + Object key = it.next(); + System.out.println(map.get(key)); + } + } +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsAttrMapper.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsAttrMapper.java new file mode 100644 index 0000000..9879ceb --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsAttrMapper.java @@ -0,0 +1,12 @@ +package com.bwie.team.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bwie.common.domain.GoodAttr; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GoodsAttrMapper extends BaseMapper { + + + +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsCateGoryMapper.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsCateGoryMapper.java new file mode 100644 index 0000000..1eeb774 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsCateGoryMapper.java @@ -0,0 +1,10 @@ +package com.bwie.team.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bwie.common.domain.GoodsCateGory; +import org.apache.ibatis.annotations.Mapper; +import org.mybatis.spring.annotation.MapperScan; + +@Mapper +public interface GoodsCateGoryMapper extends BaseMapper { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSkuAttrValueMapper.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSkuAttrValueMapper.java new file mode 100644 index 0000000..01fe5f8 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSkuAttrValueMapper.java @@ -0,0 +1,9 @@ +package com.bwie.team.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bwie.common.domain.GoodsSkuAttrValue; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GoodsSkuAttrValueMapper extends BaseMapper { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSkuMapper.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSkuMapper.java new file mode 100644 index 0000000..20ae23c --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSkuMapper.java @@ -0,0 +1,9 @@ +package com.bwie.team.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bwie.common.domain.GoodSku; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GoodsSkuMapper extends BaseMapper { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSpuAttrValueMapper.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSpuAttrValueMapper.java new file mode 100644 index 0000000..a3698c3 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSpuAttrValueMapper.java @@ -0,0 +1,9 @@ +package com.bwie.team.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bwie.common.domain.GoodsSpuAttrValue; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GoodsSpuAttrValueMapper extends BaseMapper { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSpuImageMapper.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSpuImageMapper.java new file mode 100644 index 0000000..7acd9ed --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSpuImageMapper.java @@ -0,0 +1,11 @@ +package com.bwie.team.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bwie.common.domain.GoodsSpuImages; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GoodsSpuImageMapper extends BaseMapper{ + Integer addImages(GoodsSpuImages goodsSpuImages); + +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSpuMapper.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSpuMapper.java new file mode 100644 index 0000000..5e2dd88 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/GoodsSpuMapper.java @@ -0,0 +1,11 @@ +package com.bwie.team.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bwie.common.domain.GoodSpu; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface GoodsSpuMapper extends BaseMapper { + Integer addGoodSpu(GoodSpu goodSpu); + +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/TeamMapper.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/TeamMapper.java deleted file mode 100644 index a9b6ee7..0000000 --- a/bwie-modules/bwie-team/src/main/java/com/bwie/team/mapper/TeamMapper.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.bwie.team.mapper; - -public interface TeamMapper { -} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsAttrService.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsAttrService.java new file mode 100644 index 0000000..890bed6 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsAttrService.java @@ -0,0 +1,4 @@ +package com.bwie.team.service; + +public interface GoodsAttrService { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsCateGoryService.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsCateGoryService.java new file mode 100644 index 0000000..9af69ff --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsCateGoryService.java @@ -0,0 +1,4 @@ +package com.bwie.team.service; + +public interface GoodsCateGoryService { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSkuAttrValueService.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSkuAttrValueService.java new file mode 100644 index 0000000..79cfd77 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSkuAttrValueService.java @@ -0,0 +1,4 @@ +package com.bwie.team.service; + +public interface GoodsSkuAttrValueService { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSkuService.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSkuService.java new file mode 100644 index 0000000..6619395 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSkuService.java @@ -0,0 +1,5 @@ +package com.bwie.team.service; + +public interface GoodsSkuService { + +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSpuAttrValueService.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSpuAttrValueService.java new file mode 100644 index 0000000..ed28853 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSpuAttrValueService.java @@ -0,0 +1,4 @@ +package com.bwie.team.service; + +public interface GoodsSpuAttrValueService { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSpuImageService.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSpuImageService.java new file mode 100644 index 0000000..6b4dc5b --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSpuImageService.java @@ -0,0 +1,11 @@ +package com.bwie.team.service; + +import com.bwie.common.domain.GoodsSpuImages; +import com.bwie.common.result.Result; + +public interface GoodsSpuImageService { + + public Result addImage(GoodsSpuImages goodsSpuImages); + + public Result addImages(GoodsSpuImages goodsSpuImages); +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSpuService.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSpuService.java new file mode 100644 index 0000000..4866864 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/GoodsSpuService.java @@ -0,0 +1,13 @@ +package com.bwie.team.service; + +import com.bwie.common.domain.GoodSpu; +import com.bwie.common.result.Result; + +import java.util.List; + +public interface GoodsSpuService { + + List shouall(); + + Result addGoodSpu(GoodSpu goodSpu); +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/TeamService.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/TeamService.java deleted file mode 100644 index d5a2f93..0000000 --- a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/TeamService.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.bwie.team.service; - -public interface TeamService { -// 查询商品信息 - - - - -} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/TeamServiceImpl.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/TeamServiceImpl.java deleted file mode 100644 index 69f1979..0000000 --- a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/TeamServiceImpl.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.bwie.team.service; - -public class TeamServiceImpl { -} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsAttrServiceImpl.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsAttrServiceImpl.java new file mode 100644 index 0000000..41c6bc3 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsAttrServiceImpl.java @@ -0,0 +1,14 @@ +package com.bwie.team.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bwie.common.domain.GoodAttr; +import com.bwie.team.mapper.GoodsAttrMapper; +import com.bwie.team.service.GoodsAttrService; +import org.springframework.stereotype.Service; + +@Service +public class GoodsAttrServiceImpl extends ServiceImpl implements GoodsAttrService { + + + +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsCateGoryServiceImpl.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsCateGoryServiceImpl.java new file mode 100644 index 0000000..85899cd --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsCateGoryServiceImpl.java @@ -0,0 +1,13 @@ +package com.bwie.team.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bwie.common.domain.GoodsCateGory; +import com.bwie.team.mapper.GoodsCateGoryMapper; +import com.bwie.team.service.GoodsCateGoryService; +import org.springframework.stereotype.Service; + +@Service +public class GoodsCateGoryServiceImpl extends ServiceImpl implements GoodsCateGoryService { + + +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSkuAttrValueServiceImpl.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSkuAttrValueServiceImpl.java new file mode 100644 index 0000000..6c17006 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSkuAttrValueServiceImpl.java @@ -0,0 +1,11 @@ +package com.bwie.team.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bwie.common.domain.GoodsSkuAttrValue; +import com.bwie.team.mapper.GoodsSkuAttrValueMapper; +import com.bwie.team.service.GoodsSkuAttrValueService; +import org.springframework.stereotype.Service; + +@Service +public class GoodsSkuAttrValueServiceImpl extends ServiceImpl implements GoodsSkuAttrValueService { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSkuServiceImpl.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSkuServiceImpl.java new file mode 100644 index 0000000..4bc01d0 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSkuServiceImpl.java @@ -0,0 +1,8 @@ +package com.bwie.team.service.impl; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bwie.common.domain.GoodSku; +import com.bwie.team.mapper.GoodsSkuMapper; +import com.bwie.team.service.GoodsSkuService; +import org.springframework.stereotype.Service; +@Service +public class GoodsSkuServiceImpl extends ServiceImpl implements GoodsSkuService {} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSpuAttrValueServiceImpl.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSpuAttrValueServiceImpl.java new file mode 100644 index 0000000..c5d1cbe --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSpuAttrValueServiceImpl.java @@ -0,0 +1,11 @@ +package com.bwie.team.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bwie.common.domain.GoodsSpuAttrValue; +import com.bwie.team.mapper.GoodsSpuAttrValueMapper; +import com.bwie.team.service.GoodsSpuAttrValueService; +import org.springframework.stereotype.Service; + +@Service +public class GoodsSpuAttrValueServiceImpl extends ServiceImpl implements GoodsSpuAttrValueService { +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSpuImageServiceImpl.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSpuImageServiceImpl.java new file mode 100644 index 0000000..1edf276 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSpuImageServiceImpl.java @@ -0,0 +1,38 @@ +package com.bwie.team.service.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bwie.common.domain.GoodsSpuImages; +import com.bwie.common.result.Result; +import com.bwie.team.mapper.GoodsSpuImageMapper; +import com.bwie.team.service.GoodsSpuImageService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +@Service +public class GoodsSpuImageServiceImpl extends ServiceImpl implements GoodsSpuImageService { + + + @Autowired + private GoodsSpuImageMapper goodsSpuImageMapper; + + + @Override + public Result addImage(GoodsSpuImages goodsSpuImages){ + goodsSpuImages.setDefaultStatus(0); + Integer i = goodsSpuImageMapper.insert(goodsSpuImages); + + return Result.success(i>0?200:500,i>0?"添加成功!!!!!":"添加失败!!!!!"); + } + + @Override + public Result addImages(GoodsSpuImages goodsSpuImages){ + Integer i = goodsSpuImageMapper.addImages(goodsSpuImages); + return Result.success(i>0?200:500,i>0?"添加成功!!!!!!":"添加失败!!!!!"); + } + + + + + + +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSpuServiceImpl.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSpuServiceImpl.java new file mode 100644 index 0000000..e4d0bd4 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/service/impl/GoodsSpuServiceImpl.java @@ -0,0 +1,50 @@ +package com.bwie.team.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.bwie.common.domain.GoodSpu; +import com.bwie.common.result.Result; +import com.bwie.team.mapper.GoodsSpuMapper; +import com.bwie.team.service.GoodsSpuService; +import com.bwie.team.utils.FastUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import java.util.List; +@Service +public class GoodsSpuServiceImpl extends ServiceImpl implements GoodsSpuService { + @Autowired + private GoodsSpuMapper goodsSpuMapper; + + @Autowired + private FastUtil fastUtil; + /** + * 正常的链表 + * @return + */ + @Override + public List shouall(){ + LambdaQueryWrapper goodSpuLambdaQueryWrapper = new LambdaQueryWrapper<>(); + List goodSpus = goodsSpuMapper.selectList(goodSpuLambdaQueryWrapper); + List list = this.list(); + return list; + } + /** + * 商品的添加 + * @param goodSpu + * @return + */ + @Override + public Result addGoodSpu(GoodSpu goodSpu){ + Integer insert = goodsSpuMapper.addGoodSpu(goodSpu); + return Result.success(insert>0?200:500,insert>0?"添加成功!!!!":"添加失败!!!!!"); + } +// @Override +// public Result addImage(MultipartFile multipartFile){ +// String img = ""; +// try { +// img = fastUtil.upload(multipartFile); +// } catch (Exception e) { +// throw new RuntimeException(e); +// } +// return Result.success("http:"); +// } +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/utils/FastConfig.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/utils/FastConfig.java new file mode 100644 index 0000000..de83d17 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/utils/FastConfig.java @@ -0,0 +1,20 @@ +package com.bwie.team.utils; + +import com.github.tobato.fastdfs.FdfsClientConfig; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.EnableMBeanExport; +import org.springframework.context.annotation.Import; +import org.springframework.jmx.support.RegistrationPolicy; + +/** + * @BelongsProject: demo02 + * @BelongsPackage: com.bw.config + * @Author: zhupengfei + * @CreateTime: 2022-12-16 14:37 + */ +@Configuration +// 解决 jmx 重复注册 bean 的问题 +@EnableMBeanExport(registration = RegistrationPolicy.IGNORE_EXISTING) +public class FastConfig { + +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/utils/FastUtil.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/utils/FastUtil.java new file mode 100644 index 0000000..6c4e806 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/utils/FastUtil.java @@ -0,0 +1,57 @@ +package com.bwie.team.utils; + +import com.github.tobato.fastdfs.domain.fdfs.StorePath; +import com.github.tobato.fastdfs.service.FastFileStorageClient; +import org.springframework.stereotype.Component; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; + +/** + * @BelongsProject: 0107day02 + * @BelongsPackage: com.bw.config + * @Author: zhupengfei + * @CreateTime: 2023-02-01 08:52 + */ +@Component +public class FastUtil { + private static final Logger log = LoggerFactory.getLogger(FastUtil.class); + + @Resource + private FastFileStorageClient storageClient ; + + /** + * 上传文件 + */ + public String upload(MultipartFile multipartFile) throws Exception{ + String originalFilename = multipartFile.getOriginalFilename(). + substring(multipartFile.getOriginalFilename(). + lastIndexOf(".") + 1); + StorePath storePath = this.storageClient.uploadImageAndCrtThumbImage( + multipartFile.getInputStream(), + multipartFile.getSize(),originalFilename , null); + return storePath.getFullPath() ; + } + /** + * 删除文件 + */ + public String deleteFile(String fileUrl) { + if (StringUtils.isEmpty(fileUrl)) { + log.info("fileUrl == >>文件路径为空..."); + return "文件路径不能为空"; + } + try { + StorePath storePath = StorePath.parseFromUrl(fileUrl); + storageClient.deleteFile(storePath.getGroup(), storePath.getPath()); + } catch (Exception e) { + log.error(e.getMessage()); + } + return "删除成功"; + } + +} diff --git a/bwie-modules/bwie-team/src/main/java/com/bwie/team/utils/HttpUtils.java b/bwie-modules/bwie-team/src/main/java/com/bwie/team/utils/HttpUtils.java new file mode 100644 index 0000000..bba0f1f --- /dev/null +++ b/bwie-modules/bwie-team/src/main/java/com/bwie/team/utils/HttpUtils.java @@ -0,0 +1,312 @@ +package com.bwie.team.utils; + +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; +import java.security.KeyManagementException; +import java.security.NoSuchAlgorithmException; +import java.security.cert.X509Certificate; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import javax.net.ssl.SSLContext; +import javax.net.ssl.TrustManager; +import javax.net.ssl.X509TrustManager; + +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpResponse; +import org.apache.http.NameValuePair; +import org.apache.http.client.HttpClient; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpDelete; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.methods.HttpPut; +import org.apache.http.conn.ClientConnectionManager; +import org.apache.http.conn.scheme.Scheme; +import org.apache.http.conn.scheme.SchemeRegistry; +import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.DefaultHttpClient; +import org.apache.http.message.BasicNameValuePair; + +public class HttpUtils { + + /** + * get + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @return + * @throws Exception + */ + public static HttpResponse doGet(String host, String path, String method, + Map headers, + Map querys) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpGet request = new HttpGet(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + return httpClient.execute(request); + } + + /** + * post form + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param bodys + * @return + * @throws Exception + */ + public static HttpResponse doPost(String host, String path, String method, + Map headers, + Map querys, + Map bodys) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPost request = new HttpPost(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (bodys != null) { + List nameValuePairList = new ArrayList(); + + for (String key : bodys.keySet()) { + nameValuePairList.add(new BasicNameValuePair(key, bodys.get(key))); + } + UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(nameValuePairList, "utf-8"); + formEntity.setContentType("application/x-www-form-urlencoded; charset=UTF-8"); + request.setEntity(formEntity); + } + + return httpClient.execute(request); + } + + /** + * Post String + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPost(String host, String path, String method, + Map headers, + Map querys, + String body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPost request = new HttpPost(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (StringUtils.isNotBlank(body)) { + request.setEntity(new StringEntity(body, "utf-8")); + } + + return httpClient.execute(request); + } + + /** + * Post stream + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPost(String host, String path, String method, + Map headers, + Map querys, + byte[] body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPost request = new HttpPost(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (body != null) { + request.setEntity(new ByteArrayEntity(body)); + } + + return httpClient.execute(request); + } + + /** + * Put String + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPut(String host, String path, String method, + Map headers, + Map querys, + String body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPut request = new HttpPut(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (StringUtils.isNotBlank(body)) { + request.setEntity(new StringEntity(body, "utf-8")); + } + + return httpClient.execute(request); + } + + /** + * Put stream + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @param body + * @return + * @throws Exception + */ + public static HttpResponse doPut(String host, String path, String method, + Map headers, + Map querys, + byte[] body) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpPut request = new HttpPut(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + if (body != null) { + request.setEntity(new ByteArrayEntity(body)); + } + + return httpClient.execute(request); + } + + /** + * Delete + * + * @param host + * @param path + * @param method + * @param headers + * @param querys + * @return + * @throws Exception + */ + public static HttpResponse doDelete(String host, String path, String method, + Map headers, + Map querys) + throws Exception { + HttpClient httpClient = wrapClient(host); + + HttpDelete request = new HttpDelete(buildUrl(host, path, querys)); + for (Map.Entry e : headers.entrySet()) { + request.addHeader(e.getKey(), e.getValue()); + } + + return httpClient.execute(request); + } + + private static String buildUrl(String host, String path, Map querys) throws UnsupportedEncodingException { + StringBuilder sbUrl = new StringBuilder(); + sbUrl.append(host); + if (!StringUtils.isBlank(path)) { + sbUrl.append(path); + } + if (null != querys) { + StringBuilder sbQuery = new StringBuilder(); + for (Map.Entry query : querys.entrySet()) { + if (0 < sbQuery.length()) { + sbQuery.append("&"); + } + if (StringUtils.isBlank(query.getKey()) && !StringUtils.isBlank(query.getValue())) { + sbQuery.append(query.getValue()); + } + if (!StringUtils.isBlank(query.getKey())) { + sbQuery.append(query.getKey()); + if (!StringUtils.isBlank(query.getValue())) { + sbQuery.append("="); + sbQuery.append(URLEncoder.encode(query.getValue(), "utf-8")); + } + } + } + if (0 < sbQuery.length()) { + sbUrl.append("?").append(sbQuery); + } + } + + return sbUrl.toString(); + } + + private static HttpClient wrapClient(String host) { + HttpClient httpClient = new DefaultHttpClient(); + if (host.startsWith("https://")) { + sslClient(httpClient); + } + + return httpClient; + } + + private static void sslClient(HttpClient httpClient) { + try { + SSLContext ctx = SSLContext.getInstance("TLS"); + X509TrustManager tm = new X509TrustManager() { + public X509Certificate[] getAcceptedIssuers() { + return null; + } + public void checkClientTrusted(X509Certificate[] xcs, String str) { + + } + public void checkServerTrusted(X509Certificate[] xcs, String str) { + + } + }; + ctx.init(null, new TrustManager[] { tm }, null); + SSLSocketFactory ssf = new SSLSocketFactory(ctx); + ssf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); + ClientConnectionManager ccm = httpClient.getConnectionManager(); + SchemeRegistry registry = ccm.getSchemeRegistry(); + registry.register(new Scheme("https", 443, ssf)); + } catch (KeyManagementException ex) { + throw new RuntimeException(ex); + } catch (NoSuchAlgorithmException ex) { + throw new RuntimeException(ex); + } + } +} diff --git a/bwie-modules/bwie-team/src/main/resources/bootstrap.yml b/bwie-modules/bwie-team/src/main/resources/bootstrap.yml index 12fa2a2..47d14ed 100644 --- a/bwie-modules/bwie-team/src/main/resources/bootstrap.yml +++ b/bwie-modules/bwie-team/src/main/resources/bootstrap.yml @@ -11,7 +11,7 @@ spring: time-zone: GMT+8 application: # 应用名称 - name: bwie-team + name: bwie-List profiles: # 环境配置 active: dev @@ -19,12 +19,37 @@ spring: nacos: discovery: # 服务注册地址 - server-addr: 124.221.177.197:8848 + server-addr: 124.221.30.134:8848 config: # 配置中心地址 - server-addr: 124.221.177.197:8848 + server-addr: 124.221.30.134:8848 # 配置文件格式 file-extension: yml # 共享配置 shared-configs: - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} +select: + multipart: + max-file-size: 100MB # 最大支持文件大小 + max-request-size: 100MB # 最大请求大小 + enabled: true + +aliyun: + end-point: oss-cn-shanghai.aliyuncs.com + access-key-id: LTAI5tSFAGrms29r1xwEFtRM + access-key-secret: rztMfqxdYlsMUtIoy9bIOSGEKCWQT7 + access-pre: https://dongxiaojie.oss-cn-shanghai.aliyuncs.com + bucket-name: dongxiaojie + +fdfs: + so-timeout: 1500 # socket 连接时长 + connect-timeout: 600 # 连接 tracker 服务器超时时长 + # 这两个是你服务器的 IP 地址,注意 23000 端口也要打开,阿里云服务器记得配置安全组。tracker 要和 stroage 服务进行交流 + tracker-list: 124.221.30.134:22122 + web-server-url: 124.221.30.134:8888 + pool: + jmx-enabled: false + # 生成缩略图 + thumb-image: + height: 500 + width: 500 diff --git a/bwie-modules/bwie-team/src/main/resources/mapper/GoodsAttrMapper.xml b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsAttrMapper.xml new file mode 100644 index 0000000..2e17bd1 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsAttrMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSkuAttrValueMapper.xml b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSkuAttrValueMapper.xml new file mode 100644 index 0000000..ec657a3 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSkuAttrValueMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/bwie-modules/bwie-team/src/main/resources/mapper/TeamMapper.xml b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSkuMapper.xml similarity index 73% rename from bwie-modules/bwie-team/src/main/resources/mapper/TeamMapper.xml rename to bwie-modules/bwie-team/src/main/resources/mapper/GoodsSkuMapper.xml index 187f42b..6c87c68 100644 --- a/bwie-modules/bwie-team/src/main/resources/mapper/TeamMapper.xml +++ b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSkuMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSpuAttrValueMapper.xml b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSpuAttrValueMapper.xml new file mode 100644 index 0000000..0d581ac --- /dev/null +++ b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSpuAttrValueMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSpuImageMapper.xml b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSpuImageMapper.xml new file mode 100644 index 0000000..a93fe3f --- /dev/null +++ b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSpuImageMapper.xml @@ -0,0 +1,9 @@ + + + + + + INSERT INTO `xm_shopping`.`goods_spu_images` (`spu_id`, `url`, `default_status`) VALUES + (#{spuId},#{url},1); + + diff --git a/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSpuMapper.xml b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSpuMapper.xml new file mode 100644 index 0000000..ffc0713 --- /dev/null +++ b/bwie-modules/bwie-team/src/main/resources/mapper/GoodsSpuMapper.xml @@ -0,0 +1,9 @@ + + + + + + INSERT INTO `xm_shopping`.`goods_spu` (`name`, `good_sales`, `good_inventory`, `category_id`, `publish_status`, `keywords`, `good_brief`, `good_unit`, `good_freight`, `update_time`, `create_time`, `is_delete`) VALUES + (#{name},#{goodSales},#{goodgoodInventory},#{categoryId},#{publishStatus},#{keyWords},#{goodBrief},#{goodUnit},#{goodFreight},#{updateTime},#{createTime},#{is_delete}); + + diff --git a/bwie-modules/bwie-team/src/main/resources/mapper/MonitorPer.xml b/bwie-modules/bwie-team/src/main/resources/mapper/MonitorPer.xml new file mode 100644 index 0000000..05f789e --- /dev/null +++ b/bwie-modules/bwie-team/src/main/resources/mapper/MonitorPer.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/bwie-modules/bwie-xxl/src/main/java/com/bwie/xxl/job/Test.java b/bwie-modules/bwie-xxl/src/main/java/com/bwie/xxl/job/Test.java deleted file mode 100644 index e41337c..0000000 --- a/bwie-modules/bwie-xxl/src/main/java/com/bwie/xxl/job/Test.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.bwie.xxl.job; - -import com.xxl.job.core.context.XxlJobHelper; -import com.xxl.job.core.handler.annotation.XxlJob; -import org.springframework.stereotype.Component; - -@Component -public class Test { - - @XxlJob("aaa") - /** - * 2、分片广播任务 - */ - public void shardingJobHandler() throws Exception { - // 分片参数 - int shardIndex = XxlJobHelper.getShardIndex(); - int shardTotal = XxlJobHelper.getShardTotal(); - XxlJobHelper.log("分片参数:当前分片序号 = {}, 总分片数 = {}", shardIndex, shardTotal); - // 业务逻辑 - for (int i = 0; i < shardTotal; i++) { - if (i == shardIndex) { - XxlJobHelper.log("第 {} 片, 命中分片开始处理", i); - } else { - XxlJobHelper.log("第 {} 片, 忽略", i); - } - } - } -} diff --git a/bwie-modules/bwie-xxl/src/main/java/com/bwie/xxl/util/XxlJobConfig.java b/bwie-modules/bwie-xxl/src/main/java/com/bwie/xxl/util/XxlJobConfig.java deleted file mode 100644 index d19aab3..0000000 --- a/bwie-modules/bwie-xxl/src/main/java/com/bwie/xxl/util/XxlJobConfig.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.bwie.xxl.util; - -//import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; -import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * xxl-job config - * - * @author xuxueli 2017-04-28 - */ -@Configuration -public class XxlJobConfig { - private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class); - - @Value("${xxl.job.admin.addresses}") - private String adminAddresses; - - @Value("${xxl.job.accessToken}") - private String accessToken; - - @Value("${xxl.job.executor.appname}") - private String appname; - - @Value("${xxl.job.executor.address}") - private String address; - - @Value("${xxl.job.executor.ip}") - private String ip; - - @Value("${xxl.job.executor.port}") - private int port; - - @Value("${xxl.job.executor.logpath}") - private String logPath; - - @Value("${xxl.job.executor.logretentiondays}") - private int logRetentionDays; - - - @Bean - public XxlJobSpringExecutor xxlJobExecutor() { - logger.info(">>>>>>>>>>> xxl-job config init."); - XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor(); - xxlJobSpringExecutor.setAdminAddresses(adminAddresses); - xxlJobSpringExecutor.setAppname(appname); - xxlJobSpringExecutor.setAddress(address); - xxlJobSpringExecutor.setIp(ip); - xxlJobSpringExecutor.setPort(port); - xxlJobSpringExecutor.setAccessToken(accessToken); - xxlJobSpringExecutor.setLogPath(logPath); - xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays); - - return xxlJobSpringExecutor; - } - - /** - * 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP; - * - * 1、引入依赖: - * - * org.springframework.cloud - * spring-cloud-commons - * ${version} - * - * - * 2、配置文件,或者容器启动变量 - * spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.' - * - * 3、获取IP - * String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress(); - */ - - -} diff --git a/bwie-modules/bwie-xxl/src/main/resources/bootstrap.yml b/bwie-modules/bwie-xxl/src/main/resources/bootstrap.yml deleted file mode 100644 index b00e223..0000000 --- a/bwie-modules/bwie-xxl/src/main/resources/bootstrap.yml +++ /dev/null @@ -1,53 +0,0 @@ -# Tomcat -server: - port: 9003 -# Spring -spring: - main: - allow-circular-references: true - allow-bean-definition-overriding: true - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 - application: - # 应用名称 - name: bwie-xxl - profiles: - # 环境配置 - active: dev - cloud: - nacos: - discovery: - # 服务注册地址 - server-addr: 124.221.30.134:8848 - config: - # 配置中心地址 - server-addr: 124.221.30.134:8848 - # 配置文件格式 - file-extension: yml - # 共享配置 - shared-configs: - - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} - -#开发dev环境 -xxl: - job: - admin: - #xxlJob访问地址 - addresses: http://127.0.0.1:8081/xxl-job-admin - #xxlJob访问令牌(在xxlJob配置文件中自行设置的) - accessToken: jia - executor: - # 执行器注册 [选填]:优先使用该配置作为注册地址,为空时使用内嵌服务 ”IP:PORT“ 作为注册地址。从而更灵活的支持容器类型执行器动态IP和动态映射端口问题。 - address: '' - # 执行器AppName [选填]:执行器心跳注册分组依据;为空则关闭自动注册 - appname: ueana - # 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务"; - ip: '' - # 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999,单机部署多个执行器时,注意要配置不同执行器端口; - port: 9999 - # 执行器运行日志文件存储磁盘路径 [选填] :需要对该路径拥有读写权限;为空则使用默认路径; - logpath: /data/applogs/xxl-job/jobhandler - # 执行器日志文件保存天数 [选填] : 过期日志自动清理, 限制值大于等于3时生效; 否则, 如-1, 关闭自动清理功能; - logretentiondays: 30 - diff --git a/bwie-modules/pom.xml b/bwie-modules/pom.xml index 9a18ffa..4e08578 100644 --- a/bwie-modules/pom.xml +++ b/bwie-modules/pom.xml @@ -13,8 +13,8 @@ pom bwie-system - bwie-xxl bwie-team + bwie-alipay