@Transactional
public void saveCompositeUser(UserCompositeDTO userCompositeDTO) {
var userInfo = new UserInfo();
userInfo.setFirstName(userCompositeDTO.getFirstName())
.setMiddleName(userCompositeDTO.getMiddleName())
.setLastName(userCompositeDTO.getLastName())
.setBirthDate(userCompositeDTO.getBirthDate())
.setPhoneNumber(userCompositeDTO.getPhoneNumber());
User user = new User();
user.setAuthorities(userCompositeDTO.getAuthorities())
.setEmail(userCompositeDTO.getEmail())
.setPassword(userCompositeDTO.getPassword())
.setUsername(userCompositeDTO.getUsername())
.setEnabled(true)
.setOrganization(userCompositeDTO.getOrganization())
.setUserInfo(userInfo);
User currentUser = userRepository.save(user);
userInfo.setUser(currentUser);
userInfoRepository.save(userInfo);
}
exp_str = input('Input math expression: ')
mul_brack = []
div_brack = []
reserve = []
count = 0
#(a+(b-c))+(d+e)*f
#(((A*B)+C)+(C+D))*E
#(A*(B*C)*D)+E+F
#(A+B)*(C+D)/(E-F)
exp = list(exp_str)
for i in range(len(exp)):
if exp[i] == '*':
mul_brack.append(i)
elif exp[i] == '/':
div_brack.append(i)
for i in range(len(exp)):
for j in range(len(mul_brack)):
if i == mul_brack[j]:
if exp[i-1] == ')':
reserve.append(i-1)
for k in range(i-1, 0, -1):
if exp[k] == '(':
reserve.append(k)
break
elif exp[i+1] == '(':
reserve.append(i+1)
for k in range(i+1, len(exp)):
if exp[k] == ')':
reserve.append(k)
break
for j in range(len(div_brack)):
if i == div_brack[j]:
if exp[i-1] == ')':
reserve.append(i-1)
for k in range(i-1, 0, -1):
if exp[k] == '(':
reserve.append(k)
break
elif exp[i+1] == '(':
reserve.append(i+1)
for k in range(i+1, len(exp)):
if exp[k] == ')':
reserve.append(k)
break
#for i in range(len(exp)):
i = 0
while i != len(exp):
if i == len(exp):
break
if exp[i] == '(' or exp[i] == ')':
for j in range(len(reserve)):
if i == reserve[j]:
count += 1
if count == 0:
del exp[i]
for j in range(len(reserve)):
reserve[j] -= 1
i = 0
else:
i += 1
count = 0
else:
i += 1
for i in exp:
print(i, end='')