Browse Source

修正接口BUG,保证运行接口正确。

cangku
delicacylee 3 years ago
parent
commit
7490c6ba0c
  1. 2
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/controller/GoodsAttributeController.java
  2. 28
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/controller/GoodsCategoryController.java
  3. 6
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/controller/MallController.java
  4. 2
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/dao/GoodsAttributeValueDao.java
  5. 18
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/dao/GoodsCategoryDao.java
  6. 3
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/dao/MallDao.java
  7. 19
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/dao/mapper/MallMapper.java
  8. 3
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/dto/CustomAddressQueryCriteria.java
  9. 2
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/service/GoodsAttributeValueService.java
  10. 18
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/service/GoodsCategoryService.java
  11. 3
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/service/MallService.java
  12. 17
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/service/mybatis/IMallService.java
  13. 4
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/serviceimpl/GoodsAttributeValueServiceImpl.java
  14. 12
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/serviceimpl/GoodsCategoryServiceImpl.java
  15. 7
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/serviceimpl/MallServiceImpl.java
  16. 21
      hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/serviceimpl/mybatis/IMallServiceImpl.java
  17. 11
      hiver-modules/hiver-shop/src/main/resources/mapper/MallMapper.xml

2
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/controller/GoodsAttributeController.java

@ -63,7 +63,7 @@ public class GoodsAttributeController {
public Result edit(GoodsAttributeDto entity) { public Result edit(GoodsAttributeDto entity) {
GoodsAttributeKey goodsAttributeKey = goodsAttributeKeyService.findById(entity.getId()); GoodsAttributeKey goodsAttributeKey = goodsAttributeKeyService.findById(entity.getId());
goodsAttributeKey.setAttributeKey(entity.getAttributeKey()); goodsAttributeKey.setAttributeKey(entity.getAttributeKey());
List<GoodsAttributeValue> values = goodsAttributeValueService.findAllBykAndAttributeId(entity.getId()); List<GoodsAttributeValue> values = goodsAttributeValueService.findAllByAttributeId(entity.getId());
goodsAttributeValueService.delete(values); goodsAttributeValueService.delete(values);
for(String v : entity.getAttributeValues()) { for(String v : entity.getAttributeValues()) {
GoodsAttributeValue goodsAttributeValue = new GoodsAttributeValue(); GoodsAttributeValue goodsAttributeValue = new GoodsAttributeValue();

28
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/controller/GoodsCategoryController.java

@ -1,5 +1,6 @@
package cc.hiver.shop.controller; package cc.hiver.shop.controller;
import cc.hiver.core.common.constant.CommonConstant;
import cc.hiver.core.common.utils.ResultUtil; import cc.hiver.core.common.utils.ResultUtil;
import cc.hiver.core.common.vo.Result; import cc.hiver.core.common.vo.Result;
import cc.hiver.shop.entity.GoodsCategory; import cc.hiver.shop.entity.GoodsCategory;
@ -9,10 +10,9 @@ import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import java.util.List;
import org.springframework.web.bind.annotation.RestController;
@Slf4j @Slf4j
@RestController @RestController
@ -23,6 +23,14 @@ public class GoodsCategoryController {
@Autowired @Autowired
private GoodsCategoryService goodsCategoryService; private GoodsCategoryService goodsCategoryService;
@RequestMapping(value = "/getByParentId/{parentId}", method = RequestMethod.GET)
@ApiOperation(value = "通过parentId获取")
public Result<List<GoodsCategory>> getByParentId(@PathVariable String parentId) {
List<GoodsCategory> list = goodsCategoryService.findByParentIdOrderBySortOrder(parentId);
setInfo(list);
return new ResultUtil<List<GoodsCategory>>().setData(list);
}
@RequestMapping(value = "/save", method = RequestMethod.POST) @RequestMapping(value = "/save", method = RequestMethod.POST)
@ApiOperation(value = "保存数据") @ApiOperation(value = "保存数据")
public Result<GoodsCategory> save(GoodsCategory entity) { public Result<GoodsCategory> save(GoodsCategory entity) {
@ -38,4 +46,16 @@ public class GoodsCategoryController {
} }
return ResultUtil.success("批量通过id删除数据成功"); return ResultUtil.success("批量通过id删除数据成功");
} }
public void setInfo(List<GoodsCategory> list) {
// lambda表达式
list.forEach(item -> {
if (!CommonConstant.PARENT_ID.equals(item.getParentId())) {
GoodsCategory parent = goodsCategoryService.get(item.getParentId());
item.setParentTitle(parent.getCategoryName());
} else {
item.setParentTitle("一级分类");
}
});
}
} }

6
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/controller/MallController.java

@ -6,6 +6,7 @@ import cc.hiver.shop.entity.Mall;
import cc.hiver.shop.entity.UserMall; import cc.hiver.shop.entity.UserMall;
import cc.hiver.shop.service.MallService; import cc.hiver.shop.service.MallService;
import cc.hiver.shop.service.UserMallService; import cc.hiver.shop.service.UserMallService;
import cc.hiver.shop.service.mybatis.IMallService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -27,6 +28,9 @@ public class MallController {
@Autowired @Autowired
private UserMallService userMallService; private UserMallService userMallService;
@Autowired
private IMallService iMallService;
@RequestMapping(value = "/get/{id}", method = RequestMethod.GET) @RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
@ApiOperation(value = "通过id获取") @ApiOperation(value = "通过id获取")
public Result<Mall> get(@PathVariable String id) { public Result<Mall> get(@PathVariable String id) {
@ -73,7 +77,7 @@ public class MallController {
@RequestMapping(value = "/getAll", method = RequestMethod.GET) @RequestMapping(value = "/getAll", method = RequestMethod.GET)
@ApiOperation(value = "根据会员id获得商铺列表") @ApiOperation(value = "根据会员id获得商铺列表")
public Result getAllByUserId(String userId) { public Result getAllByUserId(String userId) {
List<Mall> list = mallService.findAllByUserId(userId); List<Mall> list = iMallService.findByUserId(userId);
return ResultUtil.data(list); return ResultUtil.data(list);
} }
} }

2
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/dao/GoodsAttributeValueDao.java

@ -6,5 +6,5 @@ import cc.hiver.shop.entity.GoodsAttributeValue;
import java.util.List; import java.util.List;
public interface GoodsAttributeValueDao extends HiverBaseDao<GoodsAttributeValue, String> { public interface GoodsAttributeValueDao extends HiverBaseDao<GoodsAttributeValue, String> {
List<GoodsAttributeValue> findAllBykAndAttributeId(String attributeId); List<GoodsAttributeValue> findAllByAttributeId(String attributeId);
} }

18
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/dao/GoodsCategoryDao.java

@ -3,5 +3,23 @@ package cc.hiver.shop.dao;
import cc.hiver.core.base.HiverBaseDao; import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.shop.entity.GoodsCategory; import cc.hiver.shop.entity.GoodsCategory;
import java.util.List;
public interface GoodsCategoryDao extends HiverBaseDao<GoodsCategory, String> { public interface GoodsCategoryDao extends HiverBaseDao<GoodsCategory, String> {
/**
* 通过父id获取 升序
*
* @param parentId
* @return
*/
List<GoodsCategory> findByParentIdOrderBySortOrder(String parentId);
/**
* 通过父id和状态获取 升序
*
* @param parentId
* @param status
* @return
*/
List<GoodsCategory> findByParentIdAndStatusOrderBySortOrder(String parentId, Integer status);
} }

3
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/dao/MallDao.java

@ -3,8 +3,5 @@ package cc.hiver.shop.dao;
import cc.hiver.core.base.HiverBaseDao; import cc.hiver.core.base.HiverBaseDao;
import cc.hiver.shop.entity.Mall; import cc.hiver.shop.entity.Mall;
import java.util.List;
public interface MallDao extends HiverBaseDao<Mall, String> { public interface MallDao extends HiverBaseDao<Mall, String> {
List<Mall> findAllByUserId(String userId);
} }

19
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/dao/mapper/MallMapper.java

@ -0,0 +1,19 @@
package cc.hiver.shop.dao.mapper;
import cc.hiver.shop.entity.Mall;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface MallMapper extends BaseMapper<Mall> {
/**
* 通过用户id获取
*
* @param userId
* @return
*/
List<Mall> findByUserId(@Param("userId") String userId);
}

3
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/dto/CustomAddressQueryCriteria.java

@ -7,6 +7,9 @@ import java.io.Serializable;
@Data @Data
public class CustomAddressQueryCriteria implements Serializable { public class CustomAddressQueryCriteria implements Serializable {
@Query
private String id;
@Query @Query
private String userId; private String userId;

2
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/service/GoodsAttributeValueService.java

@ -6,5 +6,5 @@ import cc.hiver.shop.entity.GoodsAttributeValue;
import java.util.List; import java.util.List;
public interface GoodsAttributeValueService extends HiverBaseService<GoodsAttributeValue, String> { public interface GoodsAttributeValueService extends HiverBaseService<GoodsAttributeValue, String> {
List<GoodsAttributeValue> findAllBykAndAttributeId(String attributeId); List<GoodsAttributeValue> findAllByAttributeId(String attributeId);
} }

18
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/service/GoodsCategoryService.java

@ -3,5 +3,23 @@ package cc.hiver.shop.service;
import cc.hiver.core.base.HiverBaseService; import cc.hiver.core.base.HiverBaseService;
import cc.hiver.shop.entity.GoodsCategory; import cc.hiver.shop.entity.GoodsCategory;
import java.util.List;
public interface GoodsCategoryService extends HiverBaseService<GoodsCategory, String> { public interface GoodsCategoryService extends HiverBaseService<GoodsCategory, String> {
/**
* 通过父id获取 升序
*
* @param parentId
* @return
*/
List<GoodsCategory> findByParentIdOrderBySortOrder(String parentId);
/**
* 通过父id和状态获取 升序
*
* @param parentId
* @param status
* @return
*/
List<GoodsCategory> findByParentIdAndStatusOrderBySortOrder(String parentId, Integer status);
} }

3
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/service/MallService.java

@ -3,8 +3,5 @@ package cc.hiver.shop.service;
import cc.hiver.core.base.HiverBaseService; import cc.hiver.core.base.HiverBaseService;
import cc.hiver.shop.entity.Mall; import cc.hiver.shop.entity.Mall;
import java.util.List;
public interface MallService extends HiverBaseService<Mall, String> { public interface MallService extends HiverBaseService<Mall, String> {
List<Mall> findAllByUserId(String userId);
} }

17
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/service/mybatis/IMallService.java

@ -0,0 +1,17 @@
package cc.hiver.shop.service.mybatis;
import cc.hiver.shop.entity.Mall;
import com.baomidou.mybatisplus.extension.service.IService;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface IMallService extends IService<Mall> {
/**
* 通过用户id获取
*
* @param userId
* @return
*/
List<Mall> findByUserId(@Param("userId") String userId);
}

4
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/serviceimpl/GoodsAttributeValueServiceImpl.java

@ -24,7 +24,7 @@ public class GoodsAttributeValueServiceImpl implements GoodsAttributeValueServic
} }
@Override @Override
public List<GoodsAttributeValue> findAllBykAndAttributeId(String attributeId) { public List<GoodsAttributeValue> findAllByAttributeId(String attributeId) {
return goodsAttributeValueDao.findAllBykAndAttributeId(attributeId); return goodsAttributeValueDao.findAllByAttributeId(attributeId);
} }
} }

12
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/serviceimpl/GoodsCategoryServiceImpl.java

@ -9,6 +9,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Slf4j @Slf4j
@Service @Service
@Transactional @Transactional
@ -20,4 +22,14 @@ public class GoodsCategoryServiceImpl implements GoodsCategoryService {
public HiverBaseDao<GoodsCategory, String> getRepository() { public HiverBaseDao<GoodsCategory, String> getRepository() {
return goodsCategoryDao; return goodsCategoryDao;
} }
@Override
public List<GoodsCategory> findByParentIdOrderBySortOrder(String parentId) {
return goodsCategoryDao.findByParentIdOrderBySortOrder(parentId);
}
@Override
public List<GoodsCategory> findByParentIdAndStatusOrderBySortOrder(String parentId, Integer status) {
return goodsCategoryDao.findByParentIdAndStatusOrderBySortOrder(parentId, status);
}
} }

7
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/serviceimpl/MallServiceImpl.java

@ -9,8 +9,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Slf4j @Slf4j
@Service @Service
@Transactional @Transactional
@ -22,9 +20,4 @@ public class MallServiceImpl implements MallService {
public HiverBaseDao<Mall, String> getRepository() { public HiverBaseDao<Mall, String> getRepository() {
return mallDao; return mallDao;
} }
@Override
public List<Mall> findAllByUserId(String userId) {
return mallDao.findAllByUserId(userId);
}
} }

21
hiver-modules/hiver-shop/src/main/java/cc/hiver/shop/serviceimpl/mybatis/IMallServiceImpl.java

@ -0,0 +1,21 @@
package cc.hiver.shop.serviceimpl.mybatis;
import cc.hiver.shop.dao.mapper.MallMapper;
import cc.hiver.shop.entity.Mall;
import cc.hiver.shop.service.mybatis.IMallService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class IMallServiceImpl extends ServiceImpl<MallMapper, Mall> implements IMallService {
@Autowired
private MallMapper mallMapper;
@Override
public List<Mall> findByUserId(String userId) {
return mallMapper.findByUserId(userId);
}
}

11
hiver-modules/hiver-shop/src/main/resources/mapper/MallMapper.xml

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cc.hiver.shop.dao.mapper.MallMapper">
<select id="findByUserId" resultType="cc.hiver.shop.entity.Mall">
SELECT DISTINCT m.*
FROM t_mall m
LEFT JOIN t_user_mall um ON m.id = um.mall_id
WHERE um.user_id = #{userId} AND m.status = 0
ORDER BY m.sort_order ASC
</select>
</mapper>
Loading…
Cancel
Save