package com.dy.pipIrrSell.wallet;
|
|
import com.dy.common.aop.SsoAop;
|
import com.dy.common.webUtil.BaseResponse;
|
import com.dy.common.webUtil.BaseResponseUtils;
|
import com.dy.common.webUtil.ResultCodeMsg;
|
import com.dy.pipIrrGlobal.pojoSe.SeWallet;
|
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.media.Content;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
import jakarta.validation.constraints.NotNull;
|
import lombok.RequiredArgsConstructor;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.http.MediaType;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.validation.annotation.Validated;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import java.util.Date;
|
import java.util.Optional;
|
|
/**
|
* @author ZhuBaoMin
|
* @date 2023/12/11 16:36
|
* @LastEditTime 2023/12/11 16:36
|
* @Description
|
*/
|
|
@Slf4j
|
@Tag(name = "电子钱包管理", description = "电子钱包管理")
|
@RestController
|
@RequestMapping(path="wallet")
|
@RequiredArgsConstructor
|
@Validated
|
public class WalletCtrl {
|
private final WalletSv walletSv;
|
|
@Operation(summary = "注册电子钱包", description = "注册电子钱包")
|
@ApiResponses(value = {
|
@ApiResponse(
|
responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
|
description = "操作结果:true:成功,false:失败(BaseResponse.content)",
|
content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
|
schema = @Schema(implementation = Boolean.class))}
|
)
|
})
|
@PostMapping(path = "add")
|
@Transactional(rollbackFor = Exception.class)
|
@SsoAop("-1")//@SsoAop(power = "-1")
|
//public BaseResponse<Boolean> add(@RequestBody Long clientId){
|
public BaseResponse<Boolean> add(@RequestParam("clientId") @NotNull(message = "农户编号不能为空") Long clientId){
|
if(clientId == null || clientId < 0) {
|
return BaseResponseUtils.buildFail("农户编号不能为空");
|
}
|
|
SeWallet seWallet = new SeWallet();
|
seWallet.setClientid(clientId);
|
seWallet.setMoney(0f);
|
seWallet.setCreatedt(new Date());
|
Integer rec = Optional.ofNullable(walletSv.add(seWallet)).orElse(0);
|
if(rec == 0) {
|
return BaseResponseUtils.buildFail("注册电子钱包-电子钱包记录写入异常");
|
}
|
|
return BaseResponseUtils.buildSuccess(true) ;
|
}
|
|
//@Operation(summary = "电子钱包充值", description = "电子钱包充值")
|
//@ApiResponses(value = {
|
// @ApiResponse(
|
// responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
|
// description = "操作结果:true:成功,false:失败(BaseResponse.content)",
|
// content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
|
// schema = @Schema(implementation = Boolean.class))}
|
// )
|
//})
|
//@PostMapping(path = "addRecharge")
|
//@Transactional(rollbackFor = Exception.class)
|
//@SsoAop("-1")//@SsoAop(power = "-1")
|
//public BaseResponse<Boolean> addRecharge(@RequestBody @Parameter(description = "form表单json数据", required = true) @Valid DtoWalletRecharge po, @Parameter(hidden = true) BindingResult bindingResult){
|
// DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
// if(bindingResult != null && bindingResult.hasErrors()){
|
// return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
|
// }
|
//
|
//
|
//
|
// SeWallet seWallet = new SeWallet();
|
// seWallet.setClientid(clientId);
|
// seWallet.setMoney(0f);
|
// seWallet.setCreatedt(new Date());
|
// Integer rec = Optional.ofNullable(walletSv.add(seWallet)).orElse(0);
|
// if(rec == 0) {
|
// return BaseResponseUtils.buildFail("注册电子钱包-电子钱包记录写入异常");
|
// }
|
//
|
// return BaseResponseUtils.buildSuccess(true) ;
|
//}
|
}
|