Explorar o código

Merge branch 'dev' of http://192.168.1.220:10080/Amoy2/wlyy2.0 into dev

wangzhinan hai 1 ano
pai
achega
63e408afd3

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

@ -1,8 +1,5 @@
package com.yihu.jw.security.oauth2.provider.endpoint;
import com.alibaba.fastjson.JSONObject;
import com.yihu.jw.patient.util.ConstantUtils;
import com.yihu.jw.restmodel.ResultStatus;
import com.yihu.jw.security.exception.ImgCaptchaException;
import com.yihu.jw.security.model.Captcha;
import com.yihu.jw.security.model.Oauth2Envelop;
@ -111,51 +108,51 @@ public class WlyyIotLoginEndpoint {
        return pass;
    }
    @RequestMapping(value = "/oauth/captchaAndRegister", method = RequestMethod.POST)
    @ApiOperation("验证短信验证码并注册")
    public ResponseEntity<Oauth2Envelop> captchaCheck(@RequestParam Map<String, String> parameters) throws Exception {
        String client_id = parameters.get("client_id");
        String mobile = parameters.get("username");
        String captcha = parameters.get("captcha");
        String jsonData = parameters.get("jsonData");
        if (StringUtils.isEmpty(client_id)) {
            throw new InvalidRequestException("client_id");
        }
        if (StringUtils.isEmpty(mobile)) {
            throw new InvalidRequestException("username");
        }
        if (StringUtils.isEmpty(captcha)) {
            throw new InvalidRequestException("captcha");
        }
        //图形验证码验证
        String key = parameters.get("key");
        String text = parameters.get("text");
        if(!verifyCaptcha(key,text)){
            throw new ImgCaptchaException("图形验证码错误!");
        }
        Oauth2Envelop<Boolean> oauth2Envelop;
        //判断当前手机号是否注册过
        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);
            }
        }
        HttpHeaders headers = new HttpHeaders();
        headers.set("Cache-Control", "no-store");
        headers.set("Pragma", "no-cache");
        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
    }
//    @RequestMapping(value = "/oauth/captchaAndRegister", method = RequestMethod.POST)
//    @ApiOperation("验证短信验证码并注册")
//    public ResponseEntity<Oauth2Envelop> captchaCheck(@RequestParam Map<String, String> parameters) throws Exception {
//        String client_id = parameters.get("client_id");
//        String mobile = parameters.get("username");
//        String captcha = parameters.get("captcha");
//        String jsonData = parameters.get("jsonData");
//        if (StringUtils.isEmpty(client_id)) {
//            throw new InvalidRequestException("client_id");
//        }
//        if (StringUtils.isEmpty(mobile)) {
//            throw new InvalidRequestException("username");
//        }
//        if (StringUtils.isEmpty(captcha)) {
//            throw new InvalidRequestException("captcha");
//        }
//
//        //图形验证码验证
//        String key = parameters.get("key");
//        String text = parameters.get("text");
//
//        if(!verifyCaptcha(key,text)){
//            throw new ImgCaptchaException("图形验证码错误!");
//        }
//
//        Oauth2Envelop<Boolean> oauth2Envelop;
//        //判断当前手机号是否注册过
//        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);
//            }
//        }
//        HttpHeaders headers = new HttpHeaders();
//        headers.set("Cache-Control", "no-store");
//        headers.set("Pragma", "no-cache");
//        return new ResponseEntity<>(oauth2Envelop, headers, HttpStatus.OK);
//    }
}

+ 10 - 4
svr/svr-base/src/main/java/com/yihu/jw/base/endpoint/common/FileUploadController.java

@ -68,10 +68,16 @@ public class FileUploadController extends EnvelopRestEndpoint {
                                       @RequestParam(value = "file", required = true) MultipartFile file){
        try {
            // 得到文件的完整名称  xxx.txt
//        String originalFilename = file.getOriginalFilename();
//        InputStream inputStream = file.getInputStream();
//        UploadVO uploadVO = fileUploadService.uploadImg(inputStream,originalFilename,file.getSize(),fastdfs_file_url);
//        return success("上传成功", uploadVO);
            if ("iottest".equals(springProfile)||//物联网
                    "iotprod".equals(springProfile)||//物联网
                    "iotprodIn".equals(springProfile)//物联网
            ){
                String originalFileName = file.getOriginalFilename();
                String fileType = originalFileName.substring(originalFileName.lastIndexOf(".") + 1).toLowerCase();
                if (org.apache.commons.lang3.StringUtils.isBlank(fileType) || !"jpg、jpeg、png、bmp、gif".contains(fileType)) {
                    return ObjEnvelop.getError("附件文件格式不正确");
                }
            }
            UploadVO uploadVO = new UploadVO();
            if (isClose.equalsIgnoreCase("1")){
                Map<String, Object> map = fileUploadService.uploadImg(file);