首次提交
This commit is contained in:
commit
1101681331
131 changed files with 7017 additions and 0 deletions
|
|
@ -0,0 +1,58 @@
|
|||
package com.xjhs.findmemerchant.controller;
|
||||
|
||||
import com.xjhs.findmemerchant.common.ApiResult;
|
||||
import com.xjhs.findmemerchant.dto.MerchantDto;
|
||||
import com.xjhs.findmemerchant.entity.Merchant;
|
||||
import com.xjhs.findmemerchant.service.MerchantService;
|
||||
import com.xjhs.findmemerchant.vo.merchant.MerchantUpdateVo;
|
||||
import com.xjhs.findmemerchant.vo.merchant.MerchantVerifyVo;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/merchant")
|
||||
@RequiredArgsConstructor
|
||||
public class MerchantController {
|
||||
private final MerchantService merchantService;
|
||||
|
||||
@GetMapping
|
||||
public ApiResult<MerchantDto> getMerchant(Principal principal) {
|
||||
if (principal instanceof Merchant merchant) {
|
||||
return this.merchantService.getById(merchant.getId())
|
||||
.map(ApiResult::data)
|
||||
.orElse(ApiResult.fail("商户信息不存在"));
|
||||
}
|
||||
return ApiResult.fail("商户信息不存在");
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
public ApiResult<MerchantDto> updateMerchant(Principal principal,@Valid @RequestBody MerchantUpdateVo merchantUpdateVo) {
|
||||
if (principal instanceof Merchant merchant) {
|
||||
try {
|
||||
var dto = this.merchantService.updateMerchant(merchant.getId(),merchantUpdateVo);
|
||||
return ApiResult.data(dto);
|
||||
} catch (Exception e) {
|
||||
return ApiResult.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
return ApiResult.fail("商户信息不存在");
|
||||
}
|
||||
|
||||
@PostMapping("/verify")
|
||||
public ApiResult<MerchantDto> verifyMerchant(Principal principal,@Valid @RequestBody MerchantVerifyVo merchantVerifyVo) {
|
||||
if (principal instanceof Merchant merchant) {
|
||||
try {
|
||||
var dto = this.merchantService.verifyMerchant(merchant.getId(),merchantVerifyVo.getIdCardNo(),merchantVerifyVo.getRealName());
|
||||
return ApiResult.data(dto);
|
||||
} catch (Exception e) {
|
||||
return ApiResult.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
return ApiResult.fail("商户信息不存在");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue