Pārlūkot izejas kodu

fixed 预约管理相关接口迭代

fushengqian 11 mēneši atpakaļ
vecāks
revīzija
3c5814194d

+ 7 - 2
fuint-application/src/main/java/com/fuint/common/service/impl/BookCateServiceImpl.java

@@ -14,6 +14,7 @@ import com.fuint.common.service.SettingService;
 import com.fuint.common.enums.StatusEnum;
 import com.fuint.repository.model.MtBookCate;
 import com.fuint.repository.model.MtStore;
+import com.fuint.utils.StringUtil;
 import com.github.pagehelper.PageHelper;
 import lombok.AllArgsConstructor;
 import org.apache.commons.lang.StringUtils;
@@ -105,13 +106,16 @@ public class BookCateServiceImpl extends ServiceImpl<MtBookCateMapper, MtBookCat
         Integer storeId = mtBookCate.getStoreId() == null ? 0 : mtBookCate.getStoreId();
         if (mtBookCate.getMerchantId() == null || mtBookCate.getMerchantId() <= 0) {
             MtStore mtStore = storeService.queryStoreById(storeId);
-            if (mtStore != null) {
+            if (mtStore != null && mtStore.getMerchantId() != null) {
                 bookCate.setMerchantId(mtStore.getMerchantId());
             }
         }
-        if (bookCate.getMerchantId() == null || bookCate.getMerchantId() <= 0) {
+        if (mtBookCate.getMerchantId() == null || mtBookCate.getMerchantId() <= 0) {
             throw new BusinessCheckException("新增预约分类失败:所属商户不能为空!");
         }
+        if (StringUtil.isEmpty(mtBookCate.getName())) {
+            throw new BusinessCheckException("新增预约分类失败:分类名称不能为空!");
+        }
         bookCate.setStoreId(storeId);
         bookCate.setName(mtBookCate.getName());
         bookCate.setLogo(mtBookCate.getLogo());
@@ -121,6 +125,7 @@ public class BookCateServiceImpl extends ServiceImpl<MtBookCateMapper, MtBookCat
         bookCate.setCreateTime(new Date());
         bookCate.setSort(mtBookCate.getSort());
         bookCate.setOperator(mtBookCate.getOperator());
+        bookCate.setMerchantId(mtBookCate.getMerchantId());
         Integer id = mtBookCateMapper.insert(bookCate);
         if (id > 0) {
             return bookCate;

+ 7 - 6
fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendBookCateController.java

@@ -133,14 +133,14 @@ public class BackendBookCateController extends BaseController {
     public ResponseObject updateStatus(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         String status = params.get("status") != null ? params.get("status").toString() : StatusEnum.ENABLED.getKey();
-        Integer id = params.get("id") == null ? 0 : Integer.parseInt(params.get("id").toString());
+        Integer cateId = params.get("cateId") == null ? 0 : Integer.parseInt(params.get("cateId").toString());
 
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
         if (accountInfo == null) {
             return getFailureResult(1001, "请先登录");
         }
 
-        MtBookCate mtBookCate = bookCateService.getBookCateById(id);
+        MtBookCate mtBookCate = bookCateService.getBookCateById(cateId);
         if (mtBookCate == null) {
             return getFailureResult(201);
         }
@@ -171,8 +171,8 @@ public class BackendBookCateController extends BaseController {
         String description = params.get("description") == null ? "" : params.get("description").toString();
         String logo = params.get("logo") == null ? "" : params.get("logo").toString();
         String status = params.get("status") == null ? "" : params.get("status").toString();
-        String storeId = params.get("storeId") == null ? "0" : params.get("storeId").toString();
-        String sort = params.get("sort") == null ? "0" : params.get("sort").toString();
+        String storeId = (params.get("storeId") == null || StringUtil.isEmpty(params.get("storeId").toString())) ? "0" : params.get("storeId").toString();
+        String sort = (params.get("sort") == null || StringUtil.isEmpty(params.get("sort").toString())) ? "0" : params.get("sort").toString();
 
         AccountInfo accountInfo = TokenUtil.getAccountInfoByToken(token);
         if (accountInfo == null) {
@@ -188,12 +188,13 @@ public class BackendBookCateController extends BaseController {
         mtBookCate.setDescription(description);
         mtBookCate.setLogo(logo);
         mtBookCate.setOperator(accountInfo.getAccountName());
-        mtBookCate.setStatus(status);
         mtBookCate.setStoreId(Integer.parseInt(storeId));
-        mtBookCate.setSort(Integer.parseInt(sort));
         mtBookCate.setMerchantId(accountInfo.getMerchantId());
+        mtBookCate.setSort(Integer.parseInt(sort));
+        mtBookCate.setStatus(status);
 
         if (StringUtil.isNotEmpty(id)) {
+            mtBookCate.setId(Integer.parseInt(id));
             bookCateService.updateBookCate(mtBookCate);
         } else {
             bookCateService.addBookCate(mtBookCate);