Procházet zdrojové kódy

Merge branch '20251119-wyp-weCom' into test

wangyunpeng před 1 dnem
rodič
revize
a01dfd2f10

+ 5 - 5
api-module/src/main/java/com/tzld/piaoquan/api/config/CrossOriginConfig.java

@@ -23,11 +23,11 @@ public class CrossOriginConfig implements WebMvcConfigurer {
 
     @Override
     public void addCorsMappings(CorsRegistry registry) {
-//        registry.addMapping("/**")
-//                .allowedOrigins("*")
-//                .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
-//                .maxAge(3600)
-//                .allowCredentials(false);
+        registry.addMapping("/**")
+                .allowedOrigins("*")
+                .allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
+                .maxAge(3600)
+                .allowCredentials(false);
     }
 
 }

+ 3 - 0
api-module/src/main/java/com/tzld/piaoquan/api/config/JwtInterceptor.java

@@ -47,6 +47,9 @@ public class JwtInterceptor implements HandlerInterceptor {
         ) {
             return Boolean.TRUE;
         }
+        if ("OPTIONS".equalsIgnoreCase(request.getMethod())) {
+            return Boolean.TRUE;
+        }
         // 忽略带JwtIgnore注解的请求, 不做后续token认证校验
         if (handler instanceof HandlerMethod) {
             HandlerMethod handlerMethod = (HandlerMethod) handler;

+ 11 - 2
api-module/src/main/java/com/tzld/piaoquan/api/controller/wecom/thirdpart/WeComThirdPartyAccountController.java

@@ -8,6 +8,7 @@ import com.tzld.piaoquan.api.model.vo.wecom.thirdpart.ThirdPartyAccountVO;
 import com.tzld.piaoquan.api.service.wecom.thirdparty.WeComThirdPartyAccountService;
 import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
 import com.tzld.piaoquan.growth.common.utils.page.Page;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -23,43 +24,51 @@ public class WeComThirdPartyAccountController {
     @Autowired
     private WeComThirdPartyAccountService service;
 
+    @ApiOperation(value = "获取登录二维码")
     @GetMapping("/getQrCode")
-    public CommonResponse<AccountQrCodeVO> getQrCode(@RequestParam Long id) {
+    public CommonResponse<AccountQrCodeVO> getQrCode(@RequestParam(required = false) Long id) {
         return CommonResponse.success(service.getQrCode(id));
     }
 
+    @ApiOperation(value = "检查登录状态")
     @GetMapping("/checkLogin")
     public CommonResponse<Integer> checkLogin(@RequestParam String uuid) {
         return CommonResponse.success(service.checkLogin(uuid));
     }
 
+    @ApiOperation(value = "设置验证码")
     @PostMapping("/setCheckCode")
     public CommonResponse<Void> setCheckCode(@RequestBody CheckCodeRequest param) {
         service.setCheckCode(param);
         return CommonResponse.success();
     }
 
+    @ApiOperation(value = "账号列表")
     @PostMapping("/list")
     public CommonResponse<Page<ThirdPartyAccountVO>> list(@RequestBody ThirdPartyAccountListParam param) {
         return CommonResponse.success(service.list(param));
     }
 
+    @ApiOperation(value = "获取推送人员列表")
     @GetMapping("/getPushAccountList")
-    public CommonResponse<List<IdNameVO<Long>>> getPushAccountList(@RequestParam Long accountId, @RequestParam String name) {
+    public CommonResponse<List<IdNameVO<Long>>> getPushAccountList(@RequestParam Long accountId, @RequestParam(required = false) String name) {
         return CommonResponse.success(service.getPushAccountList(accountId, name));
     }
 
+    @ApiOperation(value = "获取账号配置")
     @PostMapping("/getAccountConfig")
     public CommonResponse<ThirdPartyAccountConfigVO> getAccountConfig(@RequestBody ThirdPartyConfigGetParam param) {
         return CommonResponse.success(service.getAccountConfig(param));
     }
 
+    @ApiOperation(value = "账号配置保存")
     @PostMapping("/saveAccountConfig")
     public CommonResponse<Void> saveAccountConfig(@RequestBody ThirdPartyAccountConfigParam param) {
         service.saveAccountConfig(param);
         return CommonResponse.success();
     }
 
+    @ApiOperation(value = "登出")
     @PostMapping("/logout")
     public CommonResponse<Void> logout(@RequestBody ThirdPartyAccountLogOutParam param) {
         service.logout(param);

+ 6 - 1
api-module/src/main/java/com/tzld/piaoquan/api/controller/wecom/thirdpart/WeComThirdPartyRoomController.java

@@ -9,6 +9,7 @@ import com.tzld.piaoquan.api.model.vo.wecom.thirdpart.ThirdPartyRoomVO;
 import com.tzld.piaoquan.api.service.wecom.thirdparty.WeComThirdPartyRoomService;
 import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
 import com.tzld.piaoquan.growth.common.utils.page.Page;
+import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
@@ -24,21 +25,25 @@ public class WeComThirdPartyRoomController {
     @Autowired
     private WeComThirdPartyRoomService service;
 
+    @ApiOperation(value = "群列表")
     @PostMapping("/list")
     public CommonResponse<Page<ThirdPartyRoomVO>> list(@RequestBody ThirdPartyRoomListParam param) {
         return CommonResponse.success(service.list(param));
     }
 
+    @ApiOperation(value = "获取推送人员列表")
     @GetMapping("/getPushAccountList")
-    public CommonResponse<List<IdNameVO<Long>>> getPushAccountList(@RequestParam Long roomId, @RequestParam String name) {
+    public CommonResponse<List<IdNameVO<Long>>> getPushAccountList(@RequestParam Long roomId, @RequestParam(required = false) String name) {
         return CommonResponse.success(service.getPushAccountList(roomId, name));
     }
 
+    @ApiOperation(value = "获取群配置")
     @PostMapping("/getRoomConfig")
     public CommonResponse<ThirdPartyRoomConfigVO> getRoomConfig(@RequestBody ThirdPartyConfigGetParam param) {
         return CommonResponse.success(service.getRoomConfig(param));
     }
 
+    @ApiOperation(value = "保存群配置")
     @PostMapping("/saveRoomConfig")
     public CommonResponse<Void> saveRoomConfig(@RequestBody ThirdPartyRoomConfigParam param) {
         service.saveRoomConfig(param);

+ 2 - 1
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/wecom/thirdpart/ext/ThirdPartWeComRoomMapperExt.java

@@ -8,9 +8,10 @@ import java.util.List;
 
 public interface ThirdPartWeComRoomMapperExt {
 
-    int getRoomCount(@Param("param") ThirdPartyRoomListParam param);
+    int getRoomCount(@Param("param") ThirdPartyRoomListParam param, @Param("pushAccountId") Long pushAccountId);
 
     List<ThirdPartWeComRoom> getRoomList(@Param("param") ThirdPartyRoomListParam param,
+                                         @Param("pushAccountId") Long pushAccountId,
                                          @Param("offset") int offset, @Param("pageSize") Integer pageSize);
 
 }

+ 2 - 0
api-module/src/main/java/com/tzld/piaoquan/api/dao/mapper/wecom/thirdpart/ext/ThirdPartWeComStaffMapperExt.java

@@ -16,4 +16,6 @@ public interface ThirdPartWeComStaffMapperExt {
     List<ThirdPartWeComStaff> getPushStaffList(@Param("accountId") Long accountId,
                                                @Param("roomId") Long roomId,
                                                @Param("name") String name);
+
+    Long getStaffIdByName(@Param("name") String name);
 }

+ 12 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/wecom/thirdparty/impl/WeComThirdPartyAccountServiceImpl.java

@@ -7,6 +7,7 @@ import com.tzld.piaoquan.api.common.enums.ExceptionEnum;
 import com.tzld.piaoquan.api.common.enums.wecom.ConfigSyncEnum;
 import com.tzld.piaoquan.api.common.enums.wecom.ConfigTaskContentTypeEnum;
 import com.tzld.piaoquan.api.common.enums.wecom.ThirdPartWeComStaffStatusEnum;
+import com.tzld.piaoquan.api.common.enums.wecom.WeComThirdPartyCallBackTypeEnum;
 import com.tzld.piaoquan.api.common.exception.CommonException;
 import com.tzld.piaoquan.api.component.WeComThirdPartyApiClient;
 import com.tzld.piaoquan.api.dao.mapper.wecom.thirdpart.ThirdPartWeComStaffConfigMapper;
@@ -100,7 +101,17 @@ public class WeComThirdPartyAccountServiceImpl implements WeComThirdPartyAccount
     @Override
     public Integer checkLogin(String uuid) {
         String loginStatusKey = Constant.loginStatusKey.replace("{uuid}", uuid);
-        return redisUtils.getInteger(loginStatusKey);
+        Integer result = redisUtils.getInteger(loginStatusKey);
+        if (result == 0) {
+            ThirdPartWeComStaff staff = weComThirdPartyService.getStaffByUuid(uuid);
+            if (Objects.isNull(staff)) {
+                throw new CommonException(ExceptionEnum.PARAM_ERROR.getCode(), "企微账号不存在");
+            }
+            if (staff.getStatus() == ThirdPartWeComStaffStatusEnum.NORMAL.getVal()) {
+                return WeComThirdPartyCallBackTypeEnum.LOGIN_SUCCESS.getVal();
+            }
+        }
+        return result;
     }
 
     @Override

+ 6 - 2
api-module/src/main/java/com/tzld/piaoquan/api/service/wecom/thirdparty/impl/WeComThirdPartyRoomServiceImpl.java

@@ -50,12 +50,16 @@ public class WeComThirdPartyRoomServiceImpl implements WeComThirdPartyRoomServic
     public Page<ThirdPartyRoomVO> list(ThirdPartyRoomListParam param) {
         Page<ThirdPartyRoomVO> result = new Page<>(param.getPageNum(), param.getPageSize());
         int offset = (param.getPageNum() - 1) * param.getPageSize();
-        int count = roomMapperExt.getRoomCount(param);
+        Long pushAccountId = null;
+        if (StringUtils.isNotBlank(param.getPushAccountName())) {
+            pushAccountId = staffMapperExt.getStaffIdByName(param.getPushAccountName());
+        }
+        int count = roomMapperExt.getRoomCount(param, pushAccountId);
         result.setTotalSize(count);
         if (count == 0) {
             return result;
         }
-        List<ThirdPartWeComRoom> roomList = roomMapperExt.getRoomList(param, offset, param.getPageSize());
+        List<ThirdPartWeComRoom> roomList = roomMapperExt.getRoomList(param, pushAccountId, offset, param.getPageSize());
         List<ThirdPartyRoomVO> list = buildThirdPartyRoomVOList(roomList);
         result.setObjs(list);
         return result;

+ 3 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/wecom/thirdparty/impl/WeComThirdPartyServiceImpl.java

@@ -525,6 +525,9 @@ public class WeComThirdPartyServiceImpl implements WeComThirdPartyService {
 
     @Override
     public List<ThirdPartWeComStaff> getStaffListByThirdStaffIds(List<Long> thirdStaffIds) {
+        if (CollectionUtils.isEmpty(thirdStaffIds)) {
+            return Collections.emptyList();
+        }
         ThirdPartWeComStaffExample example = new ThirdPartWeComStaffExample();
         example.createCriteria().andThirdStaffIdIn(thirdStaffIds);
         return thirdPartWeComStaffMapper.selectByExample(example);

+ 14 - 10
api-module/src/main/resources/mapper/wecom/thirdpart/ext/ThirdPartWeComRoomMapperExt.xml

@@ -4,18 +4,20 @@
 
     <select id="getRoomCount" resultType="java.lang.Integer">
         select count(1)
-        from third_part_we_com_staff staff
+        from third_part_we_com_room room
+        join third_part_we_com_staff staff on room.staff_id = staff.id
         join third_part_we_com_corp corp on staff.corp_id = corp.id
+        left join third_part_we_com_room_config room_config on room.id = room_config.room_id and room_config.status = 1
         <where>
             <trim prefixOverrides="and">
                 <if test="param.corpName != null">
                     and corp.name = #{param.corpName}
                 </if>
-                <if test="param.accountName != null">
-                    and staff.name = #{param.accountName}
+                <if test="param.groupLeaderName != null">
+                    and staff.name = #{param.groupLeaderName}
                 </if>
-                <if test="param.mobile != null">
-                    and staff.mobile = #{param.mobile}
+                <if test="param.pushAccountName != null">
+                    and (room_config.primary_push_account_id = #{pushAccountId} or room_config.secondary_push_account_id = #{pushAccountId})
                 </if>
             </trim>
         </where>
@@ -25,17 +27,19 @@
             resultType="com.tzld.piaoquan.api.model.po.wecom.thirdpart.ThirdPartWeComRoom">
         select room.*
         from third_part_we_com_room room
-        join third_part_we_com_corp corp on room.corp_id = corp.id
+        join third_part_we_com_staff staff on room.staff_id = staff.id
+        join third_part_we_com_corp corp on staff.corp_id = corp.id
+        left join third_part_we_com_room_config room_config on room.id = room_config.room_id and room_config.status = 1
         <where>
             <trim prefixOverrides="and">
                 <if test="param.corpName != null">
                     and corp.name = #{param.corpName}
                 </if>
-                <if test="param.accountName != null">
-                    and staff.name = #{param.accountName}
+                <if test="param.groupLeaderName!= null">
+                    and staff.name = #{param.groupLeaderName}
                 </if>
-                <if test="param.mobile != null">
-                    and staff.mobile = #{param.mobile}
+                <if test="param.pushAccountName != null">
+                    and (room_config.primary_push_account_id = #{pushAccountId} or room_config.secondary_push_account_id = #{pushAccountId})
                 </if>
             </trim>
         </where>

+ 6 - 0
api-module/src/main/resources/mapper/wecom/thirdpart/ext/ThirdPartWeComStaffMapperExt.xml

@@ -64,4 +64,10 @@
         </if>
     </select>
 
+    <select id="getStaffIdByName" resultType="java.lang.Long">
+        select third_staff_id
+        from third_part_we_com_staff
+        where name = #{name}
+    </select>
+
 </mapper>