添加足迹,收藏后端管理接口
This commit is contained in:
@ -10,9 +10,14 @@ package co.yixiang.modules.product.service;
|
|||||||
|
|
||||||
|
|
||||||
import co.yixiang.common.service.BaseService;
|
import co.yixiang.common.service.BaseService;
|
||||||
|
import co.yixiang.domain.PageResult;
|
||||||
import co.yixiang.modules.product.domain.YxStoreProductRelation;
|
import co.yixiang.modules.product.domain.YxStoreProductRelation;
|
||||||
|
import co.yixiang.modules.product.service.dto.YxStoreProductRelationDto;
|
||||||
|
import co.yixiang.modules.product.service.dto.YxStoreProductRelationQueryCriteria;
|
||||||
import co.yixiang.modules.product.vo.YxStoreProductRelationQueryVo;
|
import co.yixiang.modules.product.vo.YxStoreProductRelationQueryVo;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +61,28 @@ public interface YxStoreProductRelationService extends BaseService<YxStoreProduc
|
|||||||
*/
|
*/
|
||||||
List<YxStoreProductRelationQueryVo> userCollectProduct(int page, int limit, Long uid,String type);
|
List<YxStoreProductRelationQueryVo> userCollectProduct(int page, int limit, Long uid,String type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询数据分页
|
||||||
|
* @param criteria 条件
|
||||||
|
* @param pageable 分页参数
|
||||||
|
* @return Map<String,Object>
|
||||||
|
*/
|
||||||
|
PageResult<YxStoreProductRelationDto> queryAll(YxStoreProductRelationQueryCriteria criteria, Pageable pageable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有数据不分页
|
||||||
|
* @param criteria 条件参数
|
||||||
|
* @return List<YxStoreProductRelationDto>
|
||||||
|
*/
|
||||||
|
List<YxStoreProductRelation> queryAll(YxStoreProductRelationQueryCriteria criteria);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出数据
|
||||||
|
* @param all 待导出的数据
|
||||||
|
* @param response /
|
||||||
|
* @throws IOException /
|
||||||
|
*/
|
||||||
|
void download(List<YxStoreProductRelationDto> all, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2018-2020
|
||||||
|
* All rights reserved, Designed By www.yixiang.co
|
||||||
|
* 注意:
|
||||||
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用
|
||||||
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
|
||||||
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
||||||
|
*/
|
||||||
|
package co.yixiang.modules.product.service.dto;
|
||||||
|
|
||||||
|
import co.yixiang.modules.product.domain.YxStoreProduct;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.sql.Timestamp;
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hupeng
|
||||||
|
* @date 2020-09-03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class YxStoreProductRelationDto implements Serializable {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 用户ID */
|
||||||
|
private Long uid;
|
||||||
|
|
||||||
|
private String userName;
|
||||||
|
|
||||||
|
/** 商品ID */
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
private YxStoreProduct product;
|
||||||
|
|
||||||
|
/** 类型(收藏(collect)、点赞(like)) */
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/** 某种类型的商品(普通商品、秒杀商品) */
|
||||||
|
private String category;
|
||||||
|
|
||||||
|
/** 添加时间 */
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Timestamp createTime;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private Timestamp updateTime;
|
||||||
|
|
||||||
|
private Integer isDel;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2018-2020
|
||||||
|
* All rights reserved, Designed By www.yixiang.co
|
||||||
|
* 注意:
|
||||||
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用
|
||||||
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
|
||||||
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
||||||
|
*/
|
||||||
|
package co.yixiang.modules.product.service.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import java.util.List;
|
||||||
|
import co.yixiang.annotation.Query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author hupeng
|
||||||
|
* @date 2020-09-03
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class YxStoreProductRelationQueryCriteria{
|
||||||
|
@Query(type = Query.Type.EQUAL)
|
||||||
|
private String type;
|
||||||
|
}
|
@ -10,18 +10,33 @@ package co.yixiang.modules.product.service.impl;
|
|||||||
|
|
||||||
import co.yixiang.api.YshopException;
|
import co.yixiang.api.YshopException;
|
||||||
import co.yixiang.common.service.impl.BaseServiceImpl;
|
import co.yixiang.common.service.impl.BaseServiceImpl;
|
||||||
|
import co.yixiang.common.utils.QueryHelpPlus;
|
||||||
|
import co.yixiang.domain.PageResult;
|
||||||
|
import co.yixiang.dozer.service.IGenerator;
|
||||||
import co.yixiang.modules.product.domain.YxStoreProductRelation;
|
import co.yixiang.modules.product.domain.YxStoreProductRelation;
|
||||||
import co.yixiang.modules.product.service.YxStoreProductRelationService;
|
import co.yixiang.modules.product.service.YxStoreProductRelationService;
|
||||||
|
import co.yixiang.modules.product.service.YxStoreProductService;
|
||||||
|
import co.yixiang.modules.product.service.dto.YxStoreProductRelationDto;
|
||||||
|
import co.yixiang.modules.product.service.dto.YxStoreProductRelationQueryCriteria;
|
||||||
import co.yixiang.modules.product.service.mapper.YxStoreProductRelationMapper;
|
import co.yixiang.modules.product.service.mapper.YxStoreProductRelationMapper;
|
||||||
import co.yixiang.modules.product.vo.YxStoreProductRelationQueryVo;
|
import co.yixiang.modules.product.vo.YxStoreProductRelationQueryVo;
|
||||||
|
import co.yixiang.modules.user.service.YxUserService;
|
||||||
|
import co.yixiang.utils.FileUtil;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -39,7 +54,9 @@ import java.util.List;
|
|||||||
public class YxStoreProductRelationServiceImpl extends BaseServiceImpl<YxStoreProductRelationMapper, YxStoreProductRelation> implements YxStoreProductRelationService {
|
public class YxStoreProductRelationServiceImpl extends BaseServiceImpl<YxStoreProductRelationMapper, YxStoreProductRelation> implements YxStoreProductRelationService {
|
||||||
|
|
||||||
private final YxStoreProductRelationMapper yxStoreProductRelationMapper;
|
private final YxStoreProductRelationMapper yxStoreProductRelationMapper;
|
||||||
|
private final YxStoreProductService storeProductService;
|
||||||
|
private final YxUserService userService;
|
||||||
|
private final IGenerator generator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户收藏列表
|
* 获取用户收藏列表
|
||||||
@ -113,4 +130,42 @@ public class YxStoreProductRelationServiceImpl extends BaseServiceImpl<YxStorePr
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
//@Cacheable
|
||||||
|
public PageResult<YxStoreProductRelationDto> queryAll(YxStoreProductRelationQueryCriteria criteria, Pageable pageable) {
|
||||||
|
getPage(pageable);
|
||||||
|
PageInfo<YxStoreProductRelation> page = new PageInfo<>(queryAll(criteria));
|
||||||
|
PageResult<YxStoreProductRelationDto> relationDtoPageResult = generator.convertPageInfo(page, YxStoreProductRelationDto.class);
|
||||||
|
relationDtoPageResult.getContent().forEach(i ->{
|
||||||
|
i.setProduct(storeProductService.getById(i.getProductId()));
|
||||||
|
i.setUserName(userService.getYxUserById(i.getUid()).getUsername());
|
||||||
|
});
|
||||||
|
return relationDtoPageResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
//@Cacheable
|
||||||
|
public List<YxStoreProductRelation> queryAll(YxStoreProductRelationQueryCriteria criteria){
|
||||||
|
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreProductRelation.class, criteria));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void download(List<YxStoreProductRelationDto> all, HttpServletResponse response) throws IOException {
|
||||||
|
List<Map<String, Object>> list = new ArrayList<>();
|
||||||
|
for (YxStoreProductRelationDto yxStoreProductRelation : all) {
|
||||||
|
Map<String,Object> map = new LinkedHashMap<>();
|
||||||
|
map.put("用户ID", yxStoreProductRelation.getUid());
|
||||||
|
map.put("商品ID", yxStoreProductRelation.getProductId());
|
||||||
|
map.put("类型(收藏(collect)、点赞(like))", yxStoreProductRelation.getType());
|
||||||
|
map.put("某种类型的商品(普通商品、秒杀商品)", yxStoreProductRelation.getCategory());
|
||||||
|
map.put("添加时间", yxStoreProductRelation.getCreateTime());
|
||||||
|
map.put(" updateTime", yxStoreProductRelation.getUpdateTime());
|
||||||
|
map.put(" isDel", yxStoreProductRelation.getIsDel());
|
||||||
|
list.add(map);
|
||||||
|
}
|
||||||
|
FileUtil.downloadExcel(list, response);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,85 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (C) 2018-2020
|
||||||
|
* All rights reserved, Designed By www.yixiang.co
|
||||||
|
* 注意:
|
||||||
|
* 本软件为www.yixiang.co开发研制,未经购买不得使用
|
||||||
|
* 购买后可获得全部源代码(禁止转卖、分享、上传到码云、github等开源平台)
|
||||||
|
* 一经发现盗用、分享等行为,将追究法律责任,后果自负
|
||||||
|
*/
|
||||||
|
package co.yixiang.modules.shop.rest;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import co.yixiang.dozer.service.IGenerator;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import co.yixiang.logging.aop.log.Log;
|
||||||
|
import co.yixiang.modules.product.domain.YxStoreProductRelation;
|
||||||
|
import co.yixiang.modules.product.service.YxStoreProductRelationService;
|
||||||
|
import co.yixiang.modules.product.service.dto.YxStoreProductRelationQueryCriteria;
|
||||||
|
import co.yixiang.modules.product.service.dto.YxStoreProductRelationDto;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import io.swagger.annotations.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import co.yixiang.domain.PageResult;
|
||||||
|
/**
|
||||||
|
* @author hupeng
|
||||||
|
* @date 2020-09-03
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Api(tags = "ProductRelation管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/api/yxStoreProductRelation")
|
||||||
|
public class YxStoreProductRelationController {
|
||||||
|
|
||||||
|
private final YxStoreProductRelationService yxStoreProductRelationService;
|
||||||
|
private final IGenerator generator;
|
||||||
|
|
||||||
|
|
||||||
|
@Log("导出数据")
|
||||||
|
@ApiOperation("导出数据")
|
||||||
|
@GetMapping(value = "/download")
|
||||||
|
@PreAuthorize("@el.check('admin','yxStoreProductRelation:list')")
|
||||||
|
public void download(HttpServletResponse response, YxStoreProductRelationQueryCriteria criteria) throws IOException {
|
||||||
|
yxStoreProductRelationService.download(generator.convert(yxStoreProductRelationService.queryAll(criteria), YxStoreProductRelationDto.class), response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
@Log("查询ProductRelation")
|
||||||
|
@ApiOperation("查询ProductRelation")
|
||||||
|
@PreAuthorize("@el.check('admin','yxStoreProductRelation:list')")
|
||||||
|
public ResponseEntity<PageResult<YxStoreProductRelationDto>> getYxStoreProductRelations(YxStoreProductRelationQueryCriteria criteria, Pageable pageable){
|
||||||
|
return new ResponseEntity<>(yxStoreProductRelationService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@Log("新增ProductRelation")
|
||||||
|
@ApiOperation("新增ProductRelation")
|
||||||
|
@PreAuthorize("@el.check('admin','yxStoreProductRelation:add')")
|
||||||
|
public ResponseEntity<Object> create(@Validated @RequestBody YxStoreProductRelation resources){
|
||||||
|
return new ResponseEntity<>(yxStoreProductRelationService.save(resources),HttpStatus.CREATED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@Log("修改ProductRelation")
|
||||||
|
@ApiOperation("修改ProductRelation")
|
||||||
|
@PreAuthorize("@el.check('admin','yxStoreProductRelation:edit')")
|
||||||
|
public ResponseEntity<Object> update(@Validated @RequestBody YxStoreProductRelation resources){
|
||||||
|
yxStoreProductRelationService.updateById(resources);
|
||||||
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Log("删除ProductRelation")
|
||||||
|
@ApiOperation("删除ProductRelation")
|
||||||
|
@PreAuthorize("@el.check('admin','yxStoreProductRelation:del')")
|
||||||
|
@DeleteMapping
|
||||||
|
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
|
||||||
|
Arrays.asList(ids).forEach(id->{
|
||||||
|
yxStoreProductRelationService.removeById(id);
|
||||||
|
});
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user