提交 53c8bb27 作者: 洪东保

1.删除无用代码

2.智能体授权用户查看和保存接口-aigc服务使用
父级 ab6710f3
...@@ -79,8 +79,6 @@ public class RobotWebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -79,8 +79,6 @@ public class RobotWebSecurityConfig extends WebSecurityConfigurerAdapter {
*/ */
@Override @Override
protected void configure(HttpSecurity httpSecurity) throws Exception { protected void configure(HttpSecurity httpSecurity) throws Exception {
// 白名单 智能体授权相关
String[] api = {"/agent/auth/**"};
httpSecurity httpSecurity
// 由于使用的是JWT,我们这里不需要csrf // 由于使用的是JWT,我们这里不需要csrf
.csrf().disable() .csrf().disable()
...@@ -90,7 +88,7 @@ public class RobotWebSecurityConfig extends WebSecurityConfigurerAdapter { ...@@ -90,7 +88,7 @@ public class RobotWebSecurityConfig extends WebSecurityConfigurerAdapter {
.authorizeRequests() .authorizeRequests()
// 对于登录login 图标 要允许匿名访问 // 对于登录login 图标 要允许匿名访问
// .antMatchers(customApi).access("@robotJwtCustomTokenFilter.checkToken(request)") // .antMatchers(customApi).access("@robotJwtCustomTokenFilter.checkToken(request)")
.antMatchers(api).anonymous() .antMatchers("/agent/auth/**").anonymous()
.antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css",
"/**/*.js", "/**/*.map") "/**/*.js", "/**/*.map")
.permitAll() .permitAll()
......
...@@ -47,7 +47,8 @@ public class RobotJwtAuthenticationTokenFilter extends OncePerRequestFilter { ...@@ -47,7 +47,8 @@ public class RobotJwtAuthenticationTokenFilter extends OncePerRequestFilter {
// 定义白名单路径(无需JWT验证的接口) // 定义白名单路径(无需JWT验证的接口)
private static final List<String> WHITE_LIST = Arrays.asList( private static final List<String> WHITE_LIST = Arrays.asList(
"/user/**" // 登录接口 "/user/**", // 登录接口
"/agent/auth/**" // 登录接口
); );
// 判断路径是否在白名单中(支持Ant风格路径匹配) // 判断路径是否在白名单中(支持Ant风格路径匹配)
......
package com.cmeeting.controller; package com.cmeeting.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cmeeting.ad.entity.SysUserSync;
import com.cmeeting.constant.CategoryConstant;
import com.cmeeting.pojo.CoreModulePermissions; import com.cmeeting.pojo.CoreModulePermissions;
import com.cmeeting.pojo.SysUserSyncCategory;
import com.cmeeting.service.IAgentAuthService; import com.cmeeting.service.IAgentAuthService;
import com.cmeeting.service.ISysUserSyncCategoryService;
import com.cmeeting.service.SysUserSyncService;
import com.cmeeting.util.R; import com.cmeeting.util.R;
import com.cmeeting.vo.AgentAuthVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.List; import java.util.*;
import java.util.stream.Collectors;
@RestController @RestController
@RequestMapping("/agent/auth") @RequestMapping("/agent/auth")
...@@ -15,20 +28,114 @@ public class AgentAuthController { ...@@ -15,20 +28,114 @@ public class AgentAuthController {
@Resource @Resource
private IAgentAuthService iAgentAuthService; private IAgentAuthService iAgentAuthService;
@Resource
private SysUserSyncService sysUserSyncService;
@Resource
private ISysUserSyncCategoryService iSysUserSyncCategoryService;
@PostMapping("/authedList")
public R list(@RequestBody @Validated AgentAuthVO.AuthedList vo) {
Page<CoreModulePermissions> page = iAgentAuthService.page(new Page<>(vo.getCurrent(), vo.getSize()), new LambdaQueryWrapper<CoreModulePermissions>()
.eq(CoreModulePermissions::getTenantId, vo.getTenantId()));
List<CoreModulePermissions> records = page.getRecords();
if (CollUtil.isEmpty(records)) {
return R.ok();
}
List<JSONObject> ret = new ArrayList<>();
Map<String, String> deptMap = new HashMap<>();
Map<String, SysUserSync> userMap = new HashMap<>();
List<String> deptIdList = records.stream().filter(e -> e.getType() == 0).map(CoreModulePermissions::getRelId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(deptIdList)) {
List<SysUserSyncCategory> deptList = iSysUserSyncCategoryService.list(new LambdaQueryWrapper<SysUserSyncCategory>()
.in(SysUserSyncCategory::getDeptId, deptIdList)
);
deptMap = deptList.stream().collect(Collectors.toMap(SysUserSyncCategory::getDeptId, SysUserSyncCategory::getName));
}
List<String> userIdList = records.stream().filter(e -> e.getType() == 1).map(CoreModulePermissions::getRelId).collect(Collectors.toList());
if (CollUtil.isNotEmpty(userIdList)) {
List<SysUserSync> userList = sysUserSyncService.listByUserIds(userIdList);
userMap = userList.stream().collect(Collectors.toMap(SysUserSync::getUserId, e -> e));
}
for (CoreModulePermissions record : records) {
JSONObject object = JSONUtil.parseObj(record);
if (record.getType() == 0) {
if (deptMap.containsKey(record.getRelId())) {
object.putOpt("name", deptMap.get(record.getRelId()));
object.putOpt("deptName", deptMap.get(record.getRelId()));
}
} else if (record.getType() == 1) {
if (userMap.containsKey(record.getRelId())) {
object.putOpt("name", userMap.get(record.getRelId()).getName());
object.putOpt("deptName", userMap.get(record.getRelId()).getDepartment());
}
}
ret.add(object);
}
return R.ok(ret);
}
@PostMapping("/userList")
public R list(@RequestBody @Validated AgentAuthVO.UserList vo) {
List<CoreModulePermissions> list = iAgentAuthService.list(new LambdaQueryWrapper<CoreModulePermissions>()
.eq(CoreModulePermissions::getTenantId, vo.getTenantId()));
Set<String> userIdList = new HashSet<>();
Set<String> deptIdList = new HashSet<>();
if (CollUtil.isNotEmpty(list)) {
deptIdList = list.stream().filter(e -> e.getType() == 0).map(CoreModulePermissions::getRelId).collect(Collectors.toSet());
userIdList = list.stream().filter(e -> e.getType() == 1).map(CoreModulePermissions::getRelId).collect(Collectors.toSet());
}
List<SysUserSyncCategory> categories = new ArrayList<>();
List<SysUserSync> userSyncs = new ArrayList<>();
if (vo.getCategoryId().equals(CategoryConstant.ROOT)) {
categories = iSysUserSyncCategoryService.selectParentIdNoInId(vo.getSearch());
} else {
categories = iSysUserSyncCategoryService.list(new LambdaQueryWrapper<SysUserSyncCategory>()
.eq(SysUserSyncCategory::getParentId, vo.getCategoryId())
.like(StrUtil.isNotBlank(vo.getSearch()), SysUserSyncCategory::getName, vo.getSearch())
.select(SysUserSyncCategory::getDeptId, SysUserSyncCategory::getName)
);
userSyncs = sysUserSyncService.list(new LambdaQueryWrapper<SysUserSync>()
.eq(SysUserSync::getDeptId, vo.getCategoryId())
.like(StrUtil.isNotBlank(vo.getSearch()), SysUserSync::getName, vo.getSearch())
.select(SysUserSync::getUserId, SysUserSync::getName)
);
}
List<JSONObject> cateObjects = new ArrayList<>();
if (CollUtil.isNotEmpty(categories)) {
for (SysUserSyncCategory category : categories) {
JSONObject o = new JSONObject();
o.putOpt("id", category.getDeptId());
o.putOpt("name", category.getName());
o.putOpt("checked", deptIdList.contains(category.getDeptId()));
cateObjects.add(o);
}
}
List<JSONObject> userObjects = new ArrayList<>();
if (CollUtil.isNotEmpty(userSyncs)) {
for (SysUserSync sysUserSync : userSyncs) {
JSONObject o = new JSONObject();
o.putOpt("id", sysUserSync.getUserId());
o.putOpt("name", sysUserSync.getName());
o.putOpt("checked", userIdList.contains(sysUserSync.getUserId()));
userObjects.add(o);
}
}
@GetMapping("/list") JSONObject ret = new JSONObject();
public R list(String tenantId){ ret.putOpt("categoryList", cateObjects);
return R.ok(iAgentAuthService.list(new LambdaQueryWrapper<CoreModulePermissions>() ret.putOpt("userList", userObjects);
.eq(CoreModulePermissions::getTenantId, tenantId))); return R.ok(ret);
} }
@PostMapping("/save") @PostMapping("/save")
public R save(@RequestBody List<CoreModulePermissions> data){ public R save(@RequestBody List<CoreModulePermissions> data) {
return R.ok(iAgentAuthService.saveBatch(data)); return R.ok(iAgentAuthService.saveBatch(data));
} }
@GetMapping("/remove") @GetMapping("/remove")
public R remove(String id){ public R remove(String id) {
return R.ok(iAgentAuthService.removeById(id)); return R.ok(iAgentAuthService.removeById(id));
} }
......
...@@ -76,7 +76,6 @@ public class CmeetingJob { ...@@ -76,7 +76,6 @@ public class CmeetingJob {
} }
try { try {
log.info("-------企微人员定时同步任务开始-------"); log.info("-------企微人员定时同步任务开始-------");
log.info("当前时间: " + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE));
weComService.doUsers(); weComService.doUsers();
log.info("-------企微人员定时同步任务结束--------"); log.info("-------企微人员定时同步任务结束--------");
...@@ -100,7 +99,6 @@ public class CmeetingJob { ...@@ -100,7 +99,6 @@ public class CmeetingJob {
} }
try { try {
log.info("-------腾讯会议人员定时同步任务开始-------"); log.info("-------腾讯会议人员定时同步任务开始-------");
log.info("当前时间: " + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE));
tencentMeetingService.doUsers(); tencentMeetingService.doUsers();
log.info("-------腾讯会议人员定时同步任务结束--------"); log.info("-------腾讯会议人员定时同步任务结束--------");
...@@ -124,7 +122,6 @@ public class CmeetingJob { ...@@ -124,7 +122,6 @@ public class CmeetingJob {
} }
try { try {
log.info("-------关联企微腾会人员定时任务开始-------"); log.info("-------关联企微腾会人员定时任务开始-------");
log.info("当前时间: " + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE));
weComService.userBind(); weComService.userBind();
log.info("-------关联企微腾会人员定时任务结束--------"); log.info("-------关联企微腾会人员定时任务结束--------");
} catch (Exception e) { } catch (Exception e) {
...@@ -145,6 +142,7 @@ public class CmeetingJob { ...@@ -145,6 +142,7 @@ public class CmeetingJob {
if (!redisUtils.setnx("Scheduled-All", "Scheduled-All", 18 * 60)) { if (!redisUtils.setnx("Scheduled-All", "Scheduled-All", 18 * 60)) {
return; return;
} }
log.info("-------生成纪要定时任务开始-------");
try { try {
//查出企微id和腾会id的关联关系 //查出企微id和腾会id的关联关系
List<UserId> userIdRelations = userIdMapper.selectList(null); List<UserId> userIdRelations = userIdMapper.selectList(null);
...@@ -195,7 +193,6 @@ public class CmeetingJob { ...@@ -195,7 +193,6 @@ public class CmeetingJob {
} }
try { try {
log.info("-------生成纪要重试定时任务开始-------"); log.info("-------生成纪要重试定时任务开始-------");
log.info("当前时间: " + LocalDate.now().format(DateTimeFormatter.ISO_LOCAL_DATE));
//查出所有早于一小时前的,生成失败且未重试过的会议 //查出所有早于一小时前的,生成失败且未重试过的会议
// 不能用status筛选,因为可能线程执行一般服务终止,status状态没变 // 不能用status筛选,因为可能线程执行一般服务终止,status状态没变
......
...@@ -2,6 +2,20 @@ package com.cmeeting.mapper.primary; ...@@ -2,6 +2,20 @@ package com.cmeeting.mapper.primary;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cmeeting.pojo.SysUserSyncCategory; import com.cmeeting.pojo.SysUserSyncCategory;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
public interface SysUserSyncCategoryMapper extends BaseMapper<SysUserSyncCategory> { public interface SysUserSyncCategoryMapper extends BaseMapper<SysUserSyncCategory> {
@Select("<script>" +
" SELECT d1.dept_id,d1.name\n" +
" FROM sys_user_sync_category d1\n" +
" LEFT JOIN sys_user_sync_category d2 ON d1.parent_id = d2.dept_id\n" +
" WHERE d2.dept_id IS NULL \n" +
" <if test=\"search != null and search != ''\">\n" +
" and d1.name like concat('%', #{search}, '%')\n" +
" </if>" +
"</script>")
List<SysUserSyncCategory> selectParentIdNoInId(@Param("search") String search);
} }
...@@ -51,4 +51,7 @@ public interface SysUserSyncMapper extends BaseMapper<SysUserSync> { ...@@ -51,4 +51,7 @@ public interface SysUserSyncMapper extends BaseMapper<SysUserSync> {
@MapKey("userId") @MapKey("userId")
List<Map<String, String>> selectParamByUserIdList(@Param("searchValue") String searchValue, List<Map<String, String>> selectParamByUserIdList(@Param("searchValue") String searchValue,
@Param("userIdList") List<String> userIdList); @Param("userIdList") List<String> userIdList);
List<SysUserSync> listByUserIds(@Param("ids") List<String> userIdList);
} }
...@@ -18,4 +18,6 @@ public interface ISysUserSyncCategoryService extends IService<SysUserSyncCategor ...@@ -18,4 +18,6 @@ public interface ISysUserSyncCategoryService extends IService<SysUserSyncCategor
String getPath(String deptId, Map<String, String> map); String getPath(String deptId, Map<String, String> map);
List<Tree<String>> tree(String tenantId); List<Tree<String>> tree(String tenantId);
List<SysUserSyncCategory> selectParentIdNoInId(String search);
} }
...@@ -42,4 +42,6 @@ public interface SysUserSyncService extends IService<SysUserSync> { ...@@ -42,4 +42,6 @@ public interface SysUserSyncService extends IService<SysUserSync> {
List<PermissionCheckedDTO.User> findByParam(List<String> userIds, List<String> notInCateIds, List<String> shareCateIds, String search, String categoryId); List<PermissionCheckedDTO.User> findByParam(List<String> userIds, List<String> notInCateIds, List<String> shareCateIds, String search, String categoryId);
Page<SysUserSyncDTO> selectPage(Integer current, Integer size, String categoryId, String search); Page<SysUserSyncDTO> selectPage(Integer current, Integer size, String categoryId, String search);
List<SysUserSync> listByUserIds(List<String> userIdList);
} }
...@@ -53,4 +53,9 @@ public class SysUserSyncCategoryServiceImpl extends ServiceImpl<SysUserSyncCateg ...@@ -53,4 +53,9 @@ public class SysUserSyncCategoryServiceImpl extends ServiceImpl<SysUserSyncCateg
CategoryTreeUtil<SysUserSyncCategory> util = new CategoryTreeUtil<>(); CategoryTreeUtil<SysUserSyncCategory> util = new CategoryTreeUtil<>();
return util.build(sysUserSyncCategories); return util.build(sysUserSyncCategories);
} }
@Override
public List<SysUserSyncCategory> selectParentIdNoInId(String search) {
return baseMapper.selectParentIdNoInId(search);
}
} }
...@@ -246,6 +246,11 @@ public class SysUserSyncServiceImpl extends ServiceImpl<SysUserSyncMapper, SysUs ...@@ -246,6 +246,11 @@ public class SysUserSyncServiceImpl extends ServiceImpl<SysUserSyncMapper, SysUs
return retPage; return retPage;
} }
@Override
public List<SysUserSync> listByUserIds(List<String> userIdList) {
return baseMapper.listByUserIds(userIdList);
}
private List<String> getChildren(Map<String, List<String>> collect, String deptId) { private List<String> getChildren(Map<String, List<String>> collect, String deptId) {
List<String> ids = new ArrayList<>(); List<String> ids = new ArrayList<>();
if (collect.containsKey(deptId)) { if (collect.containsKey(deptId)) {
......
package com.cmeeting.vo;
import lombok.Data;
@Data
public class AgentAuthVO {
/**
* 已授权用户查询入参
*/
@Data
public static class AuthedList {
private Integer current;
private Integer size;
private String search;
private String tenantId;
}
/**
* 授权用户查询入参
*/
@Data
public static class UserList {
private String categoryId;
private String search;
private String tenantId;
}
}
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
target_id AS targetId, target_id AS targetId,
tenant_id AS tenantId tenant_id AS tenantId
FROM FROM
core_module_permissions core_module_permission
WHERE WHERE
user_type = 2 user_type = 2
and target_id = #{targetId} and target_id = #{targetId}
......
...@@ -157,4 +157,15 @@ ...@@ -157,4 +157,15 @@
</if> </if>
</where> </where>
</select> </select>
<select id="listByUserIds" resultType="com.cmeeting.ad.entity.SysUserSync">
select t1.user_id, t1.name, t2.name as department
from sys_user_sync t1
left join sys_user_sync_category t2 on t1.dept_id = t2.dept_id
<where>
t1.user_id in
<foreach collection="ids" separator="," item="id" close=")" open="(">
#{id}
</foreach>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论