package com.platform.controller; 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 Result.fail("该账户已是公共账户"); } } }