| | |
| | | package com.moral.api.pojo.form.account; |
| | | |
| | | import com.moral.api.pojo.dto.account.AccountInsertDTO; |
| | | import com.moral.api.entity.ManageAccount; |
| | | import com.moral.api.pojo.dto.account.AccountDTO; |
| | | import com.moral.constant.ResponseCodeEnum; |
| | | import com.moral.util.AESUtils; |
| | | import com.moral.util.MD5Utils; |
| | | import com.moral.util.RegexUtils; |
| | | import lombok.Data; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.util.ObjectUtils; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | * @Version TODO |
| | | **/ |
| | | @Data |
| | | public class AccountInsertForm implements Serializable{ |
| | | public class AccountInsertForm { |
| | | |
| | | |
| | | private String account; |
| | |
| | | |
| | | private String wechat; |
| | | |
| | | |
| | | private String createTime; |
| | | |
| | | |
| | | private String updateTime; |
| | | |
| | | |
| | | private List<String> roleIds; |
| | | private List<Integer> roleIds; |
| | | |
| | | public boolean valid() { |
| | | if ( |
| | | ObjectUtils.isEmpty(account) || |
| | | ObjectUtils.isEmpty(password) || |
| | | ObjectUtils.isEmpty(email) || |
| | | ObjectUtils.isEmpty(mobile) || |
| | | ObjectUtils.isEmpty(userName) |
| | | ) |
| | | ObjectUtils.isEmpty(account) || |
| | | ObjectUtils.isEmpty(password) || |
| | | ObjectUtils.isEmpty(userName) |
| | | ) |
| | | return false; |
| | | return true; |
| | | } |
| | | |
| | | public AccountInsertDTO paramValid(){ |
| | | AccountInsertDTO dto = new AccountInsertDTO(); |
| | | //判断用户名是否符合条件 |
| | | if(!RegexUtils.checkAccount(account)){ |
| | | public AccountDTO paramValid() { |
| | | AccountDTO dto = new AccountDTO(); |
| | | //判断账号是否符合条件 |
| | | if (!RegexUtils.checkAccount(account)) { |
| | | dto.setCode(ResponseCodeEnum.ACCOUNT_INVALID.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.ACCOUNT_INVALID.getMsg()); |
| | | return dto; |
| | | } |
| | | //判断用户名是否符合条件 |
| | | if(!RegexUtils.checkChinese(userName)||userName.contains(" ")){ |
| | | dto.setCode(ResponseCodeEnum.USERNAME_INVALID.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.USERNAME_INVALID.getMsg()); |
| | | return dto; |
| | | } |
| | | //判断密码是否符合条件 |
| | | if(!RegexUtils.checkPassword(AESUtils.decrypt(password))){ |
| | | if (!RegexUtils.checkPassword(AESUtils.decrypt(password))) { |
| | | dto.setCode(ResponseCodeEnum.PASSWORD_INVALID.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.PASSWORD_INVALID.getMsg()); |
| | | return dto; |
| | | } |
| | | //判断手机号是否符合条件 |
| | | if(!RegexUtils.checkMobile(mobile)){ |
| | | dto.setCode(ResponseCodeEnum.MOBILE_INVALID.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.MOBILE_INVALID.getMsg()); |
| | | return dto; |
| | | if (!ObjectUtils.isEmpty(mobile)) { |
| | | if (!RegexUtils.checkMobile(mobile)) { |
| | | dto.setCode(ResponseCodeEnum.MOBILE_INVALID.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.MOBILE_INVALID.getMsg()); |
| | | return dto; |
| | | } |
| | | } |
| | | //判断邮箱是否符合条件 |
| | | if(!RegexUtils.checkEmail(email)){ |
| | | dto.setCode(ResponseCodeEnum.EMAIL_INVALID.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.EMAIL_INVALID.getMsg()); |
| | | return dto; |
| | | if (!ObjectUtils.isEmpty(email)) { |
| | | if (!RegexUtils.checkEmail(email)) { |
| | | dto.setCode(ResponseCodeEnum.EMAIL_INVALID.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.EMAIL_INVALID.getMsg()); |
| | | return dto; |
| | | } |
| | | } |
| | | dto.setCode(ResponseCodeEnum.SUCCESS.getCode()); |
| | | dto.setMsg(ResponseCodeEnum.SUCCESS.getMsg()); |
| | | return dto; |
| | | |
| | | } |
| | | |
| | | public ManageAccount formConvertEntity() { |
| | | ManageAccount manageAccount = new ManageAccount(); |
| | | manageAccount.setAccount(account); |
| | | manageAccount.setPassword(MD5Utils.saltMD5(AESUtils.decrypt(password))); |
| | | manageAccount.setUserName(userName); |
| | | manageAccount.setEmail(email); |
| | | manageAccount.setMobile(mobile); |
| | | manageAccount.setWechat(wechat); |
| | | return manageAccount; |
| | | } |
| | | } |