From c3aec6b7fd61a40fcadf786c7b07d2ca8ac73400 Mon Sep 17 00:00:00 2001 From: "rong.liu" Date: Mon, 15 Jan 2024 10:40:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E5=85=B3=E6=B3=A8?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/EnterpriseCertification.java | 8 ++ .../CollectionProviderController.java | 97 +++++++++++++++++ .../EnterpriseCertificationController.java | 9 ++ .../nakadai/entity/CollectionProvider.java | 51 +++++++++ .../req/EnterpriseCertificationLIstReq.java | 8 ++ .../mapper/CollectionProviderMapper.java | 16 +++ .../mapper/EnterpriseCertificationMapper.java | 3 + .../mapper/xml/CollectionProviderMapper.xml | 5 + .../xml/EnterpriseCertificationMapper.xml | 100 ++++++++++++++++++ .../service/CollectionProviderService.java | 16 +++ .../EnterpriseCertificationService.java | 3 + .../impl/CollectionProviderServiceImpl.java | 20 ++++ .../EnterpriseCertificationServiceImpl.java | 9 ++ 13 files changed, 345 insertions(+) create mode 100644 nakadai/src/main/java/com/huoran/nakadai/controller/CollectionProviderController.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/entity/CollectionProvider.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/mapper/CollectionProviderMapper.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/mapper/xml/CollectionProviderMapper.xml create mode 100644 nakadai/src/main/java/com/huoran/nakadai/service/CollectionProviderService.java create mode 100644 nakadai/src/main/java/com/huoran/nakadai/service/impl/CollectionProviderServiceImpl.java diff --git a/common/src/main/java/com/huoran/common/entity/EnterpriseCertification.java b/common/src/main/java/com/huoran/common/entity/EnterpriseCertification.java index dbb99d6..7c95fd2 100644 --- a/common/src/main/java/com/huoran/common/entity/EnterpriseCertification.java +++ b/common/src/main/java/com/huoran/common/entity/EnterpriseCertification.java @@ -138,4 +138,12 @@ public class EnterpriseCertification implements Serializable { @ApiModelProperty(value = "供应商分类名称") @TableField(exist = false) private String supplierClassificationName; + + @ApiModelProperty(value = "关注id(用于取消关注,没有表示没有关注过)") + @TableField(exist = false) + private Integer attentionId; + + @ApiModelProperty(value = "是否关注(0未关注 1已关注)") + @TableField(exist = false) + private Integer whetherAttention; } diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/CollectionProviderController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/CollectionProviderController.java new file mode 100644 index 0000000..13e07c7 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/CollectionProviderController.java @@ -0,0 +1,97 @@ +package com.huoran.nakadai.controller; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.huoran.api.UserClient; +import com.huoran.common.response.R; +import com.huoran.common.utils.TokenUtils; +import com.huoran.nakadai.entity.CollectionProvider; +import com.huoran.nakadai.service.CollectionProviderService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.List; + +/** + * @描述:关注供应商控制类 + * @作者: Rong + * @日期: 2024-01-12 + */ +@RestController +@RequestMapping("/collectionProvider") +@Api(value = "关注供应商:CollectionProviderController", tags = "供应商关注") +public class CollectionProviderController { + + @Autowired + public CollectionProviderService service; + + @Autowired + private UserClient userClient; + + /*@PostMapping("/listByEntity") + @ApiOperation(value = "分页查询", response = CollectionProvider.class) + public R listByEntity(@RequestBody CollectionProvider collectionProvider) { + + return null; + }*/ + + + @PostMapping("/findById") + @ApiOperation(value = "查询详情", response = CollectionProvider.class) + public R findById(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { + CollectionProvider collectionProvider = service.getById(id); + return R.ok().put("data", collectionProvider); + } + + + + @PostMapping("/collect") + @ApiOperation(value = "关注", response = CollectionProvider.class) + public R collect(@RequestBody @ApiParam(name = "关注供应商对象", value = "传入json格式", required = true) CollectionProvider collectionProvider, HttpServletRequest request) { + String accountId = TokenUtils.getIdByJwtToken(request); + collectionProvider.setAccountId(Integer.valueOf(accountId)); + if (checkCollect(collectionProvider.getSupplierAccountId(), Integer.valueOf(accountId))){ + return R.ok("您已关注!请勿重复关注"); + } + boolean addState = service.save(collectionProvider); + return addState ? R.ok(collectionProvider.getId()) : R.error("新增失败"); + } + + //校验是否收藏过 + public boolean checkCollect(Integer supplierAccountId, Integer accountId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("account_id", accountId); + queryWrapper.eq("supplier_account_id", supplierAccountId); + CollectionProvider collectionProvider = service.getOne(queryWrapper); + return collectionProvider != null; + } + + /* @PostMapping("/update") + @ApiOperation(value = "修改", response = CollectionProvider.class) + public R update(@RequestBody @ApiParam(name = "关注供应商对象", value = "传入json格式", required = true) CollectionProvider collectionProvider, HttpServletRequest request) { + String accountId = TokenUtils.getIdByJwtToken(request); + Integer schoolId = userClient.getSchoolIdByAccountId(accountId); + collectionProvider.setAccountId(Integer.valueOf(accountId)); + boolean updateState = service.updateById(collectionProvider); + return updateState ? R.ok() : R.error("编辑失败"); + }*/ + + @PostMapping("/cancelCollection") + @ApiOperation(value = "取消关注", response = CollectionProvider.class) + public R cancelCollection(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { + boolean delState = service.removeById(id); + return delState ? R.ok() : R.error("取消失败"); + } + + + @PostMapping("/batchDeletion") + @ApiOperation(value = "批量删除", response = CollectionProvider.class) + public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestBody List ids) { + boolean delState = service.removeByIds(ids); + return delState ? R.ok() : R.error("删除失败"); + } +} + diff --git a/nakadai/src/main/java/com/huoran/nakadai/controller/EnterpriseCertificationController.java b/nakadai/src/main/java/com/huoran/nakadai/controller/EnterpriseCertificationController.java index d209d50..19c3a49 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/controller/EnterpriseCertificationController.java +++ b/nakadai/src/main/java/com/huoran/nakadai/controller/EnterpriseCertificationController.java @@ -56,6 +56,15 @@ public class EnterpriseCertificationController { } + @PostMapping("/supplierList") + @ApiOperation(value = "供应商列表", response = EnterpriseCertification.class) + public R supplierList(@RequestBody EnterpriseCertificationLIstReq req, HttpServletRequest request) { + String accountId = TokenUtils.getIdByJwtToken(request); + req.setAccountId(Integer.valueOf(accountId)); + return service.supplierList(req); + } + + @PostMapping("/enterpriseCertificationDetails") @ApiOperation(value = "企业认证详情", response = EnterpriseCertification.class) public R enterpriseCertificationDetails(@ApiParam(name = "id", value = "主键", required = true) @RequestParam Integer id) { diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/CollectionProvider.java b/nakadai/src/main/java/com/huoran/nakadai/entity/CollectionProvider.java new file mode 100644 index 0000000..d330d9b --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/CollectionProvider.java @@ -0,0 +1,51 @@ +package com.huoran.nakadai.entity; + +import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; +import java.util.Date; + +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import java.io.Serializable; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** + *

+ * 收藏供应商 + *

+ * + * @author chen + * @since 2024-01-12 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@Accessors(chain = true) +@ApiModel(value="CollectionProvider对象", description="收藏供应商") +public class CollectionProvider implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "主键") + @TableId(value = "id", type = IdType.AUTO) + private Integer id; + + @ApiModelProperty(value = "账号id(关注人id)") + private Integer accountId; + + @ApiModelProperty(value = "被关注供应商的账号id") + private Integer supplierAccountId; + + @ApiModelProperty(value = "创建时间") + @TableField(fill = FieldFill.INSERT) + private Date createTime; + + @ApiModelProperty(value = "更新时间") + @TableField(fill = FieldFill.INSERT_UPDATE) + private Date updateTime; + + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/entity/req/EnterpriseCertificationLIstReq.java b/nakadai/src/main/java/com/huoran/nakadai/entity/req/EnterpriseCertificationLIstReq.java index f4c6aad..aaec677 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/entity/req/EnterpriseCertificationLIstReq.java +++ b/nakadai/src/main/java/com/huoran/nakadai/entity/req/EnterpriseCertificationLIstReq.java @@ -1,5 +1,6 @@ package com.huoran.nakadai.entity.req; +import com.baomidou.mybatisplus.annotation.TableField; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -58,4 +59,11 @@ public class EnterpriseCertificationLIstReq { @ApiModelProperty(value = "当前页需要显示的数量", name = "pageSize", example = "10", required = true) private Integer pageSize; + @ApiModelProperty(value = "账号id") + private Integer accountId; + + @ApiModelProperty(value = "是否关注(0未关注 1已关注)") + @TableField(exist = false) + private Integer whetherAttention; + } diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/CollectionProviderMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/CollectionProviderMapper.java new file mode 100644 index 0000000..9537377 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/CollectionProviderMapper.java @@ -0,0 +1,16 @@ +package com.huoran.nakadai.mapper; + +import com.huoran.nakadai.entity.CollectionProvider; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; + +/** + *

+ * 收藏供应商 Mapper 接口 + *

+ * + * @author chen + * @since 2024-01-12 + */ +public interface CollectionProviderMapper extends BaseMapper { + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/EnterpriseCertificationMapper.java b/nakadai/src/main/java/com/huoran/nakadai/mapper/EnterpriseCertificationMapper.java index 1020766..7f0d403 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/EnterpriseCertificationMapper.java +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/EnterpriseCertificationMapper.java @@ -22,6 +22,9 @@ public interface EnterpriseCertificationMapper extends BaseMapper selectEnterpriseCertificationList(IPage page, @Param("req")EnterpriseCertificationLIstReq req); + + IPage supplierList(IPage page, @Param("req")EnterpriseCertificationLIstReq req); + EnterpriseCertification enterpriseCertificationDetails(@Param("id")Integer id); diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/CollectionProviderMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/CollectionProviderMapper.xml new file mode 100644 index 0000000..0005ec9 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/CollectionProviderMapper.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/EnterpriseCertificationMapper.xml b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/EnterpriseCertificationMapper.xml index 28b3082..8994749 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/EnterpriseCertificationMapper.xml +++ b/nakadai/src/main/java/com/huoran/nakadai/mapper/xml/EnterpriseCertificationMapper.xml @@ -147,6 +147,106 @@ AND app_open_id = #{openId} AND platform_id = #{platformId} + diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/CollectionProviderService.java b/nakadai/src/main/java/com/huoran/nakadai/service/CollectionProviderService.java new file mode 100644 index 0000000..94cb7a0 --- /dev/null +++ b/nakadai/src/main/java/com/huoran/nakadai/service/CollectionProviderService.java @@ -0,0 +1,16 @@ +package com.huoran.nakadai.service; + +import com.huoran.nakadai.entity.CollectionProvider; +import com.baomidou.mybatisplus.extension.service.IService; + +/** + *

+ * 收藏供应商 服务类 + *

+ * + * @author chen + * @since 2024-01-12 + */ +public interface CollectionProviderService extends IService { + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/EnterpriseCertificationService.java b/nakadai/src/main/java/com/huoran/nakadai/service/EnterpriseCertificationService.java index 955e8c8..74e92e0 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/EnterpriseCertificationService.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/EnterpriseCertificationService.java @@ -20,6 +20,9 @@ public interface EnterpriseCertificationService extends IService + * 收藏供应商 服务实现类 + *

+ * + * @author chen + * @since 2024-01-12 + */ +@Service +public class CollectionProviderServiceImpl extends ServiceImpl implements CollectionProviderService { + +} diff --git a/nakadai/src/main/java/com/huoran/nakadai/service/impl/EnterpriseCertificationServiceImpl.java b/nakadai/src/main/java/com/huoran/nakadai/service/impl/EnterpriseCertificationServiceImpl.java index 670ff4e..46273f0 100644 --- a/nakadai/src/main/java/com/huoran/nakadai/service/impl/EnterpriseCertificationServiceImpl.java +++ b/nakadai/src/main/java/com/huoran/nakadai/service/impl/EnterpriseCertificationServiceImpl.java @@ -46,6 +46,15 @@ public class EnterpriseCertificationServiceImpl extends ServiceImpl page = new Page(req.getPageNum(), req.getPageSize()); + IPage pageList = baseMapper.supplierList(page, req); + + + return R.ok().put("data", pageList); + } + @Override public R enterpriseCertificationDetails(Integer id) { return R.ok().put("data", baseMapper.enterpriseCertificationDetails(id));