diff --git a/hiver-core/src/main/java/cc/hiver/core/common/utils/NameUtil.java b/hiver-core/src/main/java/cc/hiver/core/common/utils/NameUtil.java
index 40d9a928..456e1cd5 100644
--- a/hiver-core/src/main/java/cc/hiver/core/common/utils/NameUtil.java
+++ b/hiver-core/src/main/java/cc/hiver/core/common/utils/NameUtil.java
@@ -98,9 +98,9 @@ public class NameUtil {
if (StrUtil.isNotBlank(username) && userService.findByUsername(username) != null) {
throw new HiverException("该登录账号已被注册");
}
- if (StrUtil.isNotBlank(email) && userService.findByEmail(email) != null) {
+ /*if (StrUtil.isNotBlank(email) && userService.findByEmail(email) != null) {
throw new HiverException("该邮箱已被注册");
- }
+ }*/
if (StrUtil.isNotBlank(mobile) && userService.findByMobile(mobile) != null) {
throw new HiverException("该手机号已被注册");
}
diff --git a/hiver-modules/hiver-app/pom.xml b/hiver-modules/hiver-app/pom.xml
index a1eacf29..7008152b 100644
--- a/hiver-modules/hiver-app/pom.xml
+++ b/hiver-modules/hiver-app/pom.xml
@@ -34,5 +34,11 @@
jsch
0.1.55
+
+ cc.hiver
+ hiver-mall
+ 1.0-SNAPSHOT
+ compile
+
\ No newline at end of file
diff --git a/hiver-modules/hiver-app/src/main/resources/mapper/ShopMapper.xml b/hiver-modules/hiver-app/src/main/resources/mapper/ShopMapper.xml
deleted file mode 100644
index bbe19947..00000000
--- a/hiver-modules/hiver-app/src/main/resources/mapper/ShopMapper.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
\ No newline at end of file
diff --git a/hiver-modules/hiver-base/pom.xml b/hiver-modules/hiver-base/pom.xml
index f6f004a3..dc2060a1 100644
--- a/hiver-modules/hiver-base/pom.xml
+++ b/hiver-modules/hiver-base/pom.xml
@@ -9,5 +9,13 @@
4.0.0
基础模块
+
+
+ cc.hiver
+ hiver-mall
+ 1.0-SNAPSHOT
+ compile
+
+
hiver-base
\ No newline at end of file
diff --git a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java
index 939ce64d..a298a96a 100644
--- a/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java
+++ b/hiver-modules/hiver-base/src/main/java/cc/hiver/base/controller/manage/UserController.java
@@ -1,17 +1,13 @@
package cc.hiver.base.controller.manage;
import cc.hiver.base.async.AddMessage;
-import cc.hiver.core.common.annotation.SystemLog;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.constant.UserConstant;
-import cc.hiver.core.common.enums.LogType;
-import cc.hiver.core.common.exception.HiverException;
import cc.hiver.core.common.redis.RedisTemplateHelper;
import cc.hiver.core.common.utils.*;
import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result;
import cc.hiver.core.common.vo.SearchVo;
-import cc.hiver.core.config.security.SecurityUserDetails;
import cc.hiver.core.dao.mapper.DeleteMapper;
import cc.hiver.core.entity.Department;
import cc.hiver.core.entity.Role;
@@ -20,6 +16,9 @@ import cc.hiver.core.entity.UserRole;
import cc.hiver.core.service.*;
import cc.hiver.core.service.mybatis.IUserRoleService;
import cc.hiver.core.vo.RoleDTO;
+import cc.hiver.mall.entity.ShopUser;
+import cc.hiver.mall.service.ShopService;
+import cc.hiver.mall.service.ShopUserService;
import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -29,8 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.domain.Page;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
@@ -89,6 +86,12 @@ public class UserController {
@Autowired
private SecurityUtil securityUtil;
+ @Autowired
+ private ShopService shopService;
+
+ @Autowired
+ private ShopUserService shopUserService;
+
@PersistenceContext
private EntityManager entityManager;
@@ -244,7 +247,9 @@ public class UserController {
@RequestMapping(value = "/admin/add", method = RequestMethod.POST)
@ApiOperation(value = "添加用户")
public Result add(@Valid User u,
- @RequestParam(required = false) String[] roleIds) {
+ @RequestParam(required = false) String[] roleIds,
+ @RequestParam(required = false) String userType,
+ @RequestParam(required = false) String shopId) {
// 校验是否已存在
NameUtil.checkUserInfo(u);
if (StrUtil.isBlank(u.getNickname())) {
@@ -271,6 +276,16 @@ public class UserController {
}).collect(Collectors.toList());
userRoleService.saveOrUpdateAll(userRoles);
}
+ //添加店铺和用户信息
+ ShopUser shopUser = shopUserService.selectByUserIdAndShopId(u.getId(), shopId);
+ if (shopUser != null) {
+ return ResultUtil.success("该员工已添加");
+ }
+ shopUser = new ShopUser();
+ shopUser.setType(Integer.valueOf(userType));
+ shopUser.setUserId(u.getId());
+ shopUser.setShopId(shopId);
+ shopUserService.save(shopUser);
// 发送创建账号消息
addMessage.addSendMessage(user.getId());
return ResultUtil.success("添加成功");
diff --git a/hiver-modules/hiver-mall/pom.xml b/hiver-modules/hiver-mall/pom.xml
index 42e3d0a7..c6436d81 100644
--- a/hiver-modules/hiver-mall/pom.xml
+++ b/hiver-modules/hiver-mall/pom.xml
@@ -18,4 +18,33 @@
1.0-SNAPSHOT
+
+
+
+ org.mybatis.generator
+ mybatis-generator-maven-plugin
+ 1.3.2
+
+ true
+ true
+
+
+
+ Generate Mybatis Artifacts
+
+ generate
+
+
+
+
+
+ org.mybatis.generator
+ mybatis-generator-core
+ 1.3.2
+
+
+
+
+
+
\ No newline at end of file
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CommonController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CommonController.java
index 7d083f43..6fb6ca8c 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CommonController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/CommonController.java
@@ -1,7 +1,7 @@
package cc.hiver.mall.controller;
-import cc.hiver.app.entity.Shop;
-import cc.hiver.app.service.mybatis.IShopService;
+import cc.hiver.mall.entity.Shop;
+import cc.hiver.mall.service.mybatis.IShopService;
import cc.hiver.core.common.exception.HiverException;
import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.ResultUtil;
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/MallController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/MallController.java
index ae629bf4..d78f0ffc 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/MallController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/MallController.java
@@ -1,14 +1,14 @@
package cc.hiver.mall.controller;
-import cc.hiver.app.entity.Shop;
-import cc.hiver.app.service.ShopService;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.utils.SecurityUtil;
import cc.hiver.core.common.vo.Result;
import cc.hiver.core.entity.User;
import cc.hiver.core.service.UserService;
import cc.hiver.core.vo.UserVo;
+import cc.hiver.mall.entity.Shop;
import cc.hiver.mall.entity.ShopUser;
+import cc.hiver.mall.service.ShopService;
import cc.hiver.mall.service.ShopUserService;
import cc.hiver.mall.service.mybatis.IMallService;
import cn.hutool.core.util.StrUtil;
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductAttributeController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductAttributeController.java
index 9863018e..b3768df3 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductAttributeController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductAttributeController.java
@@ -2,10 +2,8 @@ package cc.hiver.mall.controller;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.vo.Result;
-import cc.hiver.mall.entity.Product;
import cc.hiver.mall.entity.ProductAttribute;
import cc.hiver.mall.service.mybatis.ProductAttributeService;
-import cc.hiver.mall.service.mybatis.ProductService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -69,4 +67,22 @@ public class ProductAttributeController {
return new ResultUtil>().setData(list);
}
+ @RequestMapping(value = "/selectById", method = RequestMethod.GET)
+ @ApiOperation(value = "根据属性id查询货品属性列表")
+ public Result selectById(String id) {
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("id",id);
+ List list = productAttributeService.list(queryWrapper);
+ return new ResultUtil>().setData(list);
+ }
+
+ @RequestMapping(value = "/selectByCategoryId", method = RequestMethod.GET)
+ @ApiOperation(value = "根据分类id查询货品属性列表")
+ public Result selectByCategoryId(String categoryId) {
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("category_id",categoryId);
+ List list = productAttributeService.list(queryWrapper);
+ return new ResultUtil>().setData(list);
+ }
+
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductAttributeValueController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductAttributeValueController.java
index 39a27933..dbccb743 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductAttributeValueController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductAttributeValueController.java
@@ -29,6 +29,13 @@ public class ProductAttributeValueController {
@RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(value = "新增货品属性值")
public Result save(ProductAttributeValue productAttributeValue) {
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("attribute_id",productAttributeValue.getAttributeId());
+ queryWrapper.eq("value",productAttributeValue.getValue());
+ List list = productAttributeValueService.list(queryWrapper);
+ if(list.size()>0){
+ return ResultUtil.error("该属性已存在,请勿重复添加!");
+ }
boolean result = productAttributeValueService.save(productAttributeValue);
if(result) {
return ResultUtil.success("添加成功");
@@ -67,4 +74,13 @@ public class ProductAttributeValueController {
return new ResultUtil>().setData(list);
}
+ @RequestMapping(value = "/selectByAttributeId", method = RequestMethod.GET)
+ @ApiOperation(value = "根据属性id查询货品属性值列表")
+ public Result selectByAttributeId(String id) {
+ QueryWrapper queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("attribute_id",id);
+ List list = productAttributeValueService.list(queryWrapper);
+ return new ResultUtil>().setData(list);
+ }
+
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductCategoryController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductCategoryController.java
index 15fca0f3..ef6b5e3f 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductCategoryController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductCategoryController.java
@@ -2,10 +2,8 @@ package cc.hiver.mall.controller;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.vo.Result;
-import cc.hiver.mall.entity.Product;
import cc.hiver.mall.entity.ProductCategory;
import cc.hiver.mall.service.mybatis.ProductCategoryService;
-import cc.hiver.mall.service.mybatis.ProductService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -69,4 +67,6 @@ public class ProductCategoryController {
return new ResultUtil>().setData(list);
}
+
+
}
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java
index b136f378..96cd9d94 100644
--- a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ProductController.java
@@ -3,24 +3,16 @@ package cc.hiver.mall.controller;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.vo.Result;
import cc.hiver.mall.entity.Product;
-import cc.hiver.mall.pojo.form.GoodsForm;
-import cc.hiver.mall.pojo.query.GoodsPageQuery;
-import cc.hiver.mall.pojo.vo.GoodsDetailVO;
-import cc.hiver.mall.pojo.vo.GoodsPageVO;
-import cc.hiver.mall.pojo.vo.MallGoodsDetailVO;
-import cc.hiver.mall.pojo.vo.MallGoodsPageVO;
-import cc.hiver.mall.service.mybatis.GoodsService;
import cc.hiver.mall.service.mybatis.ProductService;
-import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
import java.util.List;
diff --git a/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopAreaController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopAreaController.java
new file mode 100644
index 00000000..bdc92662
--- /dev/null
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopAreaController.java
@@ -0,0 +1,194 @@
+package cc.hiver.mall.controller;
+
+import cc.hiver.core.common.constant.CommonConstant;
+import cc.hiver.core.common.redis.RedisTemplateHelper;
+import cc.hiver.core.common.utils.CommonUtil;
+import cc.hiver.core.common.utils.HibernateProxyTypeAdapter;
+import cc.hiver.core.common.utils.ResultUtil;
+import cc.hiver.core.common.utils.SecurityUtil;
+import cc.hiver.core.common.vo.Result;
+import cc.hiver.core.dao.mapper.DeleteMapper;
+import cc.hiver.core.entity.User;
+import cc.hiver.mall.entity.ShopArea;
+import cc.hiver.mall.service.ShopAreaService;
+import cc.hiver.mall.service.ShopService;
+import cn.hutool.core.util.StrUtil;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheConfig;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 圈层管理接口
+ *
+ * @author cc
+ */
+@Slf4j
+@RestController
+@Api(tags = "圈层管理接口")
+@RequestMapping("/hiver/app/shopArea")
+@CacheConfig(cacheNames = "shopArea")
+@Transactional
+public class ShopAreaController {
+ @Autowired
+ private ShopAreaService shopAreaService;
+
+ @Autowired
+ private DeleteMapper deleteMapper;
+
+ @Autowired
+ private RedisTemplateHelper redisTemplate;
+
+ @Autowired
+ private SecurityUtil securityUtil;
+
+ @Autowired
+ private ShopService shopService;
+
+ @RequestMapping(value = "/getByParentId/{parentId}", method = RequestMethod.GET)
+ @ApiOperation(value = "通过parentId获取")
+ public Result> getByParentId(@PathVariable String parentId,
+ @ApiParam("是否开始数据权限过滤")
+ @RequestParam(required = false, defaultValue = "true") Boolean openDataFilter) {
+ List list;
+ User u = securityUtil.getCurrUserSimple();
+ String key = "ShopArea::" + parentId + ":" + u.getId() + "_" + openDataFilter;
+ String v = redisTemplate.get(key);
+ if (StrUtil.isNotBlank(v)) {
+ list = new Gson().fromJson(v, new TypeToken>() {
+ }.getType());
+ return new ResultUtil>().setData(list);
+ }
+ list = shopAreaService.findByParentIdOrderBySortOrder(parentId, openDataFilter);
+ setInfo(list);
+ redisTemplate.set(key, new GsonBuilder().registerTypeAdapterFactory(HibernateProxyTypeAdapter.FACTORY).create().toJson(list), 15L, TimeUnit.DAYS);
+ return new ResultUtil>().setData(list);
+ }
+
+ @RequestMapping(value = "/add", method = RequestMethod.POST)
+ @ApiOperation(value = "添加")
+ public Result add(ShopArea ShopArea) {
+ ShopArea d = shopAreaService.save(ShopArea);
+ // 如果不是添加的一级 判断设置上级为父节点标识
+ if (!CommonConstant.PARENT_ID.equals(ShopArea.getParentId())) {
+ ShopArea parent = shopAreaService.get(ShopArea.getParentId());
+ if (parent.getIsParent() == null || !parent.getIsParent()) {
+ parent.setIsParent(true);
+ shopAreaService.update(parent);
+ }
+ }
+ // 更新缓存
+ redisTemplate.deleteByPattern("ShopArea::*");
+ // 删除数据权限缓存
+ //redisTemplate.deleteByPattern("userRole::depIds:*");
+ return ResultUtil.success("添加成功");
+ }
+
+ @RequestMapping(value = "/edit", method = RequestMethod.POST)
+ @ApiOperation(value = "编辑")
+ public Result edit(ShopArea ShopArea,
+ @RequestParam(required = false) String[] mainHeader,
+ @RequestParam(required = false) String[] viceHeader) {
+ if (ShopArea.getId().equals(ShopArea.getParentId())) {
+ return ResultUtil.error("上级节点不能为自己");
+ }
+ ShopArea old = shopAreaService.get(ShopArea.getId());
+ String oldParentId = old.getParentId();
+ String oldTitle = old.getTitle();
+ ShopArea d = shopAreaService.update(ShopArea);
+ // 先删除原数据
+
+ // 如果该节点不是一级节点 且修改了级别 判断上级还有无子节点
+ if (!CommonConstant.PARENT_ID.equals(oldParentId) && !oldParentId.equals(ShopArea.getParentId())) {
+ ShopArea parent = shopAreaService.get(oldParentId);
+ List children = shopAreaService.findByParentIdOrderBySortOrder(parent.getId(), false);
+ if (parent != null && (children == null || children.isEmpty())) {
+ parent.setIsParent(false);
+ shopAreaService.update(parent);
+ }
+ }
+
+ shopService.updateShopAreaTitle(ShopArea.getId(),ShopArea.getTitle());
+
+ // 手动删除所有圈层缓存
+ redisTemplate.deleteByPattern("ShopArea:*");
+ return ResultUtil.success("编辑成功");
+ }
+
+ @RequestMapping(value = "/delByIds", method = RequestMethod.POST)
+ @ApiOperation(value = "批量通过id删除")
+ public Result delByIds(@RequestParam String[] ids) {
+ for (String id : ids) {
+ deleteRecursion(id, ids);
+ }
+ // 手动删除所有圈层缓存
+ redisTemplate.deleteByPattern("ShopArea:*");
+
+ return ResultUtil.success("批量通过id删除数据成功");
+ }
+
+ public void deleteRecursion(String id, String[] ids) {
+ /*List list = userService.findByShopAreaId(id);
+ if (list != null && list.size() > 0) {
+ throw new HiverException("删除失败,包含正被用户使用关联的圈层");
+ }*/
+ // 获得其父节点
+ ShopArea dep = shopAreaService.get(id);
+ ShopArea parent = null;
+ if (StrUtil.isNotBlank(dep.getParentId())) {
+ parent = shopAreaService.findById(dep.getParentId());
+ }
+ shopAreaService.delete(id);
+
+
+ // 删除流程关联节点
+ // deleteMapper.deleteActNode(id);
+ // 判断父节点是否还有子节点
+ if (parent != null) {
+ List children = shopAreaService.findByParentIdOrderBySortOrder(parent.getId(), false);
+ if (children == null || children.isEmpty()) {
+ parent.setIsParent(false);
+ shopAreaService.update(parent);
+ }
+ }
+ // 递归删除
+ List ShopAreas = shopAreaService.findByParentIdOrderBySortOrder(id, false);
+ for (ShopArea d : ShopAreas) {
+ if (!CommonUtil.judgeIds(d.getId(), ids)) {
+ deleteRecursion(d.getId(), ids);
+ }
+ }
+ }
+
+ @RequestMapping(value = "/search", method = RequestMethod.GET)
+ @ApiOperation(value = "圈层名模糊搜索")
+ public Result> searchByTitle(@RequestParam String title,
+ @ApiParam("是否开始数据权限过滤") @RequestParam(required = false, defaultValue = "true") Boolean openDataFilter) {
+ List list = shopAreaService.findByTitleLikeOrderBySortOrder("%" + title + "%", openDataFilter);
+ setInfo(list);
+ return new ResultUtil>().setData(list);
+ }
+
+ public void setInfo(List list) {
+ // lambda表达式
+ list.forEach(item -> {
+ if (!CommonConstant.PARENT_ID.equals(item.getParentId())) {
+ ShopArea parent = shopAreaService.get(item.getParentId());
+ item.setParentTitle(parent.getTitle());
+ } else {
+ item.setParentTitle("一级圈层");
+ }
+
+ });
+ }
+}
diff --git a/hiver-modules/hiver-app/src/main/java/cc/hiver/app/controller/admin/ShopController.java b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java
similarity index 59%
rename from hiver-modules/hiver-app/src/main/java/cc/hiver/app/controller/admin/ShopController.java
rename to hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java
index 7d0d802f..ac583d46 100644
--- a/hiver-modules/hiver-app/src/main/java/cc/hiver/app/controller/admin/ShopController.java
+++ b/hiver-modules/hiver-mall/src/main/java/cc/hiver/mall/controller/ShopController.java
@@ -13,15 +13,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
-package cc.hiver.app.controller.admin;
+package cc.hiver.mall.controller;
-import cc.hiver.app.entity.Shop;
-import cc.hiver.app.service.ShopService;
import cc.hiver.core.common.constant.ShopConstant;
import cc.hiver.core.common.utils.PageUtil;
import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.vo.PageVo;
import cc.hiver.core.common.vo.Result;
+import cc.hiver.mall.entity.Shop;
+import cc.hiver.mall.entity.ShopArea;
+import cc.hiver.mall.entity.ShopUser;
+import cc.hiver.mall.service.ShopAreaService;
+import cc.hiver.mall.service.ShopService;
+import cc.hiver.mall.service.ShopUserService;
+import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -29,7 +34,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;
+import java.util.Arrays;
import java.util.List;
+import java.util.stream.Collectors;
/**
* @author cc
@@ -42,6 +49,12 @@ public class ShopController {
@Autowired
private ShopService shopService;
+ @Autowired
+ private ShopAreaService shopAreaService;
+
+ @Autowired
+ private ShopUserService shopUserService;
+
@RequestMapping(value = "/getAll", method = RequestMethod.GET)
@ApiOperation(value = "获取全部数据")
public Result> getAll() {
@@ -56,7 +69,26 @@ public class ShopController {
if (shopService.findByShopName(shop.getShopName()) != null) {
return ResultUtil.error("店铺名称已经存在");
}
+ if (StrUtil.isNotBlank(shop.getShopArea())) {
+ ShopArea d = shopAreaService.get(shop.getShopArea());
+ if (d != null) {
+ shop.setShopAreaTitle(d.getTitle());
+ }
+ } else {
+ shop.setShopArea(null);
+ shop.setShopAreaTitle("");
+ }
+
shopService.save(shop);
+
+ if (shop.getShopMangerId() != null) {
+ // 添加店长
+ List shopUsers = Arrays.asList(shop.getShopMangerId()).stream().map(e -> {
+ return new ShopUser().setShopId(shop.getId()).setUserId(e).setType(1);
+ }).collect(Collectors.toList());
+ shopUserService.saveOrUpdateAll(shopUsers);
+ }
+
return ResultUtil.success("添加成功");
}
@@ -64,7 +96,27 @@ public class ShopController {
@ResponseBody
@ApiOperation(value = "编辑")
public Result