diff --git a/waynboot-common/src/main/java/com/wayn/common/core/domain/vo/OrderVO.java b/waynboot-common/src/main/java/com/wayn/common/core/domain/vo/OrderVO.java index d682cdc..ebf1ae7 100644 --- a/waynboot-common/src/main/java/com/wayn/common/core/domain/vo/OrderVO.java +++ b/waynboot-common/src/main/java/com/wayn/common/core/domain/vo/OrderVO.java @@ -11,7 +11,7 @@ import java.util.List; public class OrderVO { /** - * 订单ID + * 订单编号 */ private String orderSn; diff --git a/waynboot-common/src/main/java/com/wayn/common/enums/ReturnCodeEnum.java b/waynboot-common/src/main/java/com/wayn/common/enums/ReturnCodeEnum.java index 2ed85c7..fbf71e7 100644 --- a/waynboot-common/src/main/java/com/wayn/common/enums/ReturnCodeEnum.java +++ b/waynboot-common/src/main/java/com/wayn/common/enums/ReturnCodeEnum.java @@ -1,8 +1,11 @@ package com.wayn.common.enums; +import lombok.Getter; + /** * 错误状态码enum */ +@Getter public enum ReturnCodeEnum { // 200,通用操作成功 3xx,资源重定向 4xx,客户端错误 500,通用操作失败 @@ -91,14 +94,6 @@ public enum ReturnCodeEnum { this.msg = msg; } - public int getCode() { - return code; - } - - public String getMsg() { - return msg; - } - public ReturnCodeEnum setMsg(String msg) { this.msg = msg; return this; diff --git a/waynboot-common/src/main/java/com/wayn/common/util/R.java b/waynboot-common/src/main/java/com/wayn/common/util/R.java index f4a73dc..5a4dca7 100644 --- a/waynboot-common/src/main/java/com/wayn/common/util/R.java +++ b/waynboot-common/src/main/java/com/wayn/common/util/R.java @@ -3,6 +3,7 @@ package com.wayn.common.util; import com.alibaba.fastjson2.JSONObject; import com.wayn.common.enums.ReturnCodeEnum; import lombok.Getter; +import lombok.Setter; import org.apache.commons.lang3.builder.ToStringBuilder; import java.io.Serial; @@ -10,14 +11,25 @@ import java.io.Serializable; import java.util.HashMap; import java.util.Map; +@Setter @Getter -public class R implements Serializable { +public class R implements Serializable { @Serial private static final long serialVersionUID = -5316597326293972581L; + /** + * 返回状态码:返回200表示请求接口成功,非200表示请求接口失败 + */ private int code; + /** + * 返回消息 + */ private String msg; - private Map map = new HashMap<>(); + + /** + * 返回数据 + */ + private Map map = new HashMap<>(); public static R success() { R r = new R(); @@ -26,14 +38,7 @@ public class R implements Serializable { return r; } - public static R success(ReturnCodeEnum ReturnCodeEnum) { - R r = new R(); - r.code = ReturnCodeEnum.getCode(); - r.msg = ReturnCodeEnum.getMsg(); - return r; - } - - public static R success(Object data) { + public static R success(T data) { R r = new R(); r.code = ReturnCodeEnum.SUCCESS.getCode(); r.msg = ReturnCodeEnum.SUCCESS.getMsg(); @@ -71,23 +76,11 @@ public class R implements Serializable { return r; } - public R add(String key, Object value) { + public R add(String key, T value) { map.put(key, value); return this; } - public void setCode(int code) { - this.code = code; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public void setMap(Map map) { - this.map = map; - } - @Override public String toString() { return new ToStringBuilder(this) diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/AddressController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/AddressController.java index e9c8f0d..d7786ec 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/AddressController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/AddressController.java @@ -11,6 +11,12 @@ import org.springframework.web.bind.annotation.*; import java.util.Date; import java.util.Objects; +/** + * 用户地址接口 + * + * @author wayn + * @since 2020-08-03 + */ @RestController @AllArgsConstructor @RequestMapping("address") @@ -18,12 +24,22 @@ public class AddressController { private IAddressService iAddressService; + /** + * 地址列表 + * + * @return R + */ @GetMapping("list") public R list() { Long memberId = MobileSecurityUtils.getUserId(); return R.success().add("data", iAddressService.list(new QueryWrapper
().eq("member_id", memberId))); } + /** + * 添加地址 + * + * @return R + */ @PostMapping public R add(@RequestBody Address address) { Long memberId = MobileSecurityUtils.getUserId(); @@ -39,6 +55,11 @@ public class AddressController { return R.result(iAddressService.save(address)); } + /** + * 删除地址 + * + * @return R + */ @DeleteMapping("{addressId}") public R delete(@PathVariable Long addressId) { return R.result(iAddressService.removeById(addressId)); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CartController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CartController.java index cbd4564..d8feb9b 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CartController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CartController.java @@ -1,7 +1,6 @@ package com.wayn.mobile.api.controller; -import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.wayn.common.base.controller.BaseController; @@ -18,7 +17,7 @@ import java.math.BigDecimal; import java.util.List; /** - * 购物车商品表 前端控制器 + * 购物车接口 * * @author wayn * @since 2020-08-03 @@ -31,8 +30,11 @@ public class CartController extends BaseController { private ICartService iCartService; - private WaynConfig waynConfig; - + /** + * 购物车列表 + * + * @return + */ @GetMapping("list") public R list() { Long userId = MobileSecurityUtils.getUserId(); @@ -41,36 +43,75 @@ public class CartController extends BaseController { return list; } + /** + * 添加购物车 + * + * @return R + */ @PostMapping public R add(@RequestBody Cart cart) { return iCartService.add(cart); } + /** + * 往购物车中添加默认商品 + * + * @return R + */ @PostMapping("addDefaultGoodsProduct") public R addDefaultGoodsProduct(@RequestBody Cart cart) { return iCartService.addDefaultGoodsProduct(cart); } + /** + * 更新购物车 + * + * @param cart 更新参数 + * @return R + */ @PutMapping public R update(@RequestBody Cart cart) { return R.result(iCartService.updateById(cart)); } + /** + * 修改购物车商品数量 + * + * @param cartId 购物车id + * @param number 更新数量 + * @return R + */ @PostMapping("changeNum/{cartId}/{number}") public R changeNum(@PathVariable Long cartId, @PathVariable Integer number) { return R.result(iCartService.changeNum(cartId, number)); } + /** + * 删除购物车商品 + * + * @param cartId 购物车id + * @return R + */ @DeleteMapping("{cartId}") public R delete(@PathVariable Long cartId) { return R.result(iCartService.removeById(cartId)); } + /** + * 统计购物车中现有商品数量 + * + * @return R + */ @GetMapping("goodsCount") public R goodsCount() { return iCartService.goodsCount(); } + /** + * 统计购物车中已勾选商品数量 + * + * @return R + */ @PostMapping("getCheckedGoods") public R getCheckedGoods() { Long userId = MobileSecurityUtils.getUserId(); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CommentController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CommentController.java index e419b39..26c762a 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CommentController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/CommentController.java @@ -16,6 +16,12 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +/** + * 用户评论接口 + * + * @author wayn + * @since 2024/1/15 + */ @RestController @AllArgsConstructor @RequestMapping("comment") @@ -23,6 +29,13 @@ public class CommentController extends BaseController { private ICommentService iCommentService; + /** + * 商品评论列表 + * + * @param tagType 评论标签类型, 1代表好评 2代表中评 3代表差评 + * @param goodsId 商品id + * @return R + */ @PostMapping("list") public R list(Integer tagType, Long goodsId) { Page page = getPage(); @@ -30,12 +43,24 @@ public class CommentController extends BaseController { return R.success().add("page", commentIPage); } + /** + * 添加评论 + * + * @param commentVO 评论参数 + * @return R + */ @PostMapping public R addComment(@Valid @RequestBody CommentVO commentVO) { commentVO.setUserId(MobileSecurityUtils.getUserId()); return R.success().add("data", iCommentService.saveComment(commentVO)); } + /** + * 统计好评、中评、差评数量 + * + * @param goodsId 商品id + * @return R + */ @PostMapping("tagNum") public R tagNum(Long goodsId) { CommentTagNumVO commentTagNumVO = iCommentService.selectTagNum(goodsId); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/DiamondController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/DiamondController.java index 150647f..bb764b2 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/DiamondController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/DiamondController.java @@ -15,6 +15,12 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; +/** + * 金刚区接口 + * + * @author wayn + * @since 2024/1/15 + */ @RestController @AllArgsConstructor @RequestMapping("diamond") @@ -24,6 +30,12 @@ public class DiamondController extends BaseController { private DiamondJumpContext diamondJumpContext; + /** + * 金刚区跳转 + * + * @param diamondId 金刚区id + * @return R + */ @GetMapping("getGoodsList") public R getGoodsList(Long diamondId) { Page page = getPage(); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/GoodsController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/GoodsController.java index 15ca2db..be8f196 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/GoodsController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/GoodsController.java @@ -8,6 +8,12 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +/** + * 商品接口 + * + * @author wayn + * @since 2024/1/15 + */ @RestController @AllArgsConstructor @RequestMapping("goods") @@ -15,6 +21,12 @@ public class GoodsController { private IGoodsDetailService iGoodsDetailService; + /** + * 商品详情 + * + * @param goodsId 商品id + * @return R + */ @GetMapping("detail/{goodsId}") public R detail(@PathVariable Long goodsId) { return R.success(iGoodsDetailService.getGoodsDetailData(goodsId)); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/HomeController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/HomeController.java index d7343d5..575d6cd 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/HomeController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/HomeController.java @@ -10,6 +10,9 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +/** + * 首页接口 + */ @RestController @AllArgsConstructor @RequestMapping("home") diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/LoginController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/LoginController.java index f4dd5ce..cd84ca2 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/LoginController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/LoginController.java @@ -30,6 +30,12 @@ import java.util.Date; import static com.wayn.common.enums.ReturnCodeEnum.*; +/** + * 登录相关接口 + * + * @author wayn + * @since 2024/1/15 + */ @RestController @AllArgsConstructor public class LoginController { @@ -40,6 +46,12 @@ public class LoginController { private IMailConfigService mailConfigService; private ThreadPoolTaskExecutor commonThreadPoolTaskExecutor; + /** + * 用户登录 + * + * @param loginObj 登录参数 + * @return R + */ @PostMapping("/login") public R login(@RequestBody LoginObj loginObj) { // 生成令牌 @@ -47,6 +59,12 @@ public class LoginController { return R.success().add(SysConstants.TOKEN, token); } + /** + * 用户注册 + * + * @param registryObj 注册参数 + * @return R + */ @PostMapping("/registry") public R registry(@RequestBody RegistryObj registryObj) { if (!StringUtils.equalsIgnoreCase(registryObj.getPassword(), registryObj.getConfirmPassword())) { @@ -95,6 +113,11 @@ public class LoginController { return R.result(iMemberService.save(member)); } + /** + * 验证码 + * + * @return R + */ @ResponseBody @RequestMapping("/captcha") public R captcha() { @@ -110,6 +133,12 @@ public class LoginController { return R.success().add("captchaKey", key).add("captchaImg", specCaptcha.toBase64()); } + /** + * 发送邮箱 + * + * @param registryObj 注册参数 + * @return R + */ @PostMapping("/sendEmailCode") public R sendEmailCode(@RequestBody RegistryObj registryObj) { // 判断图形验证码是否正确 @@ -140,7 +169,7 @@ public class LoginController { // 生成邮箱验证码唯一key String key = RedisKeyEnum.EMAIL_KEY_CACHE.getKey(IdUtil.getUid()); // 存入redis并设置过期时间为20分钟 - redisCache.setCacheObject(key, verCode + "_" + mobile, RedisKeyEnum.EMAIL_KEY_CACHE.getExpireSecond()); + redisCache.setCacheObject(key, verCode + "_" + mobile, RedisKeyEnum.EMAIL_KEY_CACHE.getExpireSecond()); commonThreadPoolTaskExecutor.execute(() -> { EmailConfig emailConfig = mailConfigService.getById(1L); SendMailVO sendMailVO = new SendMailVO(); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderController.java index 4fbe3df..bab825e 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderController.java @@ -11,6 +11,13 @@ import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.springframework.web.bind.annotation.*; + +/** + * 订单接口 + * + * @author wayn + * @since 2024/1/15 + */ @Slf4j @RestController @AllArgsConstructor @@ -19,47 +26,89 @@ public class OrderController extends BaseController { private IMobileOrderService iMobileOrderService; + /** + * 根据订单编号获取订单详情 + * + * @param orderSn 订单编号 + * @return R + */ @GetMapping("detail/{orderSn}") public R detail(@PathVariable String orderSn) { return iMobileOrderService.getOrderDetailByOrderSn(orderSn); } + /** + * 根据订单转状态展示用户订单列表 + * + * @param showType 展示类型 0全部 1待付款订单 2待发货订单 3待收货订单 4待评价订单 + * @return + */ @GetMapping("list") public R list(@RequestParam(defaultValue = "0") Integer showType) { Page page = getPage(); return iMobileOrderService.selectListPage(page, showType); } - @PostMapping("info") - public R info(@RequestBody OrderVO orderVO) { - return R.success().add("data", iMobileOrderService.getById(orderVO.getOrderSn())); - } - + /** + * 订单状态统计 + * + * @return R + */ @PostMapping("statusCount") public R statusCount() { return iMobileOrderService.statusCount(); } + /** + * 下单接口 + * + * @param orderVO 订单参数 + * @return R + */ @PostMapping("submit") public R submit(@RequestBody OrderVO orderVO) throws Exception { return iMobileOrderService.asyncSubmit(orderVO); } + /** + * 下单结果查询 + * + * @param orderSn 订单编号 + * @return R + */ @GetMapping("searchResult/{orderSn}") public R searchResult(@PathVariable String orderSn) { return iMobileOrderService.searchResult(orderSn); } + /** + * 取消订单 + * + * @param orderId 订单id + * @return R + */ @PostMapping("cancel/{orderId}") public R cancel(@PathVariable Long orderId) { return iMobileOrderService.cancel(orderId); } + /** + * 确认提交订单 + * + * @param orderId 订单id + * @return R + */ @PostMapping("confirm/{orderId}") public R confirm(@PathVariable Long orderId) { return iMobileOrderService.confirm(orderId); } + /** + * 删除订单 + * + * @param orderId 订单id + * @return R + */ @PostMapping("delete/{orderId}") public R delete(@PathVariable Long orderId) { return iMobileOrderService.delete(orderId); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderGoodsController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderGoodsController.java deleted file mode 100644 index 6b24f16..0000000 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderGoodsController.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.wayn.mobile.api.controller; - - -import com.wayn.common.base.controller.BaseController; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -/** - * 订单商品表 前端控制器 - * - * @author wayn - * @since 2020-08-11 - */ -@RestController -@RequestMapping("orderGoods") -public class OrderGoodsController extends BaseController { - -} diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderRefundController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderRefundController.java index 9fac596..6b3ea4c 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderRefundController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/OrderRefundController.java @@ -13,6 +13,12 @@ import org.springframework.web.bind.annotation.*; import java.io.UnsupportedEncodingException; +/** + * 退款接口 + * + * @author wayn + * @since 2024/1/15 + */ @Slf4j @RestController @AllArgsConstructor @@ -21,6 +27,11 @@ public class OrderRefundController extends BaseController { private IPayService payService; + /** + * 退款 + * @param orderId 订单id + * @return R + */ @PostMapping("{orderId}") public R refund(@PathVariable Long orderId) throws UnsupportedEncodingException, AlipayApiException, WxPayException { return payService.refund(orderId); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/PayCallbackController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/PayCallbackController.java index 1ff4749..b0b83b2 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/PayCallbackController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/PayCallbackController.java @@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.*; import java.io.UnsupportedEncodingException; +/** + * 支付成功回调接口 + */ @Slf4j @RestController @AllArgsConstructor @@ -21,12 +24,24 @@ public class PayCallbackController extends BaseController { private IPayService payService; + /** + * 微信支付回调 + * @param request + * @param response + * @return string + */ @PostMapping("wxPayNotify") public String wxPayNotify(HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException { log.info("微信paySuccess通知数据记录:req:{}", JSONObject.toJSONString(request.getParameterMap())); return payService.wxPayNotify(request, response); } + /** + * 支付宝支付回调 + * @param request + * @param response + * @return string + */ @PostMapping("aliPayNotify") public String aliPayNotify(HttpServletRequest request, HttpServletResponse response) throws AlipayApiException, UnsupportedEncodingException { log.info("支付宝paySuccess通知数据记录:req: {}", JSONObject.toJSONString(request.getParameterMap())); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/PayController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/PayController.java index 46c2f40..97cc444 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/PayController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/PayController.java @@ -14,6 +14,9 @@ import org.springframework.web.bind.annotation.RestController; import java.io.UnsupportedEncodingException; +/** + * 支付接口 + */ @Slf4j @RestController @AllArgsConstructor diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/SearchController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/SearchController.java index bad85b7..0e500ee 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/SearchController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/SearchController.java @@ -3,7 +3,6 @@ package com.wayn.mobile.api.controller; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.wayn.common.base.controller.BaseController; import com.wayn.common.core.domain.shop.Goods; @@ -17,7 +16,6 @@ import com.wayn.mobile.api.domain.SearchHistory; import com.wayn.mobile.api.service.ISearchHistoryService; import com.wayn.mobile.framework.manager.thread.AsyncManager; import com.wayn.mobile.framework.security.util.MobileSecurityUtils; -import jakarta.validation.constraints.NotEmpty; import lombok.AllArgsConstructor; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -44,7 +42,7 @@ import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; /** - * 搜索历史表 前端控制器 + * 搜索接口 * * @author wayn * @since 2020-09-23 @@ -64,9 +62,9 @@ public class SearchController extends BaseController { /** * 商城搜索建议 - * @param searchVO - * @return - * @throws IOException + * + * @param searchVO 搜索参数 + * @return R */ @GetMapping("sugguest") public R sugguest(SearchVO searchVO) throws IOException { @@ -85,9 +83,9 @@ public class SearchController extends BaseController { /** * 商城搜索结果 - * @param searchVO - * @return - * @throws IOException + * + * @param searchVO 搜索参数 + * @return R */ @GetMapping("result") public R result(SearchVO searchVO) throws IOException { @@ -180,6 +178,7 @@ public class SearchController extends BaseController { /** * 热门搜索 + * * @return R */ @GetMapping("hotKeywords") @@ -192,9 +191,6 @@ public class SearchController extends BaseController { List defaultKeyword = iKeywordService.list(new QueryWrapper().eq("is_default", true).orderByAsc("sort")); List defaultStrings = defaultKeyword.stream().map(Keyword::getKeyword).collect(Collectors.toList()); R r = R.success(); - if (CollectionUtils.isNotEmpty(hotStrings)) { - r.add("data", hotStrings); - } r.add("data", hotStrings); if (CollectionUtils.isNotEmpty(defaultStrings)) { r.add("default", defaultStrings.get(0)); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/SearchHistoryController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/SearchHistoryController.java index b8fecdc..ad8aa50 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/SearchHistoryController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/SearchHistoryController.java @@ -11,7 +11,7 @@ import lombok.AllArgsConstructor; import org.springframework.web.bind.annotation.*; /** - * 搜索历史表 前端控制器 + * 搜索历史接口 * * @author wayn * @since 2020-09-23 @@ -28,6 +28,12 @@ public class SearchHistoryController extends BaseController { return R.success().add("data", iSearchHistoryService.selectList()); } + /** + * 添加搜索历史 + * + * @param searchHistory 搜索历史参数 + * @return R + */ @PostMapping public R add(@RequestBody SearchHistory searchHistory) { Long memberId = MobileSecurityUtils.getUserId(); @@ -35,11 +41,22 @@ public class SearchHistoryController extends BaseController { return R.result(iSearchHistoryService.save(searchHistory)); } + /** + * 删除搜索历史 + * + * @param id 搜索历史id + * @return R + */ @DeleteMapping("{id}") public R delete(@PathVariable Long id) { return R.result(iSearchHistoryService.removeById(id)); } + /** + * 删除当前用户所有搜索历史 + * + * @return R + */ @DeleteMapping("all") public R delete() { Long memberId = MobileSecurityUtils.getUserId(); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/TestController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/TestController.java deleted file mode 100644 index 24fd89c..0000000 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/TestController.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.wayn.mobile.api.controller; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -@RestController -@RequestMapping("test") -public class TestController { - - @GetMapping("shutdown") - public String gracefullyShutdown() throws InterruptedException { - Thread.sleep(15000); - return "gracefully shutdown!"; - } -} diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/UserController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/UserController.java index 7264df2..395ee56 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/UserController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/UserController.java @@ -28,6 +28,9 @@ import java.util.Collections; import java.util.Objects; import java.util.concurrent.TimeUnit; +/** + * 用户接口 + */ @RestController @AllArgsConstructor @RequestMapping("user") @@ -41,12 +44,24 @@ public class UserController { private IMailConfigService mailConfigService; + /** + * 获取用户信息 + * 需要再 header 中添加 Authorization 参数 + * + * @return + */ @GetMapping("info") public R getInfo() { LoginUserDetail loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); return R.success().add("info", loginUser.getMember()); } + /** + * 获取用户资料 + * + * @param profileVO 用户资料参数 + * @return R + */ @PostMapping("profile") public R profile(@RequestBody ProfileVO profileVO) { String nickname = profileVO.getNickname(); @@ -76,6 +91,12 @@ public class UserController { return R.result(iMemberService.updateById(member)); } + /** + * 发送邮件 + * + * @param registryObj 发送邮件参数 + * @return R + */ @PostMapping("/sendEmailCode") public R sendEmailCode(@RequestBody RegistryObj registryObj) { SpecCaptcha specCaptcha = new SpecCaptcha(80, 32, 4); @@ -92,6 +113,12 @@ public class UserController { return R.success().add("key", key); } + /** + * 上传头像 + * + * @param avatar 用户头像地址 + * @return R + */ @PostMapping("uploadAvatar") public R uploadAvatar(String avatar) { LoginUserDetail loginUser = tokenService.getLoginUser(ServletUtils.getRequest()); @@ -109,6 +136,12 @@ public class UserController { return R.result(true).add("userInfo", member); } + /** + * 更新用户密码 + * + * @param registryObj 更新参数 + * @return R + */ @PostMapping("updatePassword") public R updatePassword(@RequestBody RegistryObj registryObj) { if (!StringUtils.equalsIgnoreCase(registryObj.getPassword(), registryObj.getConfirmPassword())) { diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/EmailController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/EmailController.java index f108d4f..78cf681 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/EmailController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/EmailController.java @@ -12,6 +12,9 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; +/** + * 邮件回调接口 + */ @RestController @AllArgsConstructor @RequestMapping("callback/email") @@ -19,6 +22,13 @@ public class EmailController { private IMailConfigService mailConfigService; + /** + * 发送邮件 + * @param subject 标题 + * @param content 内容 + * @param tos 接收人 + * @return R + */ @PostMapping public R sendEmail(String subject, String content, String tos) { EmailConfig emailConfig = mailConfigService.getById(1L); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/SubmitOrderController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/SubmitOrderController.java index edf8306..fa83dae 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/SubmitOrderController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/SubmitOrderController.java @@ -13,6 +13,9 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +/** + * 下单回调接口 + */ @Slf4j @RestController @AllArgsConstructor @@ -22,6 +25,11 @@ public class SubmitOrderController { private IMobileOrderService iMobileOrderService; private RedisCache redisCache; + /** + * 回调下单 + * @param order 订单数据传输对象 + * @return R + */ @PostMapping("submit") public R submit(String order) { log.info("callback order request is {}", order); diff --git a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/UnpaidOrderController.java b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/UnpaidOrderController.java index 37de703..7dcd77f 100644 --- a/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/UnpaidOrderController.java +++ b/waynboot-mobile-api/src/main/java/com/wayn/mobile/api/controller/callback/UnpaidOrderController.java @@ -7,6 +7,9 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +/** + * 未支付订单取消回调 + */ @RestController @AllArgsConstructor @RequestMapping("callback/order") @@ -14,6 +17,12 @@ public class UnpaidOrderController { private IOrderUnpaidService orderUnpaidService; + /** + * 未支付订单取消 + * + * @param orderSn 订单编号 + * @return R + */ @PostMapping("unpaid") public R unpaid(String orderSn) { return orderUnpaidService.unpaid(orderSn);