| | |
| | | /** |
| | | * base64图片下载 |
| | | */ |
| | | ResultBody baseDownLoad(Map<String, Object> map); |
| | | ResultBody baseDownLoad(Map<String, Object> map) throws Exception; |
| | | } |
| | |
| | | package com.kidgrow.filecenter.service.impl; |
| | | |
| | | import cn.hutool.core.util.IdUtil; |
| | | import com.aliyun.oss.model.OSSObject; |
| | | import com.aliyun.oss.model.ObjectMetadata; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | import sun.misc.BASE64Decoder; |
| | | import sun.misc.BASE64Encoder; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | |
| | | protected abstract void uploadFile(MultipartFile file, FileInfo fileInfo) throws Exception; |
| | | protected abstract void fileUpLoadOss(FileInfo fileInfo,String newFilePath, InputStream fileStream); |
| | | protected abstract String FilePath(String imgType,String folderByDate); |
| | | protected abstract OSSObject down(String url); |
| | | |
| | | /** |
| | | * 删除文件 |
| | |
| | | } |
| | | |
| | | @Override |
| | | public ResultBody baseDownLoad(Map<String, Object> map) { |
| | | public ResultBody baseDownLoad(Map<String, Object> map) throws Exception { |
| | | List<FileInfo> fileInfos = baseMapper.selectByMap(map); |
| | | if(fileInfos.size()>0){ |
| | | FileInfo fileInfo = fileInfos.get(0); |
| | | InputStream in = null; |
| | | byte[] data = null; |
| | | //读取图片字节数组 |
| | | try{ |
| | | in = new FileInputStream(fileInfo.getUrl()); |
| | | data = new byte[in.available()]; |
| | | in.read(data); |
| | | in.close(); |
| | | }catch (IOException e){ |
| | | e.printStackTrace(); |
| | | } |
| | | //对字节数组Base64编码 |
| | | BASE64Encoder encoder = new BASE64Encoder(); |
| | | OSSObject down1 = this.down(fileInfo.getUrl().replace("https://kidgrow.oss-accelerate.aliyuncs.com/","")); |
| | | InputStream objectContent = down1.getObjectContent(); |
| | | //返回Base64编码过的字节数组字符串 |
| | | String encode = encoder.encode(data); |
| | | byte[] data = null; |
| | | // 读取图片字节数组 |
| | | try { |
| | | ByteArrayOutputStream swapStream = new ByteArrayOutputStream(); |
| | | byte[] buff = new byte[100]; |
| | | int rc = 0; |
| | | while ((rc = objectContent.read(buff, 0, 100)) > 0) { |
| | | swapStream.write(buff, 0, rc); |
| | | } |
| | | data = swapStream.toByteArray(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if (objectContent != null) { |
| | | try { |
| | | objectContent.close(); |
| | | down1.close(); |
| | | } catch (IOException e) { |
| | | throw new Exception("输入流关闭异常"); |
| | | } |
| | | } |
| | | } |
| | | String encode="data:"+fileInfo.getContentType()+";base64,"+Base64.getEncoder().encodeToString(data); |
| | | return ResultBody.ok().data(encode); |
| | | }else { |
| | | return ResultBody.failed("获取数据失败"); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | |
| | | |
| | | import com.aliyun.oss.OSSClient; |
| | | import com.aliyun.oss.common.auth.DefaultCredentialProvider; |
| | | import com.aliyun.oss.model.GetObjectRequest; |
| | | import com.aliyun.oss.model.OSSObject; |
| | | import com.kidgrow.common.constant.SecurityConstants; |
| | | import com.kidgrow.common.utils.DateUtil; |
| | | import com.kidgrow.common.utils.StringUtils; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.InputStream; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.UUID; |
| | | |
| | | /** |
| | |
| | | { |
| | | ossClient.putObject(fileProperties.getOss().getBucketName(), newFilePath, fileStream); |
| | | fileInfo.setUrl(fileProperties.getOss().getDomain() + newFilePath); |
| | | |
| | | } |
| | | public OSSObject down(String url){ |
| | | GetObjectRequest request=new GetObjectRequest(fileProperties.getOss().getBucketName(),url); |
| | | return ossClient.getObject(request); |
| | | } |
| | | /** |
| | | * 组合sso上的文件路径 |
| | |
| | | package com.kidgrow.filecenter.config; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.aliyun.oss.model.OSSObject; |
| | | import com.kidgrow.filecenter.model.FileInfo; |
| | | import com.kidgrow.filecenter.properties.FileServerProperties; |
| | | import com.kidgrow.filecenter.service.impl.AbstractIFileService; |
| | |
| | | } |
| | | |
| | | @Override |
| | | protected OSSObject down(String url) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected boolean deleteFile(FileInfo fileInfo) { |
| | | if (fileInfo != null && StrUtil.isNotEmpty(fileInfo.getPath())) { |
| | | StorePath storePath = StorePath.parseFromUrl(fileInfo.getPath()); |
| | |
| | | package com.kidgrow.filecenter.config; |
| | | |
| | | import com.aliyun.oss.model.OSSObject; |
| | | import com.kidgrow.filecenter.model.FileInfo; |
| | | import com.kidgrow.filecenter.properties.FileServerProperties; |
| | | import com.kidgrow.filecenter.service.impl.AbstractIFileService; |
| | |
| | | } |
| | | |
| | | @Override |
| | | protected OSSObject down(String url) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | protected boolean deleteFile(FileInfo fileInfo) { |
| | | try { |
| | | Response response = bucketManager.delete(fileProperties.getOss().getBucketName(), fileInfo.getPath()); |
| | |
| | | /** |
| | | * base64图片下载 |
| | | */ |
| | | @PostMapping(value="baseDownLoad",produces = {MediaType.APPLICATION_JSON_UTF8_VALUE},consumes = MediaType.MULTIPART_FORM_DATA_VALUE) |
| | | public ResultBody baseDownLoad(@RequestBody Map<String,Object> map){ |
| | | @PostMapping(value="baseDownLoad") |
| | | public ResultBody baseDownLoad(@RequestBody Map<String,Object> map) throws Exception{ |
| | | return fileService.baseDownLoad(map); |
| | | } |
| | | |
| | |
| | | * @param newPassword |
| | | * @return |
| | | */ |
| | | ResultBody updatePassword(Long id, String oldPassword, String newPassword,Boolean isdefault); |
| | | ResultBody updatePassword(Long id, String oldPassword, String newPassword,Boolean isdefault) throws Exception; |
| | | /** |
| | | * 更新手机号 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | ResultBody updateUserTel(Map<String,Object> params); |
| | | ResultBody updateUserTel(Map<String,Object> params) throws Exception ; |
| | | /** |
| | | * 用户列表 |
| | | * @param params |
| | |
| | | |
| | | ResultBody findCountByMap(Map<String, Object> map); |
| | | |
| | | ResultBody passwordByPhone(Map<String, Object> map); |
| | | ResultBody passwordByPhone(Map<String, Object> map) throws Exception; |
| | | |
| | | ResultBody registerByPhone(Map<String, Object> map); |
| | | |
| | |
| | | * @param userRegVo |
| | | * @return |
| | | */ |
| | | ResultBody doctorUserReg(UserRegVo userRegVo,SysUser sysUser); |
| | | ResultBody doctorUserReg(UserRegVo userRegVo,SysUser sysUser) throws Exception; |
| | | /** |
| | | * 获取医院科室下的所有有效的医生 |
| | | * @param hospitalId |
| | |
| | | import com.kidgrow.common.model.SysUser; |
| | | import com.kidgrow.common.model.*; |
| | | import com.kidgrow.common.service.impl.SuperServiceImpl; |
| | | import com.kidgrow.common.utils.AesUtils; |
| | | import com.kidgrow.common.utils.DateUtils; |
| | | import com.kidgrow.common.utils.Pinyin4jUtil; |
| | | import com.kidgrow.redis.util.RedisUtils; |
| | |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public ResultBody updatePassword(Long id, String oldPassword, String newPassword, Boolean isdefault) { |
| | | public ResultBody updatePassword(Long id, String oldPassword, String newPassword, Boolean isdefault) throws Exception { |
| | | |
| | | SysUser sysUser = baseMapper.selectById(id); |
| | | if (StrUtil.isNotBlank(oldPassword)) { |
| | | oldPassword=AesUtils.desEncrypt(oldPassword).trim(); |
| | | if (!passwordEncoder.matches(oldPassword, sysUser.getPassword())) { |
| | | return ResultBody.failed("旧密码错误!"); |
| | | } |
| | | } |
| | | if (StrUtil.isBlank(newPassword)) { |
| | | newPassword = com.kidgrow.common.utils.RandomValueUtils.getRandom(6); |
| | | }else { |
| | | newPassword=AesUtils.desEncrypt(newPassword).trim(); |
| | | } |
| | | SysUser user = new SysUser(); |
| | | user.setId(id); |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public ResultBody updateUserTel(Map<String, Object> params) { |
| | | public ResultBody updateUserTel(Map<String, Object> params) throws Exception { |
| | | Long id = MapUtils.getLong(params, "id"); |
| | | String oldTel = MapUtils.getString(params, "oldTel"); |
| | | String newTel = MapUtils.getString(params, "newTel"); |
| | | String authCode = MapUtils.getString(params, "authCode"); |
| | | String userPassword = MapUtils.getString(params, "userPassword"); |
| | | String newTel = AesUtils.desEncrypt(MapUtils.getString(params, "newTel")).trim(); |
| | | String authCode = AesUtils.desEncrypt(MapUtils.getString(params, "authCode")).trim(); |
| | | String userPassword = AesUtils.desEncrypt(MapUtils.getString(params, "userPassword")).trim(); |
| | | |
| | | if (id > 0 && StringUtils.isNotBlank(oldTel) && StringUtils.isNotBlank(newTel) && StringUtils.isNotBlank(authCode) && StringUtils.isNotBlank(userPassword)) { |
| | | //检查验证码 |
| | |
| | | } else { |
| | | //验证旧手机号和密码 |
| | | SysUser sysUser = baseMapper.selectById(id); |
| | | userPassword = AesUtils.desEncrypt(userPassword); |
| | | if (passwordEncoder.matches(userPassword, sysUser.getPassword()) && sysUser.getMobile().equals((oldTel))) { |
| | | //验证通过,修改手机号 |
| | | SysUser user = new SysUser(); |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public ResultBody passwordByPhone(Map<String, Object> map) { |
| | | public ResultBody passwordByPhone(Map<String, Object> map) throws Exception { |
| | | //手机号,type,验证码,新密码 |
| | | String phone = MapUtils.getString(map, "phone"); |
| | | if (phone == null || "".equals(phone.trim())) { |
| | |
| | | if (newPass == null || "".equals(newPass.trim())) { |
| | | return ResultBody.failed("请输入正确的密码"); |
| | | } |
| | | if (CheckVerificationCode(ConstantSMS.PASSWORD_SMS, map.get("phone").toString(), verificationCode)) { |
| | | phone= AesUtils.desEncrypt(phone.trim()); |
| | | verificationCode= AesUtils.desEncrypt(verificationCode.trim()); |
| | | newPass= AesUtils.desEncrypt(newPass.trim()); |
| | | if (CheckVerificationCode(ConstantSMS.PASSWORD_SMS, phone, verificationCode)) { |
| | | //查询表 |
| | | Map<String, Object> selectMap = new HashMap<>(); |
| | | selectMap.put("mobile", phone); |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | @Override |
| | | public ResultBody doctorUserReg(UserRegVo userRegVo, SysUser sysUserd) { |
| | | public ResultBody doctorUserReg(UserRegVo userRegVo, SysUser sysUserd) throws Exception { |
| | | if(sysUserd.getId()==null){ |
| | | sysUserd = this.baseMapper.selectById(userRegVo.getUserId()); |
| | | } |
| | | userRegVo.setPassword(AesUtils.desEncrypt(userRegVo.getPassword()).trim()); |
| | | userRegVo.setUsername(AesUtils.desEncrypt(userRegVo.getUsername()).trim()); |
| | | //检查手机号是否已经注册 H端登录名和手机号存一样的值 |
| | | if (phoneIsUsed(userRegVo.getMobile())) { |
| | | return ResultBody.failed("该手机号已经注册"); |
| | |
| | | */ |
| | | @PutMapping(value = "/users/{id}/password") |
| | | @AuditLog(operation = "'重置用户密码:' + #id") |
| | | public ResultBody resetPassword(@PathVariable Long id) { |
| | | public ResultBody resetPassword(@PathVariable Long id) throws Exception{ |
| | | if (checkAdmin(id)) { |
| | | return ResultBody.failed(ADMIN_CHANGE_MSG); |
| | | } |
| | |
| | | * 用户自己修改密码 |
| | | */ |
| | | @PutMapping(value = "/users/password") |
| | | public ResultBody resetPassword(@RequestBody SysUser sysUser) { |
| | | public ResultBody resetPassword(@RequestBody SysUser sysUser) throws Exception { |
| | | if (checkAdmin(sysUser.getId())) { |
| | | return ResultBody.failed().msg(ADMIN_CHANGE_MSG); |
| | | } |
| | |
| | | * 用户自己修改密码-后端以外 |
| | | */ |
| | | @PutMapping(value = "/users/resetpassword") |
| | | public ResultBody resetClientPassword(@RequestParam Map<String, Object> params) { |
| | | public ResultBody resetClientPassword(@RequestParam Map<String, Object> params) throws Exception { |
| | | Long id = MapUtils.getLong(params, "id"); |
| | | String oldPassword = MapUtils.getString(params, "oldPassword"); |
| | | String newPassword = MapUtils.getString(params, "newPassword"); |
| | |
| | | * @return |
| | | */ |
| | | @PutMapping(value = "/users/updateusertel") |
| | | public ResultBody updateUserTel(@RequestParam Map<String, Object> params,@LoginUser SysUser sysUser) { |
| | | public ResultBody updateUserTel(@RequestParam Map<String, Object> params,@LoginUser SysUser sysUser) throws Exception { |
| | | String oldTel = MapUtils.getString(params, "oldTel"); |
| | | if (oldTel==null){ |
| | | return ResultBody.failed("请输入原账号"); |
| | |
| | | */ |
| | | @PostMapping("/users/doctorUserReg") |
| | | @AuditLog(operation = "'注册/添加用户:' + #userRegVo.mobile") |
| | | public ResultBody doctorUserReg(@RequestBody UserRegVo userRegVo,SysUser sysUser) { |
| | | public ResultBody doctorUserReg(@RequestBody UserRegVo userRegVo,SysUser sysUser) throws Exception { |
| | | return appUserService.doctorUserReg(userRegVo,sysUser); |
| | | } |
| | | |
| | |
| | | * 通过手机修改密码 |
| | | */ |
| | | @PutMapping(value = "/users/passwordByPhone") |
| | | public ResultBody passwordByPhone(@RequestBody Map<String, Object> map) { |
| | | public ResultBody passwordByPhone(@RequestBody Map<String, Object> map) throws Exception { |
| | | return appUserService.passwordByPhone(map); |
| | | } |
| | | |
| | |
| | | // var my_api_server_url = 'http://zuul.kidgrow.com/'; |
| | | // var my_api_server_url = 'http://192.168.2.240:8888/'; |
| | | var my_api_server_url = 'http://127.0.0.1:8888/'; |
| | | // var my_api_server_url = 'http://127.0.0.1:8888/'; |
| | | var my_api_server_url = 'http://uat-zuul.kidgrow.cloud/'; |
| | | |
| | |
| | | layer.closeAll('loading'); |
| | | if (data.code == 0) { |
| | | layer.msg(data.msg, { icon: 1, time: 500 }); |
| | | layer.alert("密码重置为:"+data.data, {icon: 1}); |
| | | } else { |
| | | layer.msg(data.msg, { icon: 2, time: 500 }); |
| | | } |
| | |
| | | </div> |
| | | </form> |
| | | </div> |
| | | |
| | | <script type="text/javascript" src="../../module/aes.js"></script> |
| | | <script> |
| | | layui.use(['layer','form', 'admin','config'], function () { |
| | | var form = layui.form; |
| | |
| | | form.on('submit(submit-psw)', function (data) { |
| | | |
| | | layer.load(2); |
| | | data.field.oldPassword=getAesString(data.field.oldPassword) |
| | | data.field.newPassword=getAesString(data.field.newPassword) |
| | | data.field.rePassword=getAesString(data.field.rePassword) |
| | | admin.req('api-user/users/password',JSON.stringify(data.field), function (data) { |
| | | layer.closeAll('loading'); |
| | | if (data.code == 0) { |