修改新闻头条和万年历接口调用
parent
16d69b601b
commit
814b1b4825
|
@ -72,6 +72,10 @@ public class Product extends BaseEntity {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "产品上架日期",defaultValue = "2024-8-9 10:47:57",type = "Date")
|
||||
private Date productShelvesdate;
|
||||
/**
|
||||
* 接口来源
|
||||
*/
|
||||
private String productFrom;
|
||||
/**
|
||||
* 重要路径
|
||||
*/
|
||||
|
@ -104,6 +108,7 @@ public class Product extends BaseEntity {
|
|||
.returnFormat(productAddReq.getReturnFormat())
|
||||
.requestMethod(productAddReq.getRequestMethod())
|
||||
.apiRouter(productAddReq.getApiRouter())
|
||||
.productFrom(productAddReq.getProductFrom())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -123,6 +128,7 @@ public class Product extends BaseEntity {
|
|||
.returnFormat(productUpdReq.getReturnFormat())
|
||||
.requestMethod(productUpdReq.getRequestMethod())
|
||||
.apiRouter(productUpdReq.getApiRouter())
|
||||
.productFrom(productUpdReq.getProductFrom())
|
||||
.build();
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,10 @@ public class ProductAddReq {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "产品上架日期",defaultValue = "2024-8-9 10:47:57",type = "Date")
|
||||
private Date productShelvesdate;
|
||||
/**
|
||||
* 接口来源
|
||||
*/
|
||||
private String productFrom;
|
||||
/**
|
||||
*接口地址
|
||||
*/
|
||||
|
|
|
@ -53,6 +53,10 @@ public class ProductListReq {
|
|||
*接口地址
|
||||
*/
|
||||
private String apiAddress;
|
||||
/**
|
||||
* 接口来源
|
||||
*/
|
||||
private String productFrom;
|
||||
/**
|
||||
* 返回格式
|
||||
*/
|
||||
|
|
|
@ -63,6 +63,10 @@ public class ProductUpdReq {
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Schema(description = "产品上架日期",defaultValue = "2024-8-9 10:47:57",type = "Date")
|
||||
private Date productShelvesdate;
|
||||
/**
|
||||
* 接口来源
|
||||
*/
|
||||
private String productFrom;
|
||||
/**
|
||||
*接口地址
|
||||
*/
|
||||
|
|
|
@ -64,6 +64,10 @@ public class ProductListResp {
|
|||
* 重要路径
|
||||
*/
|
||||
private String apiRouter;
|
||||
/**
|
||||
* 接口来源
|
||||
*/
|
||||
private String productFrom;
|
||||
|
||||
@Schema(description = "创建人",defaultValue = "muyu",type = "String")
|
||||
private String createBy;
|
||||
|
@ -93,6 +97,7 @@ public class ProductListResp {
|
|||
.returnFormat(product.getReturnFormat())
|
||||
.requestMethod(product.getRequestMethod())
|
||||
.apiRouter(product.getApiRouter())
|
||||
.productFrom(product.getProductFrom())
|
||||
.createBy(product.getCreateBy())
|
||||
.createTime(product.getCreateTime())
|
||||
.build();
|
||||
|
|
|
@ -16,6 +16,10 @@ import java.util.stream.Collectors;
|
|||
* @name:News
|
||||
* @Date:2024/8/29 20:49
|
||||
*/
|
||||
|
||||
/**
|
||||
* 新闻头条
|
||||
*/
|
||||
@Configuration
|
||||
public class News {
|
||||
public static String fetchNews(String type, String page, String pageSize, String isFilter) throws Exception {
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
package com.muyu.cloud.background.controller;
|
||||
|
||||
import com.muyu.cloud.background.domin.Product;
|
||||
import com.muyu.cloud.background.domin.req.ProductAddReq;
|
||||
import com.muyu.cloud.background.domin.req.ProductListReq;
|
||||
import com.muyu.cloud.background.domin.req.ProductUpdReq;
|
||||
import com.muyu.cloud.background.domin.resp.ProductTotalListResp;
|
||||
import com.muyu.cloud.background.service.ApiManageService;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.background.controller
|
||||
* @Project:cloud-background
|
||||
* @name:ApiManageController
|
||||
* @Date:2024/8/30 9:27
|
||||
*/
|
||||
@Log4j2
|
||||
@RestController
|
||||
@RequestMapping("/apimanage")
|
||||
@Tag(name = "接口管理",description = "进行产品接口管理、查看等相关操作")
|
||||
public class ApiManageController {
|
||||
@Autowired
|
||||
private ApiManageService apiManageService;
|
||||
|
||||
/**
|
||||
* 查询全部产品接口
|
||||
* @param productListReq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(path ="/list")
|
||||
@Operation(summary = "产品列表",description = "查询全部产品信息")
|
||||
public Result<ProductTotalListResp> selectList(@Validated @RequestBody ProductListReq productListReq){
|
||||
return Result.success(apiManageService.selectList(productListReq));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加产品接口
|
||||
* @param productAddReq
|
||||
* @return
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "接口信息添加", description = "添加接口信息,添加成功才可以使用")
|
||||
public Result<String> save(@Validated @RequestBody ProductAddReq productAddReq){
|
||||
apiManageService.save(Product.addProductList(productAddReq));
|
||||
return Result.success(null,"操作成功");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改产品接口
|
||||
* @param productId
|
||||
* @param productUpdReq
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/{productId}")
|
||||
@Operation(summary = "接口信息修改", description = "通过ID修改接口信息")
|
||||
public Result<String> update(
|
||||
@Schema(title = "产品ID", type = "Integer", defaultValue = "1", description = "修改产品信息需要依据的唯一条件")
|
||||
@PathVariable("productId") Integer productId,
|
||||
@RequestBody @Validated ProductUpdReq productUpdReq) {
|
||||
apiManageService.updateById(Product.updProductList(productUpdReq,()->productId));
|
||||
return Result.success(null, "操作成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除产品接口
|
||||
* @param productId
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/{productId}")
|
||||
@Operation(summary = "接口信息删除",description = "通过Id删除接口信息")
|
||||
public Result<String> delete(@PathVariable("productId") Integer productId){
|
||||
apiManageService.removeById(productId);
|
||||
return Result.success(null, "操作成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -23,7 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
|||
@RestController
|
||||
@RequestMapping("/api")
|
||||
@Tag(name = "接口调用",description = "进行不同接口调用")
|
||||
public class ApiController {
|
||||
public class ApiUserController {
|
||||
|
||||
/**
|
||||
* 查询手机号归属地
|
||||
|
@ -43,7 +43,7 @@ public class ApiController {
|
|||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping("/bydate/{date}")
|
||||
@GetMapping("/·/{date}")
|
||||
@Operation(summary = "万年历",description = "查询万年历")
|
||||
public Result JavaGet(@Validated @PathVariable String date) throws Exception {
|
||||
Result result = DateCalendar.fetchCalendarData(date);
|
||||
|
@ -51,6 +51,12 @@ public class ApiController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新闻头条
|
||||
* @param newsdomain
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@PostMapping("/news")
|
||||
@Operation(summary = "新闻头条",description = "查询新闻头条")
|
||||
public Result JavaGet(@Validated @RequestBody Newsdomain newsdomain) throws Exception {
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.cloud.background.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.muyu.cloud.background.domin.Product;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.background.mapper
|
||||
* @Project:cloud-background
|
||||
* @name:ApiManageMapper
|
||||
* @Date:2024/8/30 9:34
|
||||
*/
|
||||
@Mapper
|
||||
public interface ApiManageMapper extends BaseMapper<Product> {
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.muyu.cloud.background.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.muyu.cloud.background.domin.Product;
|
||||
import com.muyu.cloud.background.domin.req.ProductListReq;
|
||||
import com.muyu.cloud.background.domin.resp.ProductTotalListResp;
|
||||
import com.muyu.cloud.background.mapper.ApiManageMapper;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.background.service
|
||||
* @Project:cloud-background
|
||||
* @name:ApiManageService
|
||||
* @Date:2024/8/30 9:33
|
||||
*/
|
||||
public interface ApiManageService extends IService<Product> {
|
||||
|
||||
|
||||
/**
|
||||
* 查询全部商品接口
|
||||
* @param productListReq
|
||||
* @return
|
||||
*/
|
||||
ProductTotalListResp selectList(ProductListReq productListReq);
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.muyu.cloud.background.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.cloud.background.domin.Product;
|
||||
import com.muyu.cloud.background.domin.req.ProductListReq;
|
||||
import com.muyu.cloud.background.domin.resp.ProductListResp;
|
||||
import com.muyu.cloud.background.domin.resp.ProductTotalListResp;
|
||||
import com.muyu.cloud.background.mapper.ApiManageMapper;
|
||||
import com.muyu.cloud.background.service.ApiManageService;
|
||||
import com.muyu.common.core.utils.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:weiran
|
||||
* @Package:com.muyu.cloud.background.service.impl
|
||||
* @Project:cloud-background
|
||||
* @name:ApiManageServiceImpl
|
||||
* @Date:2024/8/30 9:34
|
||||
*/
|
||||
@Service
|
||||
public class ApiManageServiceImpl extends ServiceImpl<ApiManageMapper, Product> implements ApiManageService {
|
||||
|
||||
/**
|
||||
* 查询全部商品接口
|
||||
* @param productListReq
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ProductTotalListResp selectList(ProductListReq productListReq) {
|
||||
Integer pageNum = productListReq.getPageNum();
|
||||
Integer pageSize = productListReq.getPageSize();
|
||||
LambdaQueryWrapper<Product> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(StringUtils.isNotEmpty(productListReq.getProductName()),
|
||||
Product::getProductName,productListReq.getProductName());
|
||||
queryWrapper.eq(StringUtils.isNotEmpty(productListReq.getProductState()),
|
||||
Product::getProductState,productListReq.getProductState());
|
||||
queryWrapper.eq(StringUtils.isNotEmpty(productListReq.getProductType()),
|
||||
Product::getProductType,productListReq.getProductType());
|
||||
long count = this.count(queryWrapper);
|
||||
queryWrapper.orderByDesc(Product::getProductSales);
|
||||
queryWrapper.last("LIMIT " + ((pageNum - 1) * pageSize) + ", " + pageSize);
|
||||
List<Product> productList = this.list(queryWrapper);
|
||||
List<ProductListResp> productListResps = productList.stream()
|
||||
.map(product -> ProductListResp.productListRespbuild(product))
|
||||
.toList();
|
||||
return ProductTotalListResp.of(productListResps, count);
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue