Przeglądaj źródła

Merge remote-tracking branch 'origin/master'

yfh 1 tydzień temu
rodzic
commit
240f97f6c6

+ 2 - 0
fs-service/src/main/java/com/fs/his/config/FsSmsConfig.java

@@ -21,4 +21,6 @@ public class FsSmsConfig {
     private String dhPassword2;
     private String dhSign;
 
+    private Integer isSmsVerification; //是否开启短信验证
+
 }

+ 17 - 10
fs-service/src/main/java/com/fs/hisStore/service/impl/FsMenuScrmServiceImpl.java

@@ -3,6 +3,8 @@ package com.fs.hisStore.service.impl;
 import java.util.List;
 import com.fs.common.utils.DateUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.cache.annotation.CacheEvict;
+import org.springframework.cache.annotation.Cacheable;
 import org.springframework.stereotype.Service;
 import com.fs.hisStore.mapper.FsMenuScrmMapper;
 import com.fs.hisStore.domain.FsMenuScrm;
@@ -10,7 +12,7 @@ import com.fs.hisStore.service.IFsMenuScrmService;
 
 /**
  * 用户端菜单管理Service业务层处理
- * 
+ *
  * @author fs
  * @date 2022-03-15
  */
@@ -22,7 +24,7 @@ public class FsMenuScrmServiceImpl implements IFsMenuScrmService
 
     /**
      * 查询用户端菜单管理
-     * 
+     *
      * @param menuId 用户端菜单管理ID
      * @return 用户端菜单管理
      */
@@ -34,23 +36,25 @@ public class FsMenuScrmServiceImpl implements IFsMenuScrmService
 
     /**
      * 查询用户端菜单管理列表
-     * 
-     * @param fsMenu 用户端菜单管理
+     *
+     * @param param 用户端菜单管理
      * @return 用户端菜单管理
      */
     @Override
-    public List<FsMenuScrm> selectFsMenuList(FsMenuScrm fsMenu)
+    @Cacheable(value = "selectFsMenuList", key = "#param")
+    public List<FsMenuScrm> selectFsMenuList(FsMenuScrm param)
     {
-        return fsMenuMapper.selectFsMenuList(fsMenu);
+        return fsMenuMapper.selectFsMenuList(param);
     }
 
     /**
      * 新增用户端菜单管理
-     * 
+     *
      * @param fsMenu 用户端菜单管理
      * @return 结果
      */
     @Override
+    @CacheEvict(value = "selectFsMenuList",allEntries = true)
     public int insertFsMenu(FsMenuScrm fsMenu)
     {
         fsMenu.setCreateTime(DateUtils.getNowDate());
@@ -59,11 +63,12 @@ public class FsMenuScrmServiceImpl implements IFsMenuScrmService
 
     /**
      * 修改用户端菜单管理
-     * 
+     *
      * @param fsMenu 用户端菜单管理
      * @return 结果
      */
     @Override
+    @CacheEvict(value = "selectFsMenuList",allEntries = true)
     public int updateFsMenu(FsMenuScrm fsMenu)
     {
         fsMenu.setUpdateTime(DateUtils.getNowDate());
@@ -72,11 +77,12 @@ public class FsMenuScrmServiceImpl implements IFsMenuScrmService
 
     /**
      * 批量删除用户端菜单管理
-     * 
+     *
      * @param menuIds 需要删除的用户端菜单管理ID
      * @return 结果
      */
     @Override
+    @CacheEvict(value = "selectFsMenuList",allEntries = true)
     public int deleteFsMenuByIds(Long[] menuIds)
     {
         return fsMenuMapper.deleteFsMenuByIds(menuIds);
@@ -84,11 +90,12 @@ public class FsMenuScrmServiceImpl implements IFsMenuScrmService
 
     /**
      * 删除用户端菜单管理信息
-     * 
+     *
      * @param menuId 用户端菜单管理ID
      * @return 结果
      */
     @Override
+    @CacheEvict(value = "selectFsMenuList",allEntries = true)
     public int deleteFsMenuById(Long menuId)
     {
         return fsMenuMapper.deleteFsMenuById(menuId);

+ 75 - 0
fs-user-app/src/main/java/com/fs/app/controller/AppLoginController.java

@@ -120,6 +120,81 @@ public class AppLoginController extends AppBaseController{
         }
     }
 
+    @PostMapping("/registerSendCode")
+    public R registerSendCode(@RequestBody Map<String, String> body){
+        String phone = body.get("phone");
+        String encryptPhone = encryptPhone(phone);
+        List<FsUser> user = userService.selectFsUserListByPhone(encryptPhone);
+        if(CollectionUtil.isEmpty(user)){
+            user = userService.selectFsUserListByPhone(encryptPhoneOldKey(phone));
+        }
+        if (!CollectionUtil.isEmpty(user)){
+            return R.error("此电话号码已注册");
+        }
+
+        // 验证码 key(存验证码,3分钟有效)
+        String smsCodeKey = "sms:code:" + phone;
+        // 发送冷却 key(限制60秒内不能再次发送)
+        String smsCooldownKey = "sms:cooldown:" + phone;
+
+        // 判断是否在60秒冷却时间内
+        if (redisCache.getCacheObject(smsCooldownKey) != null) {
+            return R.error("验证码已发送,请稍后再试");
+        }
+
+        // 生成新的验证码
+        String smsCode = VerifyCodeUtil.generateCode();
+
+        // 发送短信
+        smsService.sendCaptcha(phone, smsCode, "验证码");
+
+        // 缓存验证码(3分钟有效)
+        redisCache.setCacheObject(smsCodeKey, smsCode, 180, TimeUnit.SECONDS);
+        // 设置冷却时间(60秒内不能再发)
+        redisCache.setCacheObject(smsCooldownKey, "1", 60, TimeUnit.SECONDS);
+
+        return R.ok("验证码已发送");
+    }
+
+
+    @PostMapping("/registerByPhone")
+    public R registerByPhone(@RequestBody Map<String,String> map){
+        String phone = map.get("phone");
+        String code = map.get("code");
+        String password = map.get("password");
+        String encryptPhone = encryptPhone(phone);
+        List<FsUser> users = userService.selectFsUserListByPhone(encryptPhone);
+        if (users == null || CollectionUtil.isEmpty(users)){
+            String s = encryptPhoneOldKey(phone);
+            users = userService.selectFsUserListByPhone(s);
+        }
+        if (!CollectionUtil.isEmpty(users)){
+            return R.error("此账号已经注册");
+        }
+        String redisCode = redisCache.getCacheObject("sms:code:" + phone);
+        if (StringUtils.isEmpty(redisCode)){
+            return R.error("验证码已过期,请重新发送");
+        }
+        if (!redisCode.equals(code)) {
+            return R.error("验证码错误");
+        }
+        FsUser user = new FsUser();
+        // 创建新用户
+        user.setPhone(phone);
+        user.setJpushId(map.get("jpushId"));
+        user.setSource(map.get("source"));
+        user.setNickName("app用户" + phone.substring(phone.length() - 4));
+        user.setStatus(1);
+        user.setAvatar("https://cos.his.cdwjyyh.com/fs/20240926/420728ee06e54575ba82665dedb4756b.png");
+        user.setPassword(Md5Utils.hash(password));
+        user.setCreateTime(new Date());
+        if (userService.insertFsUser(user) > 0) {
+            return R.ok("注册成功");
+        } else {
+            return R.error("注册失败");
+        }
+    }
+
 
 
 

+ 17 - 0
fs-user-app/src/main/java/com/fs/app/controller/CommonController.java

@@ -41,6 +41,7 @@ import com.fs.event.TemplateEvent;
 import com.fs.event.TemplateListenEnum;
 import com.fs.event.WeixinTemplateService;
 import com.fs.framework.config.ServerConfig;
+import com.fs.his.config.FsSmsConfig;
 import com.fs.his.config.FsSysConfig;
 import com.fs.his.domain.*;
 import com.fs.his.param.FsInquiryOrderFinishParam;
@@ -662,4 +663,20 @@ public class CommonController {
 
 		return R.ok().put("addressUrl", addressUrl).put("imgpath", imgPath).put("sendType", sendType);
 	}
+
+	@GetMapping(value = "/isSmsVerification")
+	@ApiOperation("获取app是否短信验证配置")
+	public R isSmsVerification()
+	{
+		String config=configService.selectConfigByKey("his.sms");
+		if (StringUtils.isBlank(config)){
+			return  R.ok().put("isSmsVerification",0);
+		}
+		FsSmsConfig sms = JSON.parseObject(config, FsSmsConfig.class);
+		if (sms != null && sms.getIsSmsVerification() != null){
+			return R.ok().put("isSmsVerification",sms.getIsSmsVerification());
+		}
+		return  R.ok().put("isSmsVerification",0);
+
+	}
 }

+ 8 - 0
fs-user-app/src/main/java/com/fs/app/controller/store/IndexScrmController.java

@@ -91,6 +91,14 @@ public class IndexScrmController extends AppBaseController {
 		return R.ok().put("data",list);
 	}
 
+	@ApiOperation("读取菜单配置")
+	@GetMapping("/getMenuList")
+	public R getMenuList(FsMenuScrm map){
+		map.setIsShow(1);
+		List<FsMenuScrm> list=menuService.selectFsMenuList(map);
+		return R.ok().put("data",list);
+	}
+
 	@ApiOperation("读取个人中心")
 	@GetMapping("/getMenuUser")
 	@Cacheable("menuUser")