Browse Source

增加小程序请求商品词条接口

zyj
sj 2 years ago
parent
commit
5bb10fe988
  1. 46
      zsw-bxg/src/main/java/co/yixiang/app/modules/entry/rest/AppStoreEntryController.java
  2. 66
      zsw-bxg/src/main/java/co/yixiang/modules/entry/domain/YxStoreEntry.java
  3. 88
      zsw-bxg/src/main/java/co/yixiang/modules/entry/rest/YxStoreEntryController.java
  4. 53
      zsw-bxg/src/main/java/co/yixiang/modules/entry/service/YxStoreEntryService.java
  5. 42
      zsw-bxg/src/main/java/co/yixiang/modules/entry/service/dto/YxStoreEntryDto.java
  6. 19
      zsw-bxg/src/main/java/co/yixiang/modules/entry/service/dto/YxStoreEntryQueryCriteria.java
  7. 103
      zsw-bxg/src/main/java/co/yixiang/modules/entry/service/impl/YxStoreEntryServiceImpl.java
  8. 25
      zsw-bxg/src/main/java/co/yixiang/modules/entry/service/mapper/YxStoreEntryMapper.java
  9. 2
      zsw-bxg/src/main/java/co/yixiang/modules/expert/domain/YxStoreExpert.java
  10. 4
      zsw-bxg/src/main/java/co/yixiang/modules/expert/rest/YxStoreExpertController.java
  11. 2
      zsw-bxg/src/main/java/co/yixiang/modules/expert/service/YxStoreExpertService.java
  12. 2
      zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertDto.java
  13. 2
      zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertQueryCriteria.java
  14. 2
      zsw-bxg/src/main/java/co/yixiang/modules/expert/service/mapper/YxStoreExpertMapper.java
  15. 4
      zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProduct.java
  16. 4
      zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductDto.java
  17. 13
      zsw-bxg/src/main/java/co/yixiang/utils/EntryDTO.java

46
zsw-bxg/src/main/java/co/yixiang/app/modules/entry/rest/AppStoreEntryController.java

@ -0,0 +1,46 @@
package co.yixiang.app.modules.entry.rest;
import cn.iocoder.yudao.framework.common.pojo.ApiResult;
import co.yixiang.annotation.AnonymousAccess;
import co.yixiang.modules.entry.service.YxStoreEntryService;
import co.yixiang.utils.EntryDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 商品评测控制器
* </p>
*
* @author ssj
* @since 2022-9-27
*/
@Slf4j
@RestController
@Api(value = "查询词条讲解", tags = "商城:商品词条")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class AppStoreEntryController {
private final YxStoreEntryService yxStoreEntryService;
/**
* 查询词条讲解
*/
@AnonymousAccess
@GetMapping("/entry{id}")
@ApiOperation(value = "词条查询",notes = "词条")
public ApiResult<EntryDTO> getYxEntry(@PathVariable int id){
EntryDTO entryDTO=yxStoreEntryService.getEntry(id);
return ApiResult.ok(entryDTO);
}
}

66
zsw-bxg/src/main/java/co/yixiang/modules/entry/domain/YxStoreEntry.java

