package com.platform.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.platform.model.entity.PublicAccountEntity; import com.platform.model.resp.Result; import com.platform.service.PublicAccountService; 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("/public/account") public class PublicAccountController extends BaseController { @Resource private PublicAccountService publicAccountService; @PostMapping("/set") public Result set(@RequestBody PublicAccountEntity publicAccountEntity) { try { return toAjax(publicAccountService.save(publicAccountEntity)); } catch (DuplicateKeyException e) { return toAjax(publicAccountService.remove(new LambdaQueryWrapper() .eq(PublicAccountEntity::getCaseId, publicAccountEntity.getCaseId()) .eq(PublicAccountEntity::getAccountName, publicAccountEntity.getAccountName()))); } } }