diff --git a/cloud-market2-common/src/main/java/com/muyu/market/admain/Belong.java b/cloud-market2-common/src/main/java/com/muyu/market/admain/Belong.java new file mode 100644 index 0000000..73cbed2 --- /dev/null +++ b/cloud-market2-common/src/main/java/com/muyu/market/admain/Belong.java @@ -0,0 +1,109 @@ +package com.muyu.market.admain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.muyu.common.core.web.domain.BaseEntity; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@SuperBuilder +@TableName(value = "market_belong",autoResultMap = true) +@EqualsAndHashCode(callSuper = true) +public class Belong extends BaseEntity { + /** + * 主键 + */ + @TableId(value = "belong_id",type = IdType.AUTO) + private Long belongId; + /** + * 接口名称 + */ + @Schema(type = "String",description = "接口名称") + private String name; + /** + * 价钱/次 + */ + @Schema(type = "BigDecimal",description = "价钱/次") + private BigDecimal price; + /** + * 介绍 + */ + @Schema(type = "String",description = "介绍") + private String test; + /** + * 我的数据 + */ + @Schema(type = "String",description = "我的数据") + private String data; + /** + * 接口名称 + */ + @Schema(type = "String",description = "接口名称") + private String apiName; + /** + * 接口地址 + */ + @Schema(type = "String",description = "接口地址") + private String ip; + /** + * 请求方式 + */ + @Schema(type = "String",description = "请求方式") + private String mode; + /** + * API类型 + */ + @Schema(type = "String",description = "API类型") + private String type; + /** + * 返回报文 + */ + @Schema(type = "String",description = "返回报文") + private String msgresp; + /** + * + */ + @Schema(type = "String",description = "1") + private String createBy; + /** + * + */ + @Schema(type = "Date",description = "1") + private Date createTime; + /** + * + */ + @Schema(type = "String",description = "1") + private String updateBy; + /** + * + */ + @Schema(type = "Date",description = "sb") + private Date updateTime; + /** + * + */ + @Schema(type = "String",description = "备注") + private String remark; + /** + * 购买人信息 + */ + @Schema(type = "Integer",description = "购买人信息") + private Integer userId; + /** + * 剩余使用次数 + */ + @Schema(type = "Integer",description = "剩余使用次数") + private Integer num; +} diff --git a/cloud-market2-common/src/main/java/com/muyu/market/admain/Myapi.java b/cloud-market2-common/src/main/java/com/muyu/market/admain/Myapi.java index d0df9ad..f6703ea 100644 --- a/cloud-market2-common/src/main/java/com/muyu/market/admain/Myapi.java +++ b/cloud-market2-common/src/main/java/com/muyu/market/admain/Myapi.java @@ -64,11 +64,6 @@ public class Myapi extends BaseEntity{ */ @Schema(description = "请求方式",type = "String") private String mode; - /** - * 购买字段 - */ - @Schema(description = "购买字段(当修改成功触发)",type = "Integer") - private int auth; /* API类型 */ @@ -79,7 +74,11 @@ public class Myapi extends BaseEntity{ */ @Schema(description = "API返回报文",type = "String") private String msgresp; - + /* + 购买触发 + */ + @Schema(description = "购买触发",type = "Integer") + private Integer buy; private String createBy; private Date createTime; private String updateBy; @@ -96,7 +95,6 @@ public class Myapi extends BaseEntity{ .apiName( myapiSaveReq.getApiName()) .ip( myapiSaveReq.getIp()) .mode( myapiSaveReq.getMode()) - .auth( myapiSaveReq.getAuth() ) .type( myapiSaveReq.getType()) .msgresp(myapiSaveReq.getMsgresp()) .build(); @@ -115,7 +113,6 @@ public class Myapi extends BaseEntity{ .apiName( myapiUpdReq.getApiName()) .ip( myapiUpdReq.getIp()) .mode( myapiUpdReq.getMode()) - .auth( myapiUpdReq.getAuth() ) .type( myapiUpdReq.getType()) .msgresp(myapiUpdReq.getMsgresp()) .build(); diff --git a/cloud-market2-common/src/main/java/com/muyu/market/admain/request/MyapiSaveReq.java b/cloud-market2-common/src/main/java/com/muyu/market/admain/request/MyapiSaveReq.java index bedfb88..c7e0ef6 100644 --- a/cloud-market2-common/src/main/java/com/muyu/market/admain/request/MyapiSaveReq.java +++ b/cloud-market2-common/src/main/java/com/muyu/market/admain/request/MyapiSaveReq.java @@ -59,11 +59,6 @@ public class MyapiSaveReq { */ @Schema(description = "请求方式",type = "String") private String mode; - /** - * 购买字段 - */ - @Schema(description = "购买字段(当修改成功触发)",type = "Integer") - private int auth; /* API类型 */ diff --git a/cloud-market2-common/src/main/java/com/muyu/market/admain/response/BelongResp.java b/cloud-market2-common/src/main/java/com/muyu/market/admain/response/BelongResp.java new file mode 100644 index 0000000..a7d4589 --- /dev/null +++ b/cloud-market2-common/src/main/java/com/muyu/market/admain/response/BelongResp.java @@ -0,0 +1,130 @@ +package com.muyu.market.admain.response; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.muyu.market.admain.Belong; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.math.BigDecimal; +import java.util.Date; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@SuperBuilder +@Tag( name = "响应数据",description = "用于展示购买的列表数据") +public class BelongResp { + /** + * 主键 + */ + @TableId(value = "belong_id",type = IdType.AUTO) + private Long belongId; + /** + * 接口名称 + */ + @Schema(type = "String",description = "接口名称") + private String name; + /** + * 价钱/次 + */ + @Schema(type = "BigDecimal",description = "价钱/次") + private BigDecimal price; + /** + * 介绍 + */ + @Schema(type = "String",description = "介绍") + private String test; + /** + * 我的数据 + */ + @Schema(type = "String",description = "我的数据") + private String data; + /** + * 接口名称 + */ + @Schema(type = "String",description = "接口名称") + private String apiName; + /** + * 接口地址 + */ + @Schema(type = "String",description = "接口地址") + private String ip; + /** + * 请求方式 + */ + @Schema(type = "String",description = "请求方式") + private String mode; + /** + * API类型 + */ + @Schema(type = "String",description = "API类型") + private String type; + /** + * 返回报文 + */ + @Schema(type = "String",description = "返回报文") + private String msgresp; + /** + * + */ + @Schema(type = "String",description = "1") + private String createBy; + /** + * + */ + @Schema(type = "Date",description = "1") + private Date createTime; + /** + * + */ + @Schema(type = "String",description = "1") + private String updateBy; + /** + * + */ + @Schema(type = "Date",description = "sb") + private Date updateTime; + /** + * + */ + @Schema(type = "String",description = "备注") + private String remark; + /** + * 购买人信息 + */ + @Schema(type = "Integer",description = "购买人信息") + private Integer userId; + /** + * 剩余使用次数 + */ + @Schema(type = "Integer",description = "剩余使用次数") + private Integer num; + + public static BelongResp setBelongList(Belong belong){ + return BelongResp. + builder() + .belongId(belong.getBelongId()) + .name( belong.getName() ) + .price(belong.getPrice()) + .test( belong.getTest() ) + .data( belong.getData() ) + .apiName(belong.getApiName()) + .ip(belong.getIp()) + .mode(belong.getMode()) + .type(belong.getType()) + .msgresp(belong.getMsgresp()) + .createBy(belong.getCreateBy()) + .createTime(belong.getCreateTime()) + .updateBy(belong.getUpdateBy()) + .updateTime(belong.getUpdateTime()) + .remark(belong.getRemark()) + .userId(belong.getUserId()) + .num(belong.getNum()) + .build(); + } +} diff --git a/cloud-market2-common/src/main/java/com/muyu/market/admain/response/MyapiListResp.java b/cloud-market2-common/src/main/java/com/muyu/market/admain/response/MyapiListResp.java index d662e8b..3062d46 100644 --- a/cloud-market2-common/src/main/java/com/muyu/market/admain/response/MyapiListResp.java +++ b/cloud-market2-common/src/main/java/com/muyu/market/admain/response/MyapiListResp.java @@ -60,11 +60,6 @@ public class MyapiListResp { */ @Schema(description = "请求方式",type = "String") private String mode; - /** - * 购买字段 - */ - @Schema(description = "购买字段(当修改成功触发)",type = "Integer") - private int auth; /* API类型 */ @@ -96,7 +91,6 @@ public class MyapiListResp { .apiName( myapi.getApiName()) .ip( myapi.getIp()) .mode( myapi.getMode()) - .auth( myapi.getAuth()) .type( myapi.getType()) .msgresp( myapi.getMsgresp() ) .build(); diff --git a/cloud-market2-server/src/main/java/com/muyu/market/server/controller/BelongController.java b/cloud-market2-server/src/main/java/com/muyu/market/server/controller/BelongController.java new file mode 100644 index 0000000..a93ee00 --- /dev/null +++ b/cloud-market2-server/src/main/java/com/muyu/market/server/controller/BelongController.java @@ -0,0 +1,29 @@ +package com.muyu.market.server.controller; + +import com.muyu.common.core.domain.Result; +import com.muyu.common.security.utils.SecurityUtils; +import com.muyu.common.system.domain.LoginUser; +import com.muyu.market.admain.Belong; +import com.muyu.market.server.service.BelongService; +import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@Tag( name = "购物车控制层",description = "查询登录人购买操作") +public class BelongController { + @Autowired + private BelongService belongService; + + @PostMapping("/selectBelongByUser") + public Result selectBelongByUser(){ + LoginUser loginUser = SecurityUtils.getLoginUser(); + Integer userid = Math.toIntExact( loginUser.getUserid() ); + System.out.println(loginUser); + List belongListByUserId = belongService.findBelongListByUserId( userid ); + return Result.success(belongListByUserId); + } +} diff --git a/cloud-market2-server/src/main/java/com/muyu/market/server/mapper/BelongMapper.java b/cloud-market2-server/src/main/java/com/muyu/market/server/mapper/BelongMapper.java new file mode 100644 index 0000000..48e1c22 --- /dev/null +++ b/cloud-market2-server/src/main/java/com/muyu/market/server/mapper/BelongMapper.java @@ -0,0 +1,10 @@ +package com.muyu.market.server.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.muyu.market.admain.Belong; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface BelongMapper extends BaseMapper { + +} diff --git a/cloud-market2-server/src/main/java/com/muyu/market/server/service/BelongService.java b/cloud-market2-server/src/main/java/com/muyu/market/server/service/BelongService.java new file mode 100644 index 0000000..e7abd43 --- /dev/null +++ b/cloud-market2-server/src/main/java/com/muyu/market/server/service/BelongService.java @@ -0,0 +1,22 @@ +package com.muyu.market.server.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.market.admain.Belong; + +import java.util.List; + +public interface BelongService extends IService { + /** + * 通过登录人信息 查询登录人的购买数据 + * + * @param userId + * @return + */ + ListfindBelongListByUserId(Integer userId); + + /** + * 添加购买表操作 + * @param belong + */ + void addBelong(Belong belong); +} diff --git a/cloud-market2-server/src/main/java/com/muyu/market/server/service/Impl/BelongServiceImpl.java b/cloud-market2-server/src/main/java/com/muyu/market/server/service/Impl/BelongServiceImpl.java new file mode 100644 index 0000000..57a3794 --- /dev/null +++ b/cloud-market2-server/src/main/java/com/muyu/market/server/service/Impl/BelongServiceImpl.java @@ -0,0 +1,38 @@ +package com.muyu.market.server.service.Impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.common.security.utils.SecurityUtils; +import com.muyu.common.system.domain.LoginUser; +import com.muyu.market.admain.Belong; +import com.muyu.market.server.mapper.BelongMapper; +import com.muyu.market.server.service.BelongService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class BelongServiceImpl extends ServiceImpl implements BelongService { + + @Autowired + private BelongMapper belongMapper; + //展示个人购买数据 + @Override + public List findBelongListByUserId(Integer userId) { + LambdaQueryWrapper belongRespLambdaQueryWrapper = new LambdaQueryWrapper<>(); + LambdaQueryWrapper eq = belongRespLambdaQueryWrapper.eq( Belong::getUserId, userId ); + List list = this.list( eq ); + return list; + } + + /** + * 将购买的数据 存在个人的表中 + * @param belong + */ + @Override + public void addBelong(Belong belong) { + belongMapper.insert( belong ); + + } +}