package com.platform.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.platform.model.entity.VerifyAccountEntity; import com.platform.model.resp.Result; import com.platform.service.VerifyAccountService; import org.springframework.dao.DuplicateKeyException; 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; import javax.annotation.Resource; @RestController @RequestMapping("/verify/account") public class VerifyAccountController extends BaseController { @Resource private VerifyAccountService verifyAccountService; @PostMapping("/set") public Result set(@RequestBody VerifyAccountEntity verifyAccount) { try { return toAjax(verifyAccountService.save(verifyAccount)); } catch (DuplicateKeyException e) { return toAjax(verifyAccountService.remove(new LambdaQueryWrapper() .eq(VerifyAccountEntity::getCaseId, verifyAccount.getCaseId()) .eq(VerifyAccountEntity::getAccountName, verifyAccount.getAccountName()))); } } }