| | |
| | | package com.tcm.training.admin.app.bankcard.service; |
| | | |
| | | import com.tcm.training.admin.app.auth.service.AppAuthSessionService; |
| | | import com.tcm.training.admin.member.enums.UserType; |
| | | import com.tcm.training.admin.app.bankcard.dto.AppBankCardUpdateRequest; |
| | | import com.tcm.training.admin.app.bankcard.vo.AppBankCardVO; |
| | | import com.tcm.training.admin.live.entity.Clinic; |
| | |
| | | |
| | | public AppBankCardVO detail() { return toVO(requireClinic()); } |
| | | |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AppBankCardVO update(AppBankCardUpdateRequest request) { |
| | | Clinic clinic = requireClinic(); |
| | | clinic.setBankName(trim(request.getBankName())); |
| | |
| | | private Clinic requireClinic() { |
| | | AppUser user = userMapper.selectById(sessionService.requireLoginUserId()); |
| | | if (user == null || user.getDeleted() == null || user.getDeleted() != 0) throw new IllegalArgumentException("用户不存在"); |
| | | if (user.getType() == null || user.getType() != 1 || user.getClinicId() == null) throw new IllegalArgumentException("当前账号未绑定诊所"); |
| | | if (user.getType() == null || user.getType() != UserType.CLINIC.getValue() || user.getClinicId() == null) throw new IllegalArgumentException("当前账号未绑定诊所"); |
| | | Clinic clinic = clinicMapper.selectById(user.getClinicId()); |
| | | if (clinic == null || clinic.getDeleted() == null || clinic.getDeleted() != 0) throw new IllegalArgumentException("诊所不存在"); |
| | | return clinic; |
| | | } |
| | | private AppBankCardVO toVO(Clinic c) { AppBankCardVO v=new AppBankCardVO(); v.setBankName(c.getBankName()); v.setAccountName(c.getAccountHolder()); v.setAccountNumber(c.getAccountNumber()); v.setBranchName(c.getBranchName()); return v; } |
| | | private String trim(String value) { return value == null ? null : value.trim(); } |
| | | } |
| | | } |