From 3341b7a0e2a8c719cf6eaf1591a721ec6b8e1fe4 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Tue, 25 May 2021 14:42:51 +0800 Subject: [PATCH] Merge branch 'otc' of http://120.27.238.55:7000/r/exchange into otc --- src/main/java/com/xcong/excoin/modules/otc/dto/BlackListDto.java | 7 +++ src/main/resources/mapper/otc/OtcBlackListDao.xml | 4 ++ src/main/java/com/xcong/excoin/modules/otc/dto/AddBlackDto.java | 4 + src/main/java/com/xcong/excoin/modules/otc/dao/OtcBlackListDao.java | 3 + src/main/java/com/xcong/excoin/modules/otc/controller/OtcBlackListController.java | 55 +++++++++++++++++++++++++-- src/main/java/com/xcong/excoin/common/aop/ExceptionCatchAspect.java | 5 ++ src/main/resources/application-app.yml | 1 7 files changed, 73 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/xcong/excoin/common/aop/ExceptionCatchAspect.java b/src/main/java/com/xcong/excoin/common/aop/ExceptionCatchAspect.java index 4f838da..627682c 100644 --- a/src/main/java/com/xcong/excoin/common/aop/ExceptionCatchAspect.java +++ b/src/main/java/com/xcong/excoin/common/aop/ExceptionCatchAspect.java @@ -46,6 +46,9 @@ @Value("${spring.profiles.active}") private String profiles; + @Value("${app.project}") + private String projectName; + @Pointcut("execution(* com.xcong.excoin..*.*(..))") public void exceptionCatch() { } @@ -72,7 +75,7 @@ try { log.info("插入"); exceptionData.setCreateTime(new Date()); - exceptionData.setMachine(InetAddress.getLocalHost().getHostName() + "-" + profiles); + exceptionData.setMachine(projectName + "-" + InetAddress.getLocalHost().getHostName() + "-" + profiles); exceptionData.setAddress(InetAddress.getLocalHost().getHostAddress()); exceptionData.setExceptionMsg(exStr); exceptionData.setSimpleMsg(ex.getMessage()); diff --git a/src/main/java/com/xcong/excoin/modules/otc/controller/OtcBlackListController.java b/src/main/java/com/xcong/excoin/modules/otc/controller/OtcBlackListController.java index f7fe632..69708cf 100644 --- a/src/main/java/com/xcong/excoin/modules/otc/controller/OtcBlackListController.java +++ b/src/main/java/com/xcong/excoin/modules/otc/controller/OtcBlackListController.java @@ -1,12 +1,21 @@ package com.xcong.excoin.modules.otc.controller; +import com.xcong.excoin.common.LoginUserUtils; import com.xcong.excoin.common.response.Result; +import com.xcong.excoin.modules.member.entity.MemberEntity; +import com.xcong.excoin.modules.otc.dao.OtcBlackListDao; +import com.xcong.excoin.modules.otc.dao.OtcOrderDao; +import com.xcong.excoin.modules.otc.dto.AddBlackDto; +import com.xcong.excoin.modules.otc.entity.OtcBlackList; +import com.xcong.excoin.modules.otc.entity.OtcOrder; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -17,17 +26,55 @@ @Api(value = "OtcBlackListController", tags = "黑名单列表接口类") public class OtcBlackListController { + @Autowired + private OtcBlackListDao otcBlackListDao; + @Autowired + private OtcOrderDao otcOrderDao; + @ApiOperation(value = "添加黑名单") @PostMapping(value = "/add") - public Result add() { - return null; + public Result add(@RequestBody AddBlackDto addBlackDto) { + MemberEntity member = LoginUserUtils.getAppLoginUser(); + + OtcOrder otcOrder = otcOrderDao.selectById(addBlackDto.getId()); + if (otcOrder == null) { + return Result.fail("订单不存在"); + } + + OtcBlackList otcBlackList = new OtcBlackList(); + otcBlackList.setMemberId(member.getId()); + otcBlackList.setBlackMemberId(otcOrder.getEntrustMemberId()); + otcBlackList.setReasons(addBlackDto.getReason()); + otcBlackListDao.insert(otcBlackList); + return Result.ok("拉黑成功"); } + @ApiOperation(value = "黑名单列表") + @PostMapping(value = "/blackList") public Result blackList() { return null; } - public Result del() { - return null; + @ApiOperation(value = "删除黑名单") + @PostMapping(value = "/del") + public Result del(@RequestBody AddBlackDto addBlackDto) { + MemberEntity member = LoginUserUtils.getAppLoginUser(); + if (addBlackDto.getType() == null) { + return Result.fail("参数错误"); + } + + if (addBlackDto.getType() == 1) { + OtcOrder otcOrder = otcOrderDao.selectById(addBlackDto.getId()); + if (otcOrder == null) { + return Result.fail("订单不存在"); + } + + OtcBlackList otcBlackList = otcBlackListDao.selectByMemberIdAndBlackMemberId(member.getId(), otcOrder.getEntrustMemberId()); + otcBlackListDao.deleteById(otcBlackList.getId()); + } else { + otcBlackListDao.deleteById(addBlackDto.getId()); + } + + return Result.ok("解除成功"); } } diff --git a/src/main/java/com/xcong/excoin/modules/otc/dao/OtcBlackListDao.java b/src/main/java/com/xcong/excoin/modules/otc/dao/OtcBlackListDao.java index 5819ecb..a7dca66 100644 --- a/src/main/java/com/xcong/excoin/modules/otc/dao/OtcBlackListDao.java +++ b/src/main/java/com/xcong/excoin/modules/otc/dao/OtcBlackListDao.java @@ -2,6 +2,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.otc.entity.OtcBlackList; +import org.apache.ibatis.annotations.Param; public interface OtcBlackListDao extends BaseMapper<OtcBlackList> { + + OtcBlackList selectByMemberIdAndBlackMemberId(@Param("memberId") Long memberId, @Param("blackMemberId") Long blackMemberId); } diff --git a/src/main/java/com/xcong/excoin/modules/otc/dto/AddBlackDto.java b/src/main/java/com/xcong/excoin/modules/otc/dto/AddBlackDto.java index 5da790f..643a336 100644 --- a/src/main/java/com/xcong/excoin/modules/otc/dto/AddBlackDto.java +++ b/src/main/java/com/xcong/excoin/modules/otc/dto/AddBlackDto.java @@ -17,6 +17,8 @@ private Long id; @NotBlank(message = "参数错误") - @ApiModelProperty(value = "类型 1-传订单ID 2-用户ID") private Integer type; + + @ApiModelProperty(value = "原因 - 删除不传") + private String reason; } diff --git a/src/main/java/com/xcong/excoin/modules/otc/dto/BlackListDto.java b/src/main/java/com/xcong/excoin/modules/otc/dto/BlackListDto.java new file mode 100644 index 0000000..7ba5780 --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/otc/dto/BlackListDto.java @@ -0,0 +1,7 @@ +package com.xcong.excoin.modules.otc.dto; + +import lombok.Data; + +@Data +public class BlackListDto { +} diff --git a/src/main/resources/application-app.yml b/src/main/resources/application-app.yml index 738e153..9594a28 100644 --- a/src/main/resources/application-app.yml +++ b/src/main/resources/application-app.yml @@ -93,6 +93,7 @@ app: debug: false redis_expire: 3000 + project: otc kline-update-job: true newest-price-update-job: true #日线 该任务不能与最新价处于同一个服务器 diff --git a/src/main/resources/mapper/otc/OtcBlackListDao.xml b/src/main/resources/mapper/otc/OtcBlackListDao.xml index 17a46ce..34f383a 100644 --- a/src/main/resources/mapper/otc/OtcBlackListDao.xml +++ b/src/main/resources/mapper/otc/OtcBlackListDao.xml @@ -2,4 +2,8 @@ <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.xcong.excoin.modules.otc.dao.OtcBlackListDao"> + <select id="selectByMemberIdAndBlackMemberId" resultType="com.xcong.excoin.modules.otc.entity.OtcBlackList"> + select * from otc_black_list + where member_id=#{memberId} and black_member_id=#{blackMemberId} + </select> </mapper> \ No newline at end of file -- Gitblit v1.9.1