首次提交

This commit is contained in:
guotao 2026-01-09 12:20:44 +08:00
parent 1101681331
commit ed171eda88
107 changed files with 1370 additions and 524 deletions

View file

@ -9,10 +9,14 @@ import com.xjhs.findmemerchant.vo.merchant.MerchantVerifyVo;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;
import java.security.Principal;
/**
* 商家管理接口
*/
@Slf4j
@RestController
@RequestMapping("/merchant")
@ -20,39 +24,52 @@ import java.security.Principal;
public class MerchantController {
private final MerchantService merchantService;
/**
* 查询当前登录商家详情
*
* @param merchant @ignore 当前商家
* @return 商家详情信息
*/
@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("商户信息不存在");
public ApiResult<MerchantDto> getMerchant(@AuthenticationPrincipal Merchant merchant) {
return this.merchantService.getById(merchant.getId())
.map(ApiResult::data)
.orElse(ApiResult.fail("商家信息不存在"));
}
/**
* 更新当前登录商家信息
*
* @param merchant @ignore 当前商家
* @param merchantUpdateVo 更新参数
* @return 商家信息
*/
@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());
}
public ApiResult<MerchantDto> updateMerchant(@AuthenticationPrincipal Merchant merchant,
@Valid @RequestBody MerchantUpdateVo merchantUpdateVo) {
try {
var dto = this.merchantService.updateMerchant(merchant.getId(), merchantUpdateVo);
return ApiResult.data(dto);
} catch (Exception e) {
return ApiResult.fail(e.getMessage());
}
return ApiResult.fail("商户信息不存在");
}
/**
* 当前商家验证
*
* @param merchant @ignore 当前商家
* @param merchantVerifyVo 验证参数
* @return 商家信息
*/
@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());
}
public ApiResult<MerchantDto> verifyMerchant(@AuthenticationPrincipal Merchant merchant,
@Valid @RequestBody MerchantVerifyVo merchantVerifyVo) {
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("商户信息不存在");
}
}