| | |
| | | import com.ruoyi.system.api.feignClient.SysUserRoleClient; |
| | | import com.ruoyi.system.api.model.GetSysRoleByIds; |
| | | import com.ruoyi.system.api.model.SysUserRoleVo; |
| | | import io.seata.core.context.RootContext; |
| | | import io.seata.core.exception.TransactionException; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import io.seata.tm.api.GlobalTransaction; |
| | | import io.seata.tm.api.GlobalTransactionContext; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | if(null != one){ |
| | | return AjaxResult.error("登录账号不能重复"); |
| | | } |
| | | //添加新数据 |
| | | this.save(partner); |
| | | //添加登录账户 |
| | | SysUser user = new SysUser(); |
| | | user.setPhonenumber(partner.getPhoneOne()); |
| | |
| | | user.setRoleType(2); |
| | | user.setObjectId(partner.getId()); |
| | | R r = sysUserClient.addSysUser(user); |
| | | if(r.getCode() != 200){ |
| | | // 手动进行全局事务回滚 |
| | | try { |
| | | GlobalTransactionContext.getCurrent().rollback(); |
| | | } catch (TransactionException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | if(200 != r.getCode()){ |
| | | throw new RuntimeException(r.getMsg()); |
| | | } |
| | | //添加新数据 |
| | | this.save(partner); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | } |
| | | Partner oldPartner = this.getById(partner.getId()); |
| | | SysUser user = sysUserClient.queryUserByUserName(oldPartner.getAccount()).getData(); |
| | | |
| | | //修改数据 |
| | | this.updateById(partner); |
| | | //修改登录账户 |
| | | if(null == user){ |
| | | user = new SysUser(); |
| | |
| | | throw new RuntimeException(r.getMsg()); |
| | | } |
| | | } |
| | | |
| | | //修改数据 |
| | | this.updateById(partner); |
| | | return AjaxResult.success(); |
| | | } |
| | | |