소스 검색

添加判断是否注册逻辑

humingfen 4 년 전
부모
커밋
7002c0e53c

+ 1 - 0
business/sms-service/src/main/java/com/yihu/jw/sms/service/IotSMSService.java

@ -31,6 +31,7 @@ public class IotSMSService {
        par.add(new BasicNameValuePair("mobiles", mobileStr));
        par.add(new BasicNameValuePair("content", content));
        String result = httpClientUtil.post(url,par,"UTF-8");
        System.out.println("短信接口返回结果result:" + result);
        JSONObject re = JSONObject.parseObject(result);
        if (re.getInteger("status") != 10000) {
            // 发送失败

+ 3 - 3
common/common-entity/src/main/java/com/yihu/jw/entity/IntegerIdentityEntity.java

@ -19,13 +19,13 @@ public abstract class IntegerIdentityEntity implements Serializable {
    @Id
//==========mysql 环境 id策略======================================================
/*    @GeneratedValue(generator = "generator")
    @GeneratedValue(generator = "generator")
    @GenericGenerator(name = "generator", strategy = "identity")
    @Column(name = "id", unique = true, nullable = false)*/
    @Column(name = "id", unique = true, nullable = false)
//==========mysql 环境 id策略 end======================================================
//==========Oracle 环境id策略 =========================================================
    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")
//    @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="id_generated")
//==========Oracle 环境id策略 =========================================================
    public Integer getId() {
        return id;

+ 3 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/dao/iot/UserDao.java

@ -2,6 +2,7 @@ package com.yihu.jw.security.dao.iot;
import com.yihu.jw.entity.base.user.UserDO;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
@ -12,4 +13,6 @@ import java.util.List;
 */
public interface UserDao extends PagingAndSortingRepository<UserDO, String>, JpaSpecificationExecutor<UserDO> {
    @Query("select u from UserDO u where u.mobile = ?1 and u.enabled = 1")
    UserDO findByMobile(String mobile);
}

+ 15 - 9
server/svr-authentication/src/main/java/com/yihu/jw/security/oauth2/provider/endpoint/WlyyIotLoginEndpoint.java

@ -79,7 +79,7 @@ public class WlyyIotLoginEndpoint {
            headers.set("Pragma", "no-cache");
            return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
        }
        throw new IllegalStateException("验证码发送失败!");
        throw new IllegalStateException("验证码发送失败!result:"+ result);
    }
    @RequestMapping(value = "/oauth/captchaAndRegister", method = RequestMethod.POST)
@ -99,15 +99,21 @@ public class WlyyIotLoginEndpoint {
            throw new InvalidRequestException("captcha");
        }
        Oauth2Envelop<Boolean> oauth2Envelop;
        if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
            oauth2Envelop = new Oauth2Envelop<>("注册成功", 200, true);
            //注册账号
            JSONObject jsonObject =  userService.createUser(jsonData);
            if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
                oauth2Envelop = new Oauth2Envelop<>(jsonObject.getString("msg"), ResultStatus.INVALID_GRANT, false);
        //判断当前手机号是否注册过
        Boolean b = userService.isRegisterUserName(mobile);
        if(!b){
            oauth2Envelop = new Oauth2Envelop<>("该手机号已注册过,请直接登录!", ResultStatus.INVALID_GRANT, false);
        }else {
            if (wlyyRedisVerifyCodeService.verification(client_id, mobile, captcha)) {
                oauth2Envelop = new Oauth2Envelop<>("注册成功", 200, true);
                //注册账号
                JSONObject jsonObject = userService.createUser(jsonData);
                if (jsonObject.getString("response").equalsIgnoreCase(ConstantUtils.FAIL)) {
                    oauth2Envelop = new Oauth2Envelop<>(jsonObject.getString("msg"), ResultStatus.INVALID_GRANT, false);
                }
            } else {
                oauth2Envelop = new Oauth2Envelop<>("验证码错误", ResultStatus.INVALID_GRANT, false);
            }
        } else {
            oauth2Envelop = new Oauth2Envelop<>("验证码错误", ResultStatus.INVALID_GRANT, false);
        }
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");

+ 10 - 0
server/svr-authentication/src/main/java/com/yihu/jw/security/service/UserService.java

@ -91,4 +91,14 @@ public class UserService {
        return buffer.toString();
    }
    //判断该号码是否注册过
    public Boolean isRegisterUserName(String mobile) {
        UserDO userDO = userDao.findByMobile(mobile);
        if (userDO == null) {
            return true;
        } else {
            return false;
        }
    }
}

+ 1 - 1
svr/svr-iot/src/main/java/com/yihu/iot/service/device/IotPatientDeviceService.java

@ -372,7 +372,7 @@ public class IotPatientDeviceService extends BaseJpaService<IotPatientDeviceDO,
    public MixEnvelop<IotPatientDeviceVO, IotPatientDeviceVO> getRepairDeviceList(String deviceSn, Integer status, String manufacturerId, Integer page, Integer pageSize) {
        String sql ="SELECT p.device_sn,p.device_id,p.device_name,GROUP_CONCAT(p.patient_name) as patientName,p.idcard,p.mobile,p.`status`,p.damage_description,p.damage_images,p.repair_description,d.manufacturer_id, c.`name` manufacturerName,c.contacts_name, c.contacts_mobile " +
                "FROM `iot_patient_device` p, iot_device d LEFT JOIN iot_company c on d.manufacturer_id = c.id and c.status = 1 " +
                "where  p.del =  1 and p.`status` is not null and p.`status` > 0 and p.device_id= d.id ";
                "where   p.`status` is not null and p.`status` > 0 and p.device_id= d.id ";
        if(StringUtils.isNotBlank(deviceSn)){
            sql += " and p.device_sn like '%" + deviceSn + "%' ";
        }