ソースを参照

Merge remote-tracking branch 'refs/remotes/origin/dev-1.2.1' into dev-1.2.1-lsd

lsd 3 ヶ月 前
コミット
9375e49414

+ 8 - 4
leromro-admin/src/main/java/com/leromro/web/controller/system/SysLoginController.java

@@ -150,10 +150,14 @@ public class SysLoginController
     @ApiOperation("修改当前用户定位")
     @PostMapping("/setUserLocation")
     public AjaxResult setUserOrWorker(@RequestBody SysUser user){
-        Long userId = SecurityUtils.getUserId();
-        user.setUserId(userId);
-        userService.updateById(user);
-        return AjaxResult.success();
+        try {
+            Long userId = SecurityUtils.getUserId();
+            user.setUserId(userId);
+            userService.updateById(user);
+            return AjaxResult.success();
+        } catch (Exception e) {
+            return null;
+        }
     }
 
     /**

+ 3 - 0
leromro-admin/src/main/resources/META-INF/MANIFEST.MF

@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Main-Class: com.leromro.LeromroApplication
+

+ 1 - 1
leromro-admin/src/main/resources/application.yml

@@ -1,7 +1,7 @@
 # 激活的环境(dev/test/prod)
 spring:
   profiles:
-    active: dev
+    active: prod
   # 资源信息
   messages:
     # 国际化资源文件路径

+ 13 - 4
leromro-common/src/main/java/com/leromro/common/utils/WeChatMiniProgramUtil.java

@@ -36,6 +36,8 @@ public class WeChatMiniProgramUtil {
     private final RedissonClient redissonClient;
     private final RestTemplate restTemplate;
     private final ObjectMapper objectMapper;
+    private final String cacheKey = "wechat:access_token";
+    private final String lockKey = "lock:wechat:access_token";
 
     private final String wxUrl;
     private final String appId;
@@ -62,9 +64,6 @@ public class WeChatMiniProgramUtil {
      * 获取 access_token(带 Redis 缓存和 Redisson 分布式锁)
      */
     public String getAccessToken() throws InterruptedException {
-        String cacheKey = "wechat:access_token";
-        String lockKey = "lock:wechat:access_token";
-
         // 1. 先从缓存获取
         String accessToken = redisTemplate.opsForValue().get(cacheKey);
         if (accessToken != null) {
@@ -123,7 +122,8 @@ public class WeChatMiniProgramUtil {
      */
     public String generateQrCodeWithText(String scene, String page, String footerText) throws Exception {
         byte[] qrCodeBytes = generateUnlimitedQrCode(scene, page);
-        return addTextToQrCode(qrCodeBytes, footerText, "微软雅黑", 18, Color.BLACK);
+        String fontName = "wqy-microhei";
+        return addTextToQrCode(qrCodeBytes, footerText, fontName, 18, Color.BLACK);
     }
 
 
@@ -164,6 +164,7 @@ public class WeChatMiniProgramUtil {
 
         byte[] body = response.getBody();
         if (body != null && body.length > 0 && body[0] == '{') {
+            handleFailure(response);
             String error = new String(body, StandardCharsets.UTF_8);
             throw new RuntimeException("生成小程序码失败:" + error);
         }
@@ -171,6 +172,14 @@ public class WeChatMiniProgramUtil {
         return body;
     }
 
+    /**
+     * 请求失败处理
+     */
+    private void handleFailure(ResponseEntity response) {
+        // todo 直接清除原来的token(防止多环境导致的token失效)
+        redisTemplate.delete(cacheKey);
+    }
+
     /**
      * 在小程序码图片底部添加指定文字(带白色背景)
      *

+ 18 - 15
leromro-core/src/main/java/com/leromro/core/controller/SearchHistoryController.java

@@ -37,22 +37,25 @@ public class SearchHistoryController {
     @ApiOperation(value = "在redis中获取首页搜索记录")
     @GetMapping("/businessTireNameHistory")
     public R<List<String>> searchHistory(){
-        Long userId = SecurityUtils.getUserId();
-        List<String> searchList = new ArrayList<>();
-        String key = CacheConstants.SEARCH_HISTORY_KEY + userId;
-        long start = 1;
-        long size = 10;
-        Set<ZSetOperations.TypedTuple> historySet = redisTemplate.opsForZSet().reverseRangeWithScores(key, start - 1, size - 1);
-        Iterator<ZSetOperations.TypedTuple> iterator = historySet.iterator();
-        BigDecimal bigDecimal = null;
-        while (iterator.hasNext()){
-            ZSetOperations.TypedTuple next = iterator.next();
-            BigDecimal decimal = BigDecimal.valueOf(next.getScore());
-            if (next.getValue() != null){
-                searchList.add(next.getValue().toString());
+        try {
+            Long userId = SecurityUtils.getUserId();
+            List<String> searchList = new ArrayList<>();
+            String key = CacheConstants.SEARCH_HISTORY_KEY + userId;
+            long start = 1;
+            long size = 10;
+            Set<ZSetOperations.TypedTuple> historySet = redisTemplate.opsForZSet().reverseRangeWithScores(key, start - 1, size - 1);
+            Iterator<ZSetOperations.TypedTuple> iterator = historySet.iterator();
+            BigDecimal bigDecimal = null;
+            while (iterator.hasNext()){
+                ZSetOperations.TypedTuple next = iterator.next();
+                BigDecimal decimal = BigDecimal.valueOf(next.getScore());
+                if (next.getValue() != null){
+                    searchList.add(next.getValue().toString());
+                }
             }
+            return R.ok(searchList);
+        }catch (Exception e){
+            return R.ok();
         }
-        return R.ok(searchList);
     }
-
 }

+ 6 - 1
leromro-core/src/main/java/com/leromro/core/controller/VolunteerInfoController.java

@@ -177,7 +177,12 @@ public class VolunteerInfoController extends BaseController {
     @ApiOperation("小程序志愿者首页获取自己的头像(用于排班管理)")
     @GetMapping("/volunteerPicture")
     public List<String> getVolunteerPicture() {
-        return volunteerInfoService.getVolunteerPicture(SecurityUtils.getUserId());
+        try {
+            Long userId = SecurityUtils.getUserId();
+            return volunteerInfoService.getVolunteerPicture(userId);
+        }catch (Exception e){
+            return null;
+        }
     }
 
     /**

+ 2 - 2
leromro-core/src/main/java/com/leromro/core/mapper/LSlideshowMapper.java

@@ -16,11 +16,11 @@ public interface LSlideshowMapper extends BaseMapper<Slideshow>
 {
     /**
      * 查询主页轮播图或后续其他广告图片
-     * 
+     *
      * @param slideshowType 主页轮播图或后续其他广告图片主键
      * @return 主页轮播图或后续其他广告图片
      */
-    public Slideshow selectLSlideshowBySlideshowType(ListPermission listPermission ,@Param("slideshowType") Long slideshowType);
+    public Slideshow selectLSlideshowBySlideshowType(@Param("slideshowType") Long slideshowType);
 
     /**
      * 查询主页轮播图或后续其他广告图片列表

+ 1 - 1
leromro-core/src/main/java/com/leromro/core/service/impl/InviteUserServiceImpl.java

@@ -288,7 +288,7 @@ public class InviteUserServiceImpl extends ServiceImpl<InviteUserMapper, InviteU
         }
         // 获取邀请二维码
         String qrCode = null;
-        String footerText = "金邻助家"+referrerName+")";
+        String footerText = "金邻助家("+referrerName+")";
         try {
             // 参数说明(referrerType+":"+referrerId+":2"),最后一个2标识当前二维码版本
             qrCode = weChatMiniProgramUtil.generateQrCodeWithText(referrerType+":"+referrerId+":2", page,footerText);

+ 2 - 2
leromro-core/src/main/java/com/leromro/core/service/impl/LSlideshowServiceImpl.java

@@ -41,8 +41,8 @@ public class LSlideshowServiceImpl extends ServiceImpl<LSlideshowMapper, Slidesh
      */
     @Override
     public Slideshow selectLSlideshowBySlideshowType(Long slideshowType)
-    {
-        Slideshow slideshow = lSlideshowMapper.selectLSlideshowBySlideshowType(new ListPermission(Slideshow.class, CommonConstants.CHECK_PROVINCE_CITY_DISTRICT),slideshowType);
+    {   //new ListPermission(Slideshow.class, CommonConstants.CHECK_PROVINCE_CITY_DISTRICT),
+        Slideshow slideshow = lSlideshowMapper.selectLSlideshowBySlideshowType(slideshowType);
         if (slideshow==null){
             return lSlideshowMapper.selectDefultSlideshowByType(slideshowType);
         }

+ 3 - 3
leromro-core/src/main/java/com/leromro/core/service/impl/MainOrderServiceImpl.java

@@ -110,9 +110,9 @@ public class MainOrderServiceImpl extends ServiceImpl<MainOrdersMapper, MainOrde
     @Override
     @Transactional(rollbackFor = Exception.class)
     public R<OrderPaymentVO> createOrders(OrderRequestDTO orderRequest) throws Exception {
-//        if (1==1) {
-//            return R.fail("当前地区志愿者批量认证中,暂时关闭预约功能,请谅解");
-//        }
+        if (1==1) {
+            return R.fail("当前地区志愿者批量认证中,暂时关闭预约功能,请谅解");
+        }
         //响应数据
         OrderPaymentVO vo = new OrderPaymentVO();
         //订单信息

+ 8 - 3
leromro-core/src/main/java/com/leromro/core/service/impl/VolunteerInfoServiceImpl.java

@@ -188,9 +188,14 @@ public class VolunteerInfoServiceImpl extends ServiceImpl<VolunteerInfoMapper, V
         //查询出志愿者信息
         List<VolunteerInfoVO> infos = volunteerInfoMapper.selectVolunteerInfoSimple(volunteerInfo);
         //把搜索历史记录放在redis中
-        Long userId = SecurityUtils.getUserId();
-        redisTemplate.opsForZSet().add(CacheConstants.SEARCH_HISTORY_KEY + userId, volunteerInfo.getBusinessTierName(), System.currentTimeMillis());
-        insertSearchSort(CacheConstants.SEARCH_HISTORY_KEY + userId, volunteerInfo.getBusinessTierName());
+        try {
+            Long userId = SecurityUtils.getUserId();
+            redisTemplate.opsForZSet().add(CacheConstants.SEARCH_HISTORY_KEY + userId, volunteerInfo.getBusinessTierName(), System.currentTimeMillis());
+            insertSearchSort(CacheConstants.SEARCH_HISTORY_KEY + userId, volunteerInfo.getBusinessTierName());
+        }catch (Exception e){
+
+        }
+
         //查询出所有服务名称
        /* Map<Long, String> idMapTierName = businessManagementService.list().stream().collect(Collectors.toMap(BusinessManagement::getBusinessManagementId, BusinessManagement::getBusinessTierName));
         if (ObjectUtil.isNotEmpty(infos)){

+ 10 - 8
leromro-core/src/main/resources/mapper/core/VolunteerInfoMapper.xml

@@ -53,7 +53,8 @@
         select volunteer_id, skill_describe,age ,service_category,name,volunteer_picture,score,business_management_id ,
                business_price,business_tier_name , business_unit,business_describe
         from l_volunteer_info lvi
-        where app_status = 2
+        <where> app_status = 2
+
         AND EXISTS (
         SELECT 1
         FROM l_volunteer_work_date lvw
@@ -69,11 +70,12 @@
     <!-- <if test="info.provinceCode != null and info.provinceCode != ''">and lvi.province_code = #{info.provinceCode}</if>-->
     <!-- <if test="info.cityCode != null and info.cityCode != ''">and lvi.city_code = #{info.cityCode}</if>-->
     <!-- <if test="info.districtCode != null and info.districtCode != ''">and lvi.district_code = #{info.districtCode}</if>-->
-        <if test="info.businessTierName != null and info.businessTierName != ''">
-        and lvi.business_tier_name like concat('%', #{info.businessTierName}, '%') or
-        lvi.name like concat('%', #{info.businessTierName}, '%') or
-        lvi.business_describe like concat('%', #{info.businessTierName}, '%')
-        </if>
+            <if test="info.businessTierName != null and info.businessTierName != ''">
+                and (lvi.business_tier_name like concat('%', #{info.businessTierName}, '%') or
+                lvi.name like concat('%', #{info.businessTierName}, '%') or
+                lvi.business_describe like concat('%', #{info.businessTierName}, '%'))
+            </if>
+        </where>
     </select>
 
     <select id="getCurrentOrgVolunteerList" resultType="com.leromro.core.domain.VolunteerInfo">
@@ -93,7 +95,7 @@
     </select>
     <select id="searchBusinessTypeList" resultType="com.leromro.core.domain.vo.BusinessManagementVO"
             parameterType="com.leromro.core.domain.dto.VolunteerListDTO">
-        select  lbm2.business_management_id as id,lbm2.parent_id,lbm2.business_name,lbm2.business_tier_name,lbm2.business_icon,lvi.project_type_name
+        select DISTINCT lbm2.business_management_id as id,lbm2.parent_id,lbm2.business_name,lbm2.business_tier_name,lbm2.business_icon,lvi.project_type_name
         from l_volunteer_info lvi left join l_business_management  lbm2 on lvi.business_management_id = lbm2.business_management_id
         where lvi.app_status = 2
         AND EXISTS (
@@ -113,7 +115,7 @@
             lvi.name like concat('%', #{info.businessTierName}, '%') or
             lvi.business_describe like concat('%', #{info.businessTierName}, '%')
         </if>
-        group by lbm2.business_tier_name
+
         <!--        <if test="info.provinceCode != null and info.provinceCode != ''">and lvi.province_code = #{info.provinceCode}</if>-->
         <!--        <if test="info.cityCode != null and info.cityCode != ''">and lvi.city_code = #{info.cityCode}</if>-->
         <!--        <if test="info.districtCode != null and info.districtCode != ''">and lvi.district_code = #{info.districtCode}</if>-->

+ 3 - 1
leromro-framework/src/main/java/com/leromro/framework/config/SecurityConfig.java

@@ -112,7 +112,9 @@ public class SecurityConfig
                 permitAllUrl.getUrls().forEach(url -> requests.antMatchers(url).permitAll());
                 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
                 requests.antMatchers("/login","/loginWeb", "/register", "/captchaImage","/system/dict/**,","/websocket/**",
-                                "/core/users/orders/payNotify","/core/users/orders/refundNotify","/system/config/getHomeRollText","/system/config/serviceUrl/**").permitAll()
+                                "/core/users/orders/payNotify","/core/users/orders/refundNotify","/system/config/getHomeRollText",
+                                "/system/config/serviceUrl/**","/core/searchHistory/info/businessTireNameHistory","/core/volunteer/info/searchBusinessTypeList",
+                                "/core/volunteer/info/volunteerPicture","/setUserLocation").permitAll()
                     //微信小程序需要提供部分预览功能
                     .antMatchers("/core/volunteer/info/list","/core/volunteer/info/getDetails",
                                 "/web/core/slideshow/**","/core/business/management/**",