@ -0,0 +1,66 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖分享上传到码云github等开源平台
* 一经发现盗用分享等行为将追究法律责任后果自负
*/
package co.yixiang.modules.entry.domain;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import com.baomidou.mybatisplus.annotation.TableName;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.validation.constraints.*;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author sj
* @date 2022-09-27
*/
@Data
@TableName("yx_store_entry")
public class YxStoreEntry implements Serializable {
/** 词条id */
@TableId
private Long id;
/** 租户id */
@NotNull
private Long tenantId;
/** 词条名称 */
@NotBlank
private String entryName;
/** 词条讲解 */
@NotBlank
private String entryInfo;
/** 添加时间 */
@TableField(fill= FieldFill.INSERT)
private Timestamp createTime;
/** 更新时间 */
@TableField(fill= FieldFill.INSERT_UPDATE)
private Timestamp updateTime;
/** 是否删除 */
private Integer isDel;
public void copy(YxStoreEntry source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

88
zsw-bxg/src/main/java/co/yixiang/modules/entry/rest/YxStoreEntryController.java

@ -0,0 +1,88 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖分享上传到码云github等开源平台
* 一经发现盗用分享等行为将追究法律责任后果自负
*/
package co.yixiang.modules.entry.rest;
import co.yixiang.domain.PageResult;
import co.yixiang.dozer.service.IGenerator;
import co.yixiang.logging.aop.log.Log;
import co.yixiang.modules.entry.service.YxStoreEntryService;
import co.yixiang.modules.entry.service.dto.YxStoreEntryDto;
import co.yixiang.modules.entry.service.dto.YxStoreEntryQueryCriteria;
import co.yixiang.modules.entry.domain.YxStoreEntry;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
/**
* @author ssj
* @date 2022-09-27
*/
@AllArgsConstructor
@Api(tags = " 商品词条管理")
@RestController
@RequestMapping("/api/yxStoreEntry")
public class YxStoreEntryController {
private final YxStoreEntryService yxStoreEntryService;
private final IGenerator generator;
@Log("导出数据")
@ApiOperation("导出数据")
@GetMapping(value = "/download")
// @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreExpert:list')")
public void download(HttpServletResponse response, YxStoreEntryQueryCriteria criteria) throws IOException {
yxStoreEntryService.download(generator.convert(yxStoreEntryService.queryAll(criteria), YxStoreEntryDto.class), response);
}
@GetMapping
@Log("查询 商品词条")
@ApiOperation("查询 商品词条")
// @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreExpert:list')")
public ResponseEntity<PageResult<YxStoreEntryDto>> getYxStoreEntrys(YxStoreEntryQueryCriteria criteria, Pageable pageable){
return new ResponseEntity<>(yxStoreEntryService.queryAll(criteria,pageable),HttpStatus.OK);
}
@PostMapping
@Log("新增 商品词条")
@ApiOperation("新增 商品词条")
// @PreAuthorize("ss.hasAnyPermissions('admin','yxStoreExpert:add')")
public ResponseEntity<Object> create(@Validated @RequestBody YxStoreEntry resources){
return new ResponseEntity<>(yxStoreEntryService.save(resources),HttpStatus.CREATED);
}
@PutMapping
@Log("修改 商品词条")
@ApiOperation("修改 商品词条")
// @PreAuthorize("@ss.hasAnyPermissions('admin','yxStoreExpert:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody YxStoreEntry resources){
yxStoreEntryService.updateById(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
@Log("删除 商品词条")
@ApiOperation("删除 商品词条")
// @PreAuthorize("@ss.hasAnyPermissions ('admin','yxStoreExpert:del')")
@DeleteMapping
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
Arrays.asList(ids).forEach(id->{
yxStoreEntryService.removeById(id);
});
return new ResponseEntity<>(HttpStatus.OK);
}
}

53
zsw-bxg/src/main/java/co/yixiang/modules/entry/service/YxStoreEntryService.java

@ -0,0 +1,53 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖分享上传到码云github等开源平台
* 一经发现盗用分享等行为将追究法律责任后果自负
*/
package co.yixiang.modules.entry.service;
import co.yixiang.common.service.BaseService;
import co.yixiang.domain.PageResult;
import co.yixiang.modules.entry.domain.YxStoreEntry;
import co.yixiang.modules.entry.service.dto.YxStoreEntryDto;
import co.yixiang.modules.entry.service.dto.YxStoreEntryQueryCriteria;
import co.yixiang.modules.product.vo.ProductVo;
import co.yixiang.utils.EntryDTO;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author sj
* @date 2022-09-27
*/
public interface YxStoreEntryService extends BaseService<YxStoreEntry> {
/**
* 查询数据分页
* @param criteria 条件
* @param pageable 分页参数
* @return Map<String,Object>
*/
PageResult<YxStoreEntryDto> queryAll(YxStoreEntryQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<YxStoreEntryDto>
*/
List<YxStoreEntry> queryAll(YxStoreEntryQueryCriteria criteria);
/**
* 导出数据
* @param all 待导出的数据
* @param response /
* @throws IOException /
*/
void download(List<YxStoreEntryDto> all, HttpServletResponse response) throws IOException;
EntryDTO getEntry(int id);
}

42
zsw-bxg/src/main/java/co/yixiang/modules/entry/service/dto/YxStoreEntryDto.java

@ -0,0 +1,42 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖分享上传到码云github等开源平台
* 一经发现盗用分享等行为将追究法律责任后果自负
*/
package co.yixiang.modules.entry.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author sj
* @date 2022-09-27
*/
@Data
public class YxStoreEntryDto implements Serializable {
/** 词条id */
private Long id;
/** 租户id */
private Long tenantId;
/** 词条名称 */
private String entryName;
/** 词条讲解 */
private String entryInfo;
/** 添加时间 */
private Timestamp createTime;
/** 更新时间 */
private Timestamp updateTime;
/** 是否删除 */
private Integer isDel;
}

19
zsw-bxg/src/main/java/co/yixiang/modules/entry/service/dto/YxStoreEntryQueryCriteria.java

@ -0,0 +1,19 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖分享上传到码云github等开源平台
* 一经发现盗用分享等行为将追究法律责任后果自负
*/
package co.yixiang.modules.entry.service.dto;
import lombok.Data;
/**
* @author sj
* @date 2022-09-27
*/
@Data
public class YxStoreEntryQueryCriteria{
}

103
zsw-bxg/src/main/java/co/yixiang/modules/entry/service/impl/YxStoreEntryServiceImpl.java

@ -0,0 +1,103 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖分享上传到码云github等开源平台
* 一经发现盗用分享等行为将追究法律责任后果自负
*/
package co.yixiang.modules.entry.service.impl;
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.enums.CommonEnum;
import co.yixiang.modules.entry.domain.YxStoreEntry;
import co.yixiang.modules.entry.service.YxStoreEntryService;
import co.yixiang.modules.entry.service.dto.YxStoreEntryDto;
import co.yixiang.modules.entry.service.dto.YxStoreEntryQueryCriteria;
import co.yixiang.modules.entry.service.mapper.YxStoreEntryMapper;
import co.yixiang.modules.product.domain.YxStoreProduct;
import co.yixiang.modules.product.service.YxStoreProductService;
import co.yixiang.utils.EntryDTO;
import co.yixiang.utils.FileUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
/**
* @author sj
* @date 2022-09-27
*/
@Service
@AllArgsConstructor
//@CacheConfig(cacheNames = "yxStoreEntry")
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class YxStoreEntryServiceImpl extends BaseServiceImpl<YxStoreEntryMapper, YxStoreEntry> implements YxStoreEntryService {
private final IGenerator generator;
private final YxStoreEntryMapper yxStoreEntryMapper;
@Override
//@Cacheable
public PageResult<YxStoreEntryDto> queryAll(YxStoreEntryQueryCriteria criteria, Pageable pageable) {
getPage(pageable);
PageInfo<YxStoreEntry> page = new PageInfo<>(queryAll(criteria));
return generator.convertPageInfo(page,YxStoreEntryDto.class);
}
@Override
//@Cacheable
public List<YxStoreEntry> queryAll(YxStoreEntryQueryCriteria criteria){
return baseMapper.selectList(QueryHelpPlus.getPredicate(YxStoreEntry.class, criteria));
}
@Override
public void download(List<YxStoreEntryDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (YxStoreEntryDto yxStoreEntry : all) {
Map<String,Object> map = new LinkedHashMap<>();
map.put("租户id", yxStoreEntry.getTenantId());
map.put("词条名称", yxStoreEntry.getEntryName());
map.put("词条讲解", yxStoreEntry.getEntryInfo());
map.put("添加时间", yxStoreEntry.getCreateTime());
map.put("更新时间", yxStoreEntry.getUpdateTime());
map.put("是否删除", yxStoreEntry.getIsDel());
list.add(map);
}
FileUtil.downloadExcel(list, response);
}
@Override
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "词条ID", paramType = "query", dataType = "int",dataTypeClass = Integer.class)
})
public EntryDTO getEntry(int id) {
LambdaQueryWrapper<YxStoreEntry> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(YxStoreEntry::getIsDel, CommonEnum.DEL_STATUS_0.getValue()).eq(YxStoreEntry::getId, id);
YxStoreEntry yxStoreEntry=yxStoreEntryMapper.selectOne(wrapper);
EntryDTO entryDTO=new EntryDTO();
//取出需要的属性
entryDTO.setEntryName(yxStoreEntry.getEntryName());
entryDTO.setEntryInfo(yxStoreEntry.getEntryInfo());
return entryDTO;
}
}

