Commit a5c2aff4 authored by Junling Bu's avatar Junling Bu
Browse files

chore[后端服务]: 后端服务代码基于IDEA的reformat code工具格式化代码,但是mybatis generator生成的代码除外。

parent 556f269d
......@@ -3,7 +3,6 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.core.util.JacksonUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
......@@ -19,7 +18,6 @@ import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -100,19 +98,19 @@ public class AdminGrouponController {
private Object validate(LitemallGrouponRules grouponRules) {
Integer goodsId = grouponRules.getGoodsId();
if(goodsId == null){
if (goodsId == null) {
return ResponseUtil.badArgument();
}
BigDecimal discount = grouponRules.getDiscount();
if(discount == null){
if (discount == null) {
return ResponseUtil.badArgument();
}
Integer discountMember = grouponRules.getDiscountMember();
if(discountMember == null){
if (discountMember == null) {
return ResponseUtil.badArgument();
}
LocalDateTime expireTime = grouponRules.getExpireTime();
if(expireTime == null){
if (expireTime == null) {
return ResponseUtil.badArgument();
}
......@@ -126,7 +124,7 @@ public class AdminGrouponController {
}
Object error = validate(grouponRules);
if(error != null){
if (error != null) {
return error;
}
......@@ -139,7 +137,7 @@ public class AdminGrouponController {
grouponRules.setGoodsName(goods.getName());
grouponRules.setPicUrl(goods.getPicUrl());
if(rulesService.updateById(grouponRules) == 0){
if (rulesService.updateById(grouponRules) == 0) {
return ResponseUtil.updatedDataFailed();
}
......@@ -154,7 +152,7 @@ public class AdminGrouponController {
}
Object error = validate(grouponRules);
if(error != null){
if (error != null) {
return error;
}
......@@ -180,7 +178,7 @@ public class AdminGrouponController {
}
Integer id = grouponRules.getId();
if(id == null){
if (id == null) {
return ResponseUtil.badArgument();
}
......
......@@ -3,13 +3,16 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.LitemallSearchHistory;
import org.linlinjava.litemall.db.service.LitemallSearchHistoryService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
......@@ -29,8 +32,8 @@ public class AdminHistoryController {
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order){
if(adminId == null){
@Order @RequestParam(defaultValue = "desc") String order) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......
......@@ -12,7 +12,7 @@ public class AdminIndexController {
private final Log logger = LogFactory.getLog(AdminIndexController.class);
@RequestMapping("/index")
public Object index(){
public Object index() {
return ResponseUtil.ok("hello world, this is admin service");
}
......
......@@ -3,18 +3,17 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.LitemallIssue;
import org.linlinjava.litemall.db.service.LitemallIssueService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -34,8 +33,8 @@ public class AdminIssueController {
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order){
if(adminId == null){
@Order @RequestParam(defaultValue = "desc") String order) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......@@ -50,23 +49,23 @@ public class AdminIssueController {
private Object validate(LitemallIssue issue) {
String question = issue.getQuestion();
if(StringUtils.isEmpty(question)){
if (StringUtils.isEmpty(question)) {
return ResponseUtil.badArgument();
}
String answer = issue.getAnswer();
if(StringUtils.isEmpty(answer)){
if (StringUtils.isEmpty(answer)) {
return ResponseUtil.badArgument();
}
return null;
}
@PostMapping("/create")
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallIssue issue){
if(adminId == null){
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallIssue issue) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Object error = validate(issue);
if(error != null){
if (error != null) {
return error;
}
issueService.add(issue);
......@@ -74,8 +73,8 @@ public class AdminIssueController {
}
@GetMapping("/read")
public Object read(@LoginAdmin Integer adminId, @NotNull Integer id){
if(adminId == null){
public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......@@ -84,15 +83,15 @@ public class AdminIssueController {
}
@PostMapping("/update")
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallIssue issue){
if(adminId == null){
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallIssue issue) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Object error = validate(issue);
if(error != null){
if (error != null) {
return error;
}
if(issueService.updateById(issue) == 0){
if (issueService.updateById(issue) == 0) {
return ResponseUtil.updatedDataFailed();
}
......@@ -100,12 +99,12 @@ public class AdminIssueController {
}
@PostMapping("/delete")
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallIssue issue){
if(adminId == null){
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallIssue issue) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Integer id = issue.getId();
if(id == null){
if (id == null) {
return ResponseUtil.badArgument();
}
issueService.deleteById(id);
......
......@@ -3,18 +3,17 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.LitemallKeyword;
import org.linlinjava.litemall.db.service.LitemallKeywordService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -34,8 +33,8 @@ public class AdminKeywordController {
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order){
if(adminId == null){
@Order @RequestParam(defaultValue = "desc") String order) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......@@ -61,12 +60,12 @@ public class AdminKeywordController {
}
@PostMapping("/create")
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallKeyword keywords){
if(adminId == null){
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallKeyword keywords) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Object error = validate(keywords);
if(error != null){
if (error != null) {
return error;
}
keywordService.add(keywords);
......@@ -74,8 +73,8 @@ public class AdminKeywordController {
}
@GetMapping("/read")
public Object read(@LoginAdmin Integer adminId, @NotNull Integer id){
if(adminId == null){
public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......@@ -84,27 +83,27 @@ public class AdminKeywordController {
}
@PostMapping("/update")
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallKeyword keywords){
if(adminId == null){
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallKeyword keywords) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Object error = validate(keywords);
if(error != null){
if (error != null) {
return error;
}
if(keywordService.updateById(keywords) == 0){
if (keywordService.updateById(keywords) == 0) {
return ResponseUtil.updatedDataFailed();
}
return ResponseUtil.ok(keywords);
}
@PostMapping("/delete")
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallKeyword keyword){
if(adminId == null){
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallKeyword keyword) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Integer id = keyword.getId();
if(id == null){
if (id == null) {
return ResponseUtil.badArgument();
}
keywordService.deleteById(id);
......
......@@ -6,12 +6,12 @@ import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.core.notify.NotifyService;
import org.linlinjava.litemall.core.notify.NotifyType;
import org.linlinjava.litemall.core.util.JacksonUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.*;
import org.linlinjava.litemall.db.service.*;
import org.linlinjava.litemall.db.util.OrderUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.PlatformTransactionManager;
......@@ -25,7 +25,6 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -60,7 +59,7 @@ public class AdminOrderController {
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order){
@Order @RequestParam(defaultValue = "desc") String order) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......@@ -135,7 +134,7 @@ public class AdminOrderController {
try {
// 设置订单取消状态
order.setOrderStatus(OrderUtil.STATUS_REFUND_CONFIRM);
if(orderService.updateWithOptimisticLocker(order) == 0) {
if (orderService.updateWithOptimisticLocker(order) == 0) {
throw new Exception("跟新数据已失效");
}
......@@ -146,7 +145,7 @@ public class AdminOrderController {
LitemallGoodsProduct product = productService.findById(productId);
Integer number = product.getNumber() + orderGoods.getNumber();
product.setNumber(number);
if(productService.updateById(product) == 0){
if (productService.updateById(product) == 0) {
throw new Exception("跟新数据失败");
}
}
......@@ -209,7 +208,7 @@ public class AdminOrderController {
order.setShipSn(shipSn);
order.setShipChannel(shipChannel);
order.setShipTime(LocalDateTime.now());
if(orderService.updateWithOptimisticLocker(order) == 0){
if (orderService.updateWithOptimisticLocker(order) == 0) {
return ResponseUtil.updatedDateExpired();
}
......@@ -226,7 +225,7 @@ public class AdminOrderController {
* 回复订单商品
*
* @param adminId 管理员ID
* @param body 订单信息,{ orderId:xxx }
* @param body 订单信息,{ orderId:xxx }
* @return 订单操作结果
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
......@@ -238,24 +237,24 @@ public class AdminOrderController {
}
Integer commentId = JacksonUtil.parseInteger(body, "commentId");
if(commentId == null || commentId == 0){
if (commentId == null || commentId == 0) {
return ResponseUtil.badArgument();
}
// 目前只支持回复一次
if(commentService.findById(commentId) != null){
if (commentService.findById(commentId) != null) {
return ResponseUtil.fail(404, "订单商品已回复!");
}
String content = JacksonUtil.parseString(body, "content");
if(StringUtils.isEmpty(content)){
if (StringUtils.isEmpty(content)) {
return ResponseUtil.badArgument();
}
// 创建评价回复
LitemallComment comment = new LitemallComment();
comment.setType((byte)2);
comment.setType((byte) 2);
comment.setValueId(commentId);
comment.setContent(content);
comment.setUserId(0); // 评价回复没有用
comment.setStar((short)0); // 评价回复没有用
comment.setStar((short) 0); // 评价回复没有用
comment.setHasPicture(false); // 评价回复没有用
comment.setPicUrls(new String[]{}); // 评价回复没有用
commentService.save(comment);
......@@ -294,7 +293,7 @@ public class AdminOrderController {
// 设置订单已取消状态
order.setOrderStatus(OrderUtil.STATUS_AUTO_CANCEL);
order.setEndTime(LocalDateTime.now());
if(orderService.updateWithOptimisticLocker(order) == 0){
if (orderService.updateWithOptimisticLocker(order) == 0) {
throw new Exception("跟新数据已失效");
}
......@@ -306,7 +305,7 @@ public class AdminOrderController {
LitemallGoodsProduct product = productService.findById(productId);
Integer number = product.getNumber() + orderGoods.getNumber();
product.setNumber(number);
if(productService.updateById(product) == 0){
if (productService.updateById(product) == 0) {
throw new Exception("跟新数据失败");
}
}
......@@ -353,10 +352,9 @@ public class AdminOrderController {
// 设置订单已取消状态
order.setOrderStatus(OrderUtil.STATUS_AUTO_CONFIRM);
order.setConfirmTime(now);
if(orderService.updateWithOptimisticLocker(order) == 0){
if (orderService.updateWithOptimisticLocker(order) == 0) {
logger.info("订单 ID=" + order.getId() + " 数据已经更新,放弃自动确认收货");
}
else{
} else {
logger.info("订单 ID=" + order.getId() + " 已经超期自动确认收货");
}
}
......@@ -375,17 +373,17 @@ public class AdminOrderController {
LocalDateTime now = LocalDateTime.now();
List<LitemallOrder> orderList = orderService.queryComment();
for (LitemallOrder order : orderList) {
LocalDateTime confirm = order.getConfirmTime();
LocalDateTime confirm = order.getConfirmTime();
LocalDateTime expired = confirm.plusDays(7);
if (expired.isAfter(now)) {
continue;
}
order.setComments((short)0);
order.setComments((short) 0);
orderService.updateWithOptimisticLocker(order);
List<LitemallOrderGoods> orderGoodsList = orderGoodsService.queryByOid(order.getId());
for(LitemallOrderGoods orderGoods : orderGoodsList){
for (LitemallOrderGoods orderGoods : orderGoodsList) {
orderGoods.setComment(-1);
orderGoodsService.updateById(orderGoods);
}
......
......@@ -11,7 +11,10 @@ import org.linlinjava.litemall.db.service.LitemallAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/admin/profile")
......@@ -23,24 +26,24 @@ public class AdminProfileController {
private LitemallAdminService adminService;
@PostMapping("/password")
public Object create(@LoginAdmin Integer adminId, @RequestBody String body){
if(adminId == null){
public Object create(@LoginAdmin Integer adminId, @RequestBody String body) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
String oldPassword = JacksonUtil.parseString(body, "oldPassword");
String newPassword = JacksonUtil.parseString(body, "newPassword");
if(StringUtils.isEmpty(oldPassword)){
if (StringUtils.isEmpty(oldPassword)) {
return ResponseUtil.badArgument();
}
if(StringUtils.isEmpty(newPassword)){
if (StringUtils.isEmpty(newPassword)) {
return ResponseUtil.badArgument();
}
LitemallAdmin admin = adminService.findAdmin(adminId);
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
if(!encoder.matches(oldPassword, admin.getPassword())){
if (!encoder.matches(oldPassword, admin.getPassword())) {
return ResponseUtil.fail(405, "账号密码不对");
}
......
......@@ -3,11 +3,11 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.LitemallRegion;
import org.linlinjava.litemall.db.service.LitemallRegionService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -31,7 +31,7 @@ public class AdminRegionController {
@GetMapping("/clist")
public Object clist(@LoginAdmin Integer adminId, @NotNull Integer id) {
if(adminId == null){
if (adminId == null) {
return ResponseUtil.unlogin();
}
......@@ -45,9 +45,9 @@ public class AdminRegionController {
String name, Integer code,
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort (accepts={"id"}) @RequestParam(defaultValue = "id") String sort,
@Order @RequestParam(defaultValue = "desc") String order){
if(adminId == null){
@Sort(accepts = {"id"}) @RequestParam(defaultValue = "id") String sort,
@Order @RequestParam(defaultValue = "desc") String order) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......
......@@ -5,14 +5,13 @@ import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.admin.util.StatVo;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.dao.StatMapper;
import org.linlinjava.litemall.db.service.LitemallOrderService;
import org.linlinjava.litemall.db.service.StatService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -26,8 +25,8 @@ public class AdminStatController {
private StatService statService;
@GetMapping("/user")
public Object statUser(@LoginAdmin Integer adminId){
if(adminId == null){
public Object statUser(@LoginAdmin Integer adminId) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......@@ -41,8 +40,8 @@ public class AdminStatController {
}
@GetMapping("/order")
public Object statOrder(@LoginAdmin Integer adminId){
if(adminId == null){
public Object statOrder(@LoginAdmin Integer adminId) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......@@ -56,8 +55,8 @@ public class AdminStatController {
}
@GetMapping("/goods")
public Object statGoods(@LoginAdmin Integer adminId){
if(adminId == null){
public Object statGoods(@LoginAdmin Integer adminId) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......
......@@ -77,7 +77,7 @@ public class AdminStorageController {
if (adminId == null) {
return ResponseUtil.unlogin();
}
if(litemallStorageService.update(litemallStorage) == 0){
if (litemallStorageService.update(litemallStorage) == 0) {
return ResponseUtil.updatedDataFailed();
}
return ResponseUtil.ok(litemallStorage);
......@@ -89,7 +89,7 @@ public class AdminStorageController {
return ResponseUtil.unlogin();
}
String key = litemallStorage.getKey();
if(StringUtils.isEmpty(key)){
if (StringUtils.isEmpty(key)) {
return ResponseUtil.badArgument();
}
litemallStorageService.deleteByKey(key);
......
......@@ -3,11 +3,11 @@ package org.linlinjava.litemall.admin.web;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.LitemallTopic;
import org.linlinjava.litemall.db.service.LitemallTopicService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
......@@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -35,8 +34,8 @@ public class AdminTopicController {
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order){
if(adminId == null){
@Order @RequestParam(defaultValue = "desc") String order) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......@@ -66,12 +65,12 @@ public class AdminTopicController {
}
@PostMapping("/create")
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallTopic topic){
if(adminId == null){
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallTopic topic) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Object error = validate(topic);
if(error != null){
if (error != null) {
return error;
}
topicService.add(topic);
......@@ -79,8 +78,8 @@ public class AdminTopicController {
}
@GetMapping("/read")
public Object read(@LoginAdmin Integer adminId, @NotNull Integer id){
if(adminId == null){
public Object read(@LoginAdmin Integer adminId, @NotNull Integer id) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
......@@ -89,23 +88,23 @@ public class AdminTopicController {
}
@PostMapping("/update")
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallTopic topic){
if(adminId == null){
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallTopic topic) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Object error = validate(topic);
if(error != null){
if (error != null) {
return error;
}
if(topicService.updateById(topic) == 0){
if (topicService.updateById(topic) == 0) {
return ResponseUtil.updatedDataFailed();
}
return ResponseUtil.ok(topic);
}
@PostMapping("/delete")
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallTopic topic){
if(adminId == null){
public Object delete(@LoginAdmin Integer adminId, @RequestBody LitemallTopic topic) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
topicService.deleteById(topic.getId());
......
package org.linlinjava.litemall.admin.web;
import com.github.pagehelper.util.StringUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.admin.annotation.LoginAdmin;
import org.linlinjava.litemall.core.util.RegexUtil;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.util.bcrypt.BCryptPasswordEncoder;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.db.domain.LitemallUser;
import org.linlinjava.litemall.db.service.LitemallUserService;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotEmpty;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -37,8 +35,8 @@ public class AdminUserController {
@RequestParam(defaultValue = "1") Integer page,
@RequestParam(defaultValue = "10") Integer limit,
@Sort @RequestParam(defaultValue = "add_time") String sort,
@Order @RequestParam(defaultValue = "desc") String order){
if(adminId == null){
@Order @RequestParam(defaultValue = "desc") String order) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
List<LitemallUser> userList = userService.querySelective(username, mobile, page, limit, sort, order);
......@@ -51,13 +49,13 @@ public class AdminUserController {
}
@GetMapping("/username")
public Object username(@LoginAdmin Integer adminId, @NotEmpty String username){
if(adminId == null){
public Object username(@LoginAdmin Integer adminId, @NotEmpty String username) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
int total = userService.countSeletive(username, null, null, null, null, null);
if(total == 0){
if (total == 0) {
return ResponseUtil.ok("不存在");
}
return ResponseUtil.ok("已存在");
......@@ -65,46 +63,46 @@ public class AdminUserController {
private Object validate(LitemallUser user) {
String username = user.getUsername();
if(StringUtils.isEmpty(user)){
if (StringUtils.isEmpty(user)) {
return ResponseUtil.badArgument();
}
if(!RegexUtil.isUsername(username)){
if (!RegexUtil.isUsername(username)) {
return ResponseUtil.fail(402, "用户名不符合规定");
}
String password = user.getPassword();
if(StringUtils.isEmpty(password) || password.length() < 6){
if (StringUtils.isEmpty(password) || password.length() < 6) {
return ResponseUtil.fail(402, "用户密码长度不能小于6");
}
String mobile = user.getMobile();
if(StringUtils.isEmpty(mobile)){
if (StringUtils.isEmpty(mobile)) {
return ResponseUtil.badArgument();
}
if(!RegexUtil.isMobileExact(mobile)){
if (!RegexUtil.isMobileExact(mobile)) {
return ResponseUtil.fail(402, "用户手机号码格式不正确");
}
return null;
}
@PostMapping("/create")
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallUser user){
if(adminId == null){
public Object create(@LoginAdmin Integer adminId, @RequestBody LitemallUser user) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Object error = validate(user);
if(error != null){
if (error != null) {
return error;
}
String username = user.getUsername();
String mobile = user.getMobile();
List<LitemallUser> userList = userService.queryByUsername(username);
if(userList.size() > 0){
if (userList.size() > 0) {
return ResponseUtil.fail(403, "用户名已注册");
}
userList = userService.queryByMobile(mobile);
if(userList.size() > 0){
if (userList.size() > 0) {
return ResponseUtil.fail(403, "手机号已注册");
}
if(!RegexUtil.isMobileExact(mobile)){
if (!RegexUtil.isMobileExact(mobile)) {
return ResponseUtil.fail(403, "手机号格式不正确");
}
......@@ -118,12 +116,12 @@ public class AdminUserController {
}
@PostMapping("/update")
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallUser user){
if(adminId == null){
public Object update(@LoginAdmin Integer adminId, @RequestBody LitemallUser user) {
if (adminId == null) {
return ResponseUtil.unlogin();
}
Object error = validate(user);
if(error != null){
if (error != null) {
return error;
}
// 用户密码加密存储
......@@ -132,7 +130,7 @@ public class AdminUserController {
String encodedPassword = encoder.encode(password);
user.setPassword(encodedPassword);
if(userService.updateById(user) == 0){
if (userService.updateById(user) == 0) {
return ResponseUtil.updatedDataFailed();
}
return ResponseUtil.ok(user);
......
......@@ -14,8 +14,8 @@ public class BcryptTest {
@Test
public void test() {
String rawPassword = "aaaaaa";
String encodedPassword ="";
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
String encodedPassword = "";
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
encodedPassword = bCryptPasswordEncoder.encode(rawPassword);
System.out.println("rawPassword=" + rawPassword + " encodedPassword=" + encodedPassword);
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>litemall-all</artifactId>
......
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>litemall-core</artifactId>
......
......@@ -7,7 +7,6 @@ import org.springframework.web.bind.MissingServletRequestParameterException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import javax.validation.ConstraintViolation;
......@@ -20,28 +19,28 @@ public class GlobalExceptionHandler {
@ExceptionHandler(IllegalArgumentException.class)
@ResponseBody
public Object badArgumentHandler(IllegalArgumentException e){
public Object badArgumentHandler(IllegalArgumentException e) {
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
@ResponseBody
public Object badArgumentHandler(MethodArgumentTypeMismatchException e){
public Object badArgumentHandler(MethodArgumentTypeMismatchException e) {
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(MissingServletRequestParameterException.class)
@ResponseBody
public Object badArgumentHandler(MissingServletRequestParameterException e){
public Object badArgumentHandler(MissingServletRequestParameterException e) {
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
@ExceptionHandler(HttpMessageNotReadableException.class)
@ResponseBody
public Object badArgumentHandler(HttpMessageNotReadableException e){
public Object badArgumentHandler(HttpMessageNotReadableException e) {
e.printStackTrace();
return ResponseUtil.badArgumentValue();
}
......@@ -50,11 +49,11 @@ public class GlobalExceptionHandler {
@ResponseBody
public Object badArgumentHandler(ValidationException e) {
e.printStackTrace();
if(e instanceof ConstraintViolationException){
if (e instanceof ConstraintViolationException) {
ConstraintViolationException exs = (ConstraintViolationException) e;
Set<ConstraintViolation<?>> violations = exs.getConstraintViolations();
for (ConstraintViolation<?> item : violations) {
String message = ((PathImpl)item.getPropertyPath()).getLeafNode().getName() +item.getMessage();
String message = ((PathImpl) item.getPropertyPath()).getLeafNode().getName() + item.getMessage();
return ResponseUtil.fail(402, message);
}
}
......@@ -63,7 +62,7 @@ public class GlobalExceptionHandler {
@ExceptionHandler(Exception.class)
@ResponseBody
public Object seriousHandler(Exception e){
public Object seriousHandler(Exception e) {
e.printStackTrace();
return ResponseUtil.serious();
}
......
......@@ -11,10 +11,10 @@ import javax.validation.ValidatorFactory;
@Configuration
public class ValidatorConfiguration {
@Bean
public Validator validator(){
ValidatorFactory validatorFactory = Validation.byProvider( HibernateValidator.class )
public Validator validator() {
ValidatorFactory validatorFactory = Validation.byProvider(HibernateValidator.class)
.configure()
.addProperty( "hibernate.validator.fail_fast", "true" )
.addProperty("hibernate.validator.fail_fast", "true")
.buildValidatorFactory();
Validator validator = validatorFactory.getValidator();
......
......@@ -16,7 +16,7 @@ public class ExpressAutoConfiguration {
}
@Bean
public ExpressService expressService(){
public ExpressService expressService() {
ExpressService expressService = new ExpressService();
expressService.setProperties(properties);
return expressService;
......
......@@ -9,6 +9,9 @@ import java.util.Map;
@ConfigurationProperties(prefix = "litemall.express")
public class ExpressProperties {
private boolean enable;
private String appId;
private String appKey;
private List<Map<String, String>> vendors = new ArrayList<>();
public boolean isEnable() {
return enable;
......@@ -18,11 +21,6 @@ public class ExpressProperties {
this.enable = enable;
}
private String appId;
private String appKey;
private List<Map<String, String>> vendors = new ArrayList<>();
public List<Map<String, String>> getVendors() {
return vendors;
}
......
......@@ -32,62 +32,62 @@ public class ExpressInfo {
private String ShipperName;
public void setLogisticCode(String LogisticCode) {
this.LogisticCode = LogisticCode;
}
public String getLogisticCode() {
return LogisticCode;
}
public void setShipperCode(String ShipperCode) {
this.ShipperCode = ShipperCode;
public void setLogisticCode(String LogisticCode) {
this.LogisticCode = LogisticCode;
}
public String getShipperCode() {
return ShipperCode;
}
public void setTraces(List<Traces> Traces) {
this.Traces = Traces;
public void setShipperCode(String ShipperCode) {
this.ShipperCode = ShipperCode;
}
public List<Traces> getTraces() {
return Traces;
}
public void setState(String State) {
this.State = State;
public void setTraces(List<Traces> Traces) {
this.Traces = Traces;
}
public String getState() {
return State;
}
public void setEBusinessID(String EBusinessID) {
this.EBusinessID = EBusinessID;
public void setState(String State) {
this.State = State;
}
public String getEBusinessID() {
return EBusinessID;
}
public void setSuccess(boolean Success) {
this.Success = Success;
public void setEBusinessID(String EBusinessID) {
this.EBusinessID = EBusinessID;
}
public boolean getSuccess() {
return Success;
}
public void setReason(String Reason) {
this.Reason = Reason;
public void setSuccess(boolean Success) {
this.Success = Success;
}
public String getReason() {
return Reason;
}
public void setReason(String Reason) {
this.Reason = Reason;
}
public String getShipperName() {
return ShipperName;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment