|
@@ -3,12 +3,14 @@ package com.yami.shop.platform.controller;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.yami.shop.bean.model.ShopCategory;
|
|
import com.yami.shop.bean.model.ShopCategory;
|
|
|
|
|
+import com.yami.shop.bean.model.ShopDetail;
|
|
|
import com.yami.shop.bean.param.CategoryProductDTO;
|
|
import com.yami.shop.bean.param.CategoryProductDTO;
|
|
|
import com.yami.shop.common.util.PageParam;
|
|
import com.yami.shop.common.util.PageParam;
|
|
|
import com.yami.shop.common.util.R;
|
|
import com.yami.shop.common.util.R;
|
|
|
import com.yami.shop.security.platform.model.YamiSysUser;
|
|
import com.yami.shop.security.platform.model.YamiSysUser;
|
|
|
import com.yami.shop.security.platform.util.SecurityUtils;
|
|
import com.yami.shop.security.platform.util.SecurityUtils;
|
|
|
import com.yami.shop.service.IShopCategoryService;
|
|
import com.yami.shop.service.IShopCategoryService;
|
|
|
|
|
+import com.yami.shop.service.ShopDetailService;
|
|
|
import io.swagger.annotations.Api;
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
import io.swagger.annotations.ApiOperation;
|
|
@@ -19,6 +21,8 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -35,11 +39,12 @@ import java.util.List;
|
|
|
public class ShopCategoryController {
|
|
public class ShopCategoryController {
|
|
|
|
|
|
|
|
private final IShopCategoryService shopCategoryService;
|
|
private final IShopCategoryService shopCategoryService;
|
|
|
|
|
+ private final ShopDetailService shopDetailService;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 分页查询门店前台类目列表
|
|
* 分页查询门店前台类目列表
|
|
|
*
|
|
*
|
|
|
- * @param pageParam 分页参数
|
|
|
|
|
|
|
+ * @param pageParam 分页参数
|
|
|
* @param shopCategory 查询条件
|
|
* @param shopCategory 查询条件
|
|
|
* @return 分页结果
|
|
* @return 分页结果
|
|
|
*/
|
|
*/
|
|
@@ -70,7 +75,7 @@ public class ShopCategoryController {
|
|
|
if (shopId == null) {
|
|
if (shopId == null) {
|
|
|
return R.FAIL("门店不能为空!");
|
|
return R.FAIL("门店不能为空!");
|
|
|
}
|
|
}
|
|
|
- return R.SUCCESS(shopCategoryService.treeShopCategory(shopId,name));
|
|
|
|
|
|
|
+ return R.SUCCESS(shopCategoryService.treeShopCategory(shopId, name));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -87,9 +92,9 @@ public class ShopCategoryController {
|
|
|
throw new RuntimeException("导出模板失败:" + e.getMessage());
|
|
throw new RuntimeException("导出模板失败:" + e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 导入门店前台类目
|
|
* 导入门店前台类目
|
|
|
- *
|
|
|
|
|
*/
|
|
*/
|
|
|
@PostMapping("/import")
|
|
@PostMapping("/import")
|
|
|
@ApiOperation(value = "导入门店前台类目", notes = "导入门店前台类目")
|
|
@ApiOperation(value = "导入门店前台类目", notes = "导入门店前台类目")
|
|
@@ -100,7 +105,6 @@ public class ShopCategoryController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 根据ID获取门店前台类目详情
|
|
* 根据ID获取门店前台类目详情
|
|
|
*
|
|
*
|
|
@@ -128,12 +132,16 @@ public class ShopCategoryController {
|
|
|
@ApiOperation(value = "新增门店前台类目", notes = "新增门店前台类目")
|
|
@ApiOperation(value = "新增门店前台类目", notes = "新增门店前台类目")
|
|
|
public R<Void> save(@Valid @RequestBody ShopCategory shopCategory) {
|
|
public R<Void> save(@Valid @RequestBody ShopCategory shopCategory) {
|
|
|
// 设置默认值
|
|
// 设置默认值
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
|
+ String date = sdf.format(new Date());
|
|
|
|
|
+ String random = String.valueOf((int) (Math.random() * 10000));
|
|
|
|
|
+ shopCategory.setCode("F" + date + random);
|
|
|
shopCategory.setIsDelete(0);
|
|
shopCategory.setIsDelete(0);
|
|
|
- boolean result = shopCategoryService.save(shopCategory);
|
|
|
|
|
- if (result) {
|
|
|
|
|
- return R.SUCCESS();
|
|
|
|
|
- }
|
|
|
|
|
- return R.FAIL("新增门店前台类目失败");
|
|
|
|
|
|
|
+
|
|
|
|
|
+ ShopDetail shopDetailByShopId = shopDetailService.getShopDetailByShopId(shopCategory.getShopId());
|
|
|
|
|
+ shopCategory.setHbShopId(shopDetailByShopId.getHbStationId());
|
|
|
|
|
+ shopCategoryService.save(shopCategory);
|
|
|
|
|
+ return R.SUCCESS();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -154,12 +162,8 @@ public class ShopCategoryController {
|
|
|
if (dbShopCategory == null) {
|
|
if (dbShopCategory == null) {
|
|
|
return R.FAIL("门店前台类目不存在");
|
|
return R.FAIL("门店前台类目不存在");
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- boolean result = shopCategoryService.updateById(shopCategory);
|
|
|
|
|
- if (result) {
|
|
|
|
|
- return R.SUCCESS();
|
|
|
|
|
- }
|
|
|
|
|
- return R.FAIL("修改门店前台类目失败");
|
|
|
|
|
|
|
+ shopCategoryService.updateById(shopCategory);
|
|
|
|
|
+ return R.SUCCESS();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -172,21 +176,9 @@ public class ShopCategoryController {
|
|
|
@ApiOperation(value = "删除门店前台类目", notes = "删除门店前台类目(逻辑删除)")
|
|
@ApiOperation(value = "删除门店前台类目", notes = "删除门店前台类目(逻辑删除)")
|
|
|
@ApiImplicitParam(name = "id", value = "门店前台类目ID", required = true, dataType = "Long", paramType = "path")
|
|
@ApiImplicitParam(name = "id", value = "门店前台类目ID", required = true, dataType = "Long", paramType = "path")
|
|
|
public R<Void> delete(@PathVariable Long id) {
|
|
public R<Void> delete(@PathVariable Long id) {
|
|
|
- // 检查是否存在
|
|
|
|
|
- ShopCategory dbShopCategory = shopCategoryService.getById(id);
|
|
|
|
|
- if (dbShopCategory == null) {
|
|
|
|
|
- return R.FAIL("门店前台类目不存在");
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ shopCategoryService.delete(id);
|
|
|
|
|
+ return R.SUCCESS();
|
|
|
|
|
|
|
|
- // 逻辑删除
|
|
|
|
|
- ShopCategory shopCategory = new ShopCategory();
|
|
|
|
|
- shopCategory.setId(id);
|
|
|
|
|
- shopCategory.setIsDelete(1);
|
|
|
|
|
- boolean result = shopCategoryService.updateById(shopCategory);
|
|
|
|
|
- if (result) {
|
|
|
|
|
- return R.SUCCESS();
|
|
|
|
|
- }
|
|
|
|
|
- return R.FAIL("删除门店前台类目失败");
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|