25
zsw-bxg/src/main/java/co/yixiang/modules/entry/service/mapper/YxStoreEntryMapper.java

@ -0,0 +1,25 @@
/**
* Copyright (C) 2018-2020
* All rights reserved, Designed By www.yixiang.co
* 注意
* 本软件为www.yixiang.co开发研制未经购买不得使用
* 购买后可获得全部源代码禁止转卖分享上传到码云github等开源平台
* 一经发现盗用分享等行为将追究法律责任后果自负
*/
package co.yixiang.modules.entry.service.mapper;
import co.yixiang.common.mapper.CoreMapper;
import co.yixiang.modules.entry.domain.YxStoreEntry;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author sj
* @date 2022-09-27
*/
@Repository
public interface YxStoreEntryMapper extends CoreMapper<YxStoreEntry> {
}

2
zsw-bxg/src/main/java/co/yixiang/modules/expert/domain/YxStoreExpert.java

@ -20,7 +20,7 @@ import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author hupeng
* @author sj
* @date 2022-09-17
*/
@Data

4
zsw-bxg/src/main/java/co/yixiang/modules/expert/rest/YxStoreExpertController.java

@ -29,11 +29,11 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
/**
* @author hupeng
* @author ssj
* @date 2022-09-17
*/
@AllArgsConstructor
@Api(tags = " ss管理")
@Api(tags = " 专家管理")
@RestController
@RequestMapping("/api/yxStoreExpert")
public class YxStoreExpertController {

2
zsw-bxg/src/main/java/co/yixiang/modules/expert/service/YxStoreExpertService.java

@ -20,7 +20,7 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
/**
* @author hupeng
* @author sj
* @date 2022-09-17
*/
public interface YxStoreExpertService extends BaseService<YxStoreExpert> {

2
zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertDto.java

@ -15,7 +15,7 @@ import java.sql.Timestamp;
import java.io.Serializable;
/**
* @author hupeng
* @author sj
* @date 2022-09-17
*/
@Data

2
zsw-bxg/src/main/java/co/yixiang/modules/expert/service/dto/YxStoreExpertQueryCriteria.java

@ -11,7 +11,7 @@ package co.yixiang.modules.expert.service.dto;
import lombok.Data;
/**
* @author hupeng
* @author sj
* @date 2022-09-17
*/
@Data

2
zsw-bxg/src/main/java/co/yixiang/modules/expert/service/mapper/YxStoreExpertMapper.java

@ -13,7 +13,7 @@ import co.yixiang.modules.expert.domain.YxStoreExpert;
import org.springframework.stereotype.Repository;
/**
* @author hupeng
* @author sj
* @date 2022-09-17
*/
@Repository

4
zsw-bxg/src/main/java/co/yixiang/modules/product/domain/YxStoreProduct.java

@ -90,8 +90,8 @@ public class YxStoreProduct extends BaseDomain {
@ApiModelProperty(value = "分类id")
private String cateId;
/** 品牌id (默认无品牌)*/
@JsonProperty("brand_id")
/** 品牌id */
@ApiModelProperty(value = "品牌id")
private String brandId;
/** 商品价格 */

4
zsw-bxg/src/main/java/co/yixiang/modules/product/service/dto/ProductDto.java

@ -53,6 +53,10 @@ public class ProductDto
@JsonProperty("cate_id")
private String cateId;
/** 品牌id */
@JsonProperty("brand_id")
private String brandId;
/** 商品价格 */
private Double price;

13
zsw-bxg/src/main/java/co/yixiang/utils/EntryDTO.java

@ -0,0 +1,13 @@
package co.yixiang.utils;
import lombok.Data;
import java.io.Serializable;
@Data
public class EntryDTO implements Serializable {
/** 词条名称 */
private String entryName;
/** 词条讲解 */
private String entryInfo;
}
Loading…
Cancel
Save