diff --git a/gulimall-auth-server/gulimall-auth-server.iml b/gulimall-auth-server/gulimall-auth-server.iml
deleted file mode 100644
index e25f7fe408d0f65974f8893d68a14501d0c0737b..0000000000000000000000000000000000000000
--- a/gulimall-auth-server/gulimall-auth-server.iml
+++ /dev/null
@@ -1,189 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/app/AttrController.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/app/AttrController.java
index 1a33b865c50b708dcafb4d95c2ec3f7483500a65..1334c50295f5e22d55c513e851f5a97bcc5cc73d 100644
--- a/gulimall-product/src/main/java/com/yyf/gulimall/product/app/AttrController.java
+++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/app/AttrController.java
@@ -3,13 +3,11 @@ package com.yyf.gulimall.product.app;
import java.util.Arrays;
import java.util.Map;
+import com.yyf.gulimall.product.vo.AttrRespVo;
import org.springframework.beans.factory.annotation.Autowired ;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+import com.yyf.gulimall.product.vo.attrVo;
import com.yyf.gulimall.product.entity.AttrEntity;
import com.yyf.gulimall.product.service.AttrService;
import com.yyf.common.utils.PageUtils;
@@ -30,6 +28,14 @@ public class AttrController {
@Autowired
private AttrService attrService;
+
+ @GetMapping("base/list/{catelogId}")
+ public R saveBase(@RequestParam Map params,@PathVariable("catelogId") Long catelogId){
+
+ PageUtils page = attrService.queryBaseAttrPage(params,catelogId);
+ return R.ok().put("page",page);
+ }
+
/**
* 列表
*/
@@ -48,9 +54,9 @@ public class AttrController {
@RequestMapping("/info/{attrId}")
//@RequiresPermissions("product:attr:info")
public R info(@PathVariable("attrId") Long attrId){
- AttrEntity attr = attrService.getById(attrId);
-
- return R.ok().put("attr", attr);
+ //AttrEntity attr = attrService.getById(attrId);
+ AttrRespVo attrRespVo = attrService.getAttrInfo(attrId);
+ return R.ok().put("attr", attrRespVo);
}
/**
@@ -58,8 +64,8 @@ public class AttrController {
*/
@RequestMapping("/save")
//@RequiresPermissions("product:attr:save")
- public R save(@RequestBody AttrEntity attr){
- attrService.save(attr);
+ public R save(@RequestBody attrVo attr){
+ attrService.saveAttr(attr);
return R.ok();
}
@@ -69,8 +75,8 @@ public class AttrController {
*/
@RequestMapping("/update")
//@RequiresPermissions("product:attr:update")
- public R update(@RequestBody AttrEntity attr){
- attrService.updateById(attr);
+ public R update(@RequestBody attrVo attr){
+ attrService.updateAttrVo(attr);
return R.ok();
}
diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/AttrService.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/AttrService.java
index e553944c74a0e59d9d8886c2f492dda278d71827..046694b2cedd39828e697a987d70adb24b09ca10 100644
--- a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/AttrService.java
+++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/AttrService.java
@@ -3,6 +3,8 @@ package com.yyf.gulimall.product.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.yyf.common.utils.PageUtils;
import com.yyf.gulimall.product.entity.AttrEntity;
+import com.yyf.gulimall.product.vo.AttrRespVo;
+import com.yyf.gulimall.product.vo.attrVo;
import java.util.List;
import java.util.Map;
@@ -19,5 +21,13 @@ public interface AttrService extends IService {
PageUtils queryPage(Map params);
List getAttrByGroupId(Integer attrGroupId);
+
+ void saveAttr(attrVo attr);
+
+ PageUtils queryBaseAttrPage(Map params, Long catelogId);
+
+ AttrRespVo getAttrInfo(Long attrId);
+
+ void updateAttrVo(attrVo attr);
}
diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrGroupServiceImpl.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrGroupServiceImpl.java
index 7f251b19b469736f5178feec4bc87ead82fe44ec..e8736a3feb895c77d2b4e48954db61c389395966 100644
--- a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrGroupServiceImpl.java
+++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrGroupServiceImpl.java
@@ -46,20 +46,21 @@ public class AttrGroupServiceImpl extends ServiceImpl params, Long catelogId){
System.out.println(params+"................................这是条件");
+ String key = (String) params.get("key");
+ QueryWrapper wrapper = new QueryWrapper();
+ if(!StringUtils.isEmpty(key)){
+ wrapper.and((obj) -> {
+ obj.eq("attr_group_id",key).or().like("attr_group_name",key);
+ });
+ }
if (catelogId==0){
IPage page = this.page(
new Query().getPage(params),
- new QueryWrapper()
+ wrapper
);
return new PageUtils(page);
}else{
- String key = (String) params.get("key");
- QueryWrapper wrapper = new QueryWrapper().eq("catelog_id",catelogId);
- if(!StringUtils.isEmpty(key)){
- wrapper.and((obj) -> {
- obj.eq("attr_group_id",key).or().like("attr_group_name",key);
- });
- }
+ wrapper.eq("catelog_id",catelogId);
IPage page = this.page(new Query().getPage(params),wrapper);
return new PageUtils(page);
}
diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrServiceImpl.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrServiceImpl.java
index fb6449da6e6e4b1713607865ecf8dc2d95c0e40a..d8c40071cb84dfd745e670c7fdbcd46c92224ee5 100644
--- a/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrServiceImpl.java
+++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/service/impl/AttrServiceImpl.java
@@ -1,13 +1,24 @@
package com.yyf.gulimall.product.service.impl;
+import com.yyf.gulimall.product.dao.AttrAttrgroupRelationDao;
+import com.yyf.gulimall.product.dao.AttrGroupDao;
+import com.yyf.gulimall.product.dao.CategoryDao;
import com.yyf.gulimall.product.entity.AttrAttrgroupRelationEntity;
+import com.yyf.gulimall.product.entity.AttrGroupEntity;
+import com.yyf.gulimall.product.entity.CategoryEntity;
import com.yyf.gulimall.product.service.AttrAttrgroupRelationService;
+import com.yyf.gulimall.product.service.CategoryService;
+import com.yyf.gulimall.product.vo.AttrRespVo;
+import com.yyf.gulimall.product.vo.attrVo;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
+
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -17,6 +28,8 @@ import com.yyf.common.utils.Query;
import com.yyf.gulimall.product.dao.AttrDao;
import com.yyf.gulimall.product.entity.AttrEntity;
import com.yyf.gulimall.product.service.AttrService;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.StringUtils;
@Service("attrService")
@@ -25,6 +38,18 @@ public class AttrServiceImpl extends ServiceImpl implements
@Autowired
AttrAttrgroupRelationService attrAttrgroupRelationService;
+ @Autowired
+ AttrAttrgroupRelationDao attrAttrgroupRelationDao;
+
+ @Autowired
+ AttrGroupDao attrGroupDao;
+
+ @Autowired
+ CategoryDao categoryDao;
+
+ @Autowired
+ CategoryService categoryService;
+
@Override
public PageUtils queryPage(Map params) {
IPage page = this.page(
@@ -52,4 +77,102 @@ public class AttrServiceImpl extends ServiceImpl implements
return attrs;
}
+ @Transactional
+ @Override
+ public void saveAttr(attrVo attr) {
+ AttrEntity attrEntity = new AttrEntity();
+ BeanUtils.copyProperties(attr,attrEntity);
+ this.save(attrEntity);//保存基本信息
+ AttrAttrgroupRelationEntity attrgroup = new AttrAttrgroupRelationEntity();
+ attrgroup.setAttrGroupId(attr.getAttrGroupId());
+ attrgroup.setAttrId(attrEntity.getAttrId());
+ attrAttrgroupRelationDao.insert(attrgroup);
+ }
+
+ @Override
+ public PageUtils queryBaseAttrPage(Map params, Long catelogId) {
+ QueryWrapper Wrapper = new QueryWrapper<>();
+
+ if (catelogId!=0){
+ Wrapper.eq("catelog_id",catelogId);
+ }
+ String key = (String) params.get("key");
+ if (!StringUtils.isEmpty(key)){
+ Wrapper.and((wrapper)->{
+ wrapper.eq("attr_id",key).or().like("attr_name",key);
+ });
+
+ }
+ IPage page = this.page(
+ new Query().getPage(params),
+ Wrapper
+ );
+ PageUtils pageUtils = new PageUtils(page);
+ List records = page.getRecords();
+ List respVos = records.stream().map((attrEntity) -> {
+ AttrRespVo attrRespVo = new AttrRespVo();
+ BeanUtils.copyProperties(attrEntity, attrRespVo);
+
+ //设置分类和分组的名称
+ AttrAttrgroupRelationEntity attrId = attrAttrgroupRelationDao.selectOne(new QueryWrapper().eq("attr_id", attrEntity.getAttrId()));
+ if (attrId != null) {
+ AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(attrId.getAttrGroupId());
+ attrRespVo.setGroupName(attrGroupEntity.getAttrGroupName());
+ }
+ CategoryEntity categoryEntity = categoryDao.selectById(attrEntity.getCatelogId());
+ if (categoryEntity != null) {
+ attrRespVo.setCatelogName(categoryEntity.getName());
+ }
+ return attrRespVo;
+ }).collect(Collectors.toList());
+ pageUtils.setList(respVos);
+ return pageUtils;
+ }
+
+ @Override
+ public AttrRespVo getAttrInfo(Long attrId) {
+ AttrRespVo respVo = new AttrRespVo();
+ AttrEntity attrEntity = this.getById(attrId);
+ BeanUtils.copyProperties(attrEntity,respVo);
+ //设置分组信息
+ AttrAttrgroupRelationEntity attrgroupRelation = attrAttrgroupRelationDao.selectOne(new QueryWrapper().eq("attr_id", attrId));
+ if (attrgroupRelation!=null){
+ respVo.setAttrGroupId(attrgroupRelation.getAttrGroupId());
+ AttrGroupEntity attrGroupEntity = attrGroupDao.selectById(attrgroupRelation.getAttrGroupId());
+ if (attrGroupEntity!=null){
+ respVo.setGroupName(attrGroupEntity.getAttrGroupName());
+ }
+ }
+
+ //设置分类信息
+ Long catelogId = attrEntity.getCatelogId();
+ Long[] catelogPath = categoryService.findCatelogPath(catelogId);
+ respVo.setCatelogPath(catelogPath);
+ CategoryEntity categoryEntity = categoryDao.selectById(catelogId);
+ if (categoryEntity!=null){
+ respVo.setCatelogName(categoryEntity.getName());
+ }
+ return respVo;
+ }
+
+ @Transactional
+ @Override
+ public void updateAttrVo(attrVo attr) {
+ AttrEntity attrEntity = new AttrEntity();
+ BeanUtils.copyProperties(attr,attrEntity);
+ this.updateById(attrEntity);
+
+ AttrAttrgroupRelationEntity relationEntity = new AttrAttrgroupRelationEntity();
+ relationEntity.setAttrGroupId(attr.getAttrGroupId());
+ relationEntity.setAttrId(attr.getAttrId());
+ Integer count = attrAttrgroupRelationDao.selectCount(new QueryWrapper().eq("attr_id", attr.getAttrId()));
+ if (count>0) {
+
+ attrAttrgroupRelationDao.update(relationEntity,new QueryWrapper().eq("attr_id",attr.getAttrId()));
+
+ }else {
+ attrAttrgroupRelationDao.insert(relationEntity);
+ }
+ }
+
}
\ No newline at end of file
diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/AttrRespVo.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/AttrRespVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..70c80ae62cf5f9ffde9e407987134d2a2bbd538b
--- /dev/null
+++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/AttrRespVo.java
@@ -0,0 +1,13 @@
+package com.yyf.gulimall.product.vo;
+
+import lombok.Data;
+
+@Data
+public class AttrRespVo extends attrVo {
+
+ private String catelogName;
+ private String groupName;
+
+ private Long[] catelogPath;
+
+}
diff --git a/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/attrVo.java b/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/attrVo.java
new file mode 100644
index 0000000000000000000000000000000000000000..aca3d9172f71336bf5d2bd7e9c30ff7d7fdd5089
--- /dev/null
+++ b/gulimall-product/src/main/java/com/yyf/gulimall/product/vo/attrVo.java
@@ -0,0 +1,45 @@
+package com.yyf.gulimall.product.vo;
+
+import lombok.Data;
+
+@Data
+public class attrVo {
+
+ private Long attrId;
+ /**
+ * 属性名
+ */
+ private String attrName;
+ /**
+ * 是否需要检索[0-不需要,1-需要]
+ */
+ private Integer searchType;
+ /**
+ * 属性图标
+ */
+ private String icon;
+ /**
+ * 可选值列表[用逗号分隔]
+ */
+ private String valueSelect;
+ /**
+ * 属性类型[0-销售属性,1-基本属性,2-既是销售属性又是基本属性]
+ */
+ private Integer attrType;
+ /**
+ * 启用状态[0 - 禁用,1 - 启用]
+ */
+ private Long enable;
+ /**
+ * 所属分类
+ */
+ private Long catelogId;
+ /**
+ * 快速展示【是否展示在介绍上;0-否 1-是】,在sku中仍然可以调整
+ */
+ private Integer showDesc;
+ /**
+ * 存
+ */
+ private Long attrGroupId;
+}
diff --git a/renren-fast/renren-fast.iml b/renren-fast/renren-fast.iml
index abd4a264892881cea271d2073777e3a72be5be6f..a4a46674efc0732ae6ccd60f77419f0fb2aa9df0 100644
--- a/renren-fast/renren-fast.iml
+++ b/renren-fast/renren-fast.iml
@@ -15,8 +15,8 @@
-
-
+
+
@@ -25,50 +25,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -79,7 +35,7 @@
-
+
@@ -217,6 +173,7 @@
+
@@ -226,8 +183,49 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file