Kaynağa Gözat

Merge remote-tracking branch 'origin/Payment-Configuration' into Payment-Configuration

yys 1 ay önce
ebeveyn
işleme
2c34d1e18b

+ 50 - 0
fs-admin/src/main/java/com/fs/app/task/AppTask.java

@@ -0,0 +1,50 @@
+package com.fs.app.task;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.fs.common.utils.DateUtils;
+import com.fs.gtPush.domain.UniPushLog;
+import com.fs.gtPush.mapper.PushLogMapper;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.Date;
+
+/**
+ * @description: App定时任务
+ * @author: Xgb
+ * @createDate: 2026/5/13
+ * @version: 1.0
+ */
+@Component("appTask")
+@Slf4j
+public class AppTask {
+
+    @Autowired
+    private PushLogMapper pushLogMapper;
+
+    @Scheduled(cron = "0 0 2 * * ?")
+    public void deleteUniPushLog() {
+        Date expireDate = DateUtils.addDays(new Date(), -30);
+        int batchSize = 1000;
+        int totalDelete = 0;
+        int deleted;
+        do {
+            LambdaQueryWrapper<UniPushLog> wrapper = new LambdaQueryWrapper<>();
+            wrapper.lt(UniPushLog::getCreateTime, expireDate);
+            wrapper.last("LIMIT " + batchSize);
+            deleted = pushLogMapper.delete(wrapper);
+            totalDelete += deleted;
+            if (deleted > 0) {
+                try {
+                    Thread.sleep(200);
+                } catch (InterruptedException e) {
+                    Thread.currentThread().interrupt();
+                    break;
+                }
+            }
+        } while (deleted == batchSize);
+        log.info("定时删除uni_push_log记录,保留最近30天数据,共删除 {} 条", totalDelete);
+    }
+}

+ 13 - 0
fs-company-app/src/main/java/com/fs/app/controller/CompanyUserController.java

@@ -20,6 +20,7 @@ import com.fs.common.utils.bean.BeanUtils;
 import com.fs.company.domain.*;
 import com.fs.company.mapper.CompanyRoleMapper;
 import com.fs.company.mapper.CompanyUserMapper;
+import com.fs.company.mapper.CompanyUserRoleMapper;
 import com.fs.company.param.companyUserAddPrintParam;
 import com.fs.company.service.*;
 import com.fs.company.vo.CompanyTagUserVO;
@@ -90,6 +91,7 @@ public class CompanyUserController extends AppBaseController {
     private final IFsUserCompanyUserService fsUserCompanyUserService;
     private final ICompanyTagUserService companyTagUserService;
     private final FastgptChatVoiceHomoMapper fastgptChatVoiceHomoMapper;
+    private final CompanyUserRoleMapper companyUserRoleMapper;
     public static final String SOP_TEMP_VOICE_KEY = "sop:tempVoice";
 
     @Login
@@ -245,6 +247,17 @@ public class CompanyUserController extends AppBaseController {
         }
 
         companyUserService.insertUser(companyUser);
+
+        // 查询公司是否存在默认角色,如果存在则自动绑定
+        // 查询公司是否存在默认角色
+        CompanyRole defaultRole = companyRoleMapper.selectDefaultRoleByCompanyId(company.getCompanyId());
+        if (Objects.nonNull(defaultRole)) {
+            CompanyUserRole companyUserRole = new CompanyUserRole();
+            companyUserRole.setUserId(companyUser.getUserId());
+            companyUserRole.setRoleId(defaultRole.getRoleId());
+            companyUserRoleMapper.insertCompanyUserRole(companyUserRole);
+        }
+
         return R.ok();
     }
 

+ 12 - 0
fs-service/src/main/java/com/fs/company/domain/CompanyRole.java

@@ -44,6 +44,9 @@ public class CompanyRole extends BaseEntity
     /** 角色状态(0正常 1停用) */
     private String status;
 
+    /** 是否默认角色(0否 1是) */
+    private String defaultRole;
+
     /** 删除标志(0代表存在 2代表删除) */
     private String delFlag;
 
@@ -137,6 +140,15 @@ public class CompanyRole extends BaseEntity
     {
         return status;
     }
+
+    public String getDefaultRole() {
+        return defaultRole;
+    }
+
+    public void setDefaultRole(String defaultRole) {
+        this.defaultRole = defaultRole;
+    }
+
     public void setDelFlag(String delFlag)
     {
         this.delFlag = delFlag;

+ 7 - 0
fs-service/src/main/java/com/fs/company/mapper/CompanyRoleMapper.java

@@ -85,4 +85,11 @@ public interface CompanyRoleMapper
      * **/
     CompanyRole selectCompanyRoleByRoleKey(@Param("roleKey") String roleKey);
     Long selectRolesByUserNameAndCompanyId(@Param("roleName") String roleName,@Param("companyId") Long companyId);
+
+    /**
+     * 根据公司ID查询默认角色
+     * @param companyId 公司ID
+     * @return 默认角色
+     */
+    CompanyRole selectDefaultRoleByCompanyId(@Param("companyId") Long companyId);
 }

+ 1 - 0
fs-service/src/main/java/com/fs/im/service/impl/OpenIMServiceImpl.java

@@ -1548,6 +1548,7 @@ public class OpenIMServiceImpl implements OpenIMService {
             planSendTimeStamp = batchSendCourseDTO.getSendTime().getTime();
         } else {
             planSendTimeStamp = System.currentTimeMillis();
+            batchSendCourseDTO.setSendTime(new Date(planSendTimeStamp));
         }
 
         String courseUrl = fsUserCourse != null ? fsUserCourse.getImgUrl() : null;

+ 11 - 1
fs-service/src/main/resources/mapper/company/CompanyRoleMapper.xml

@@ -14,6 +14,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="menuCheckStrictly"    column="menu_check_strictly"    />
         <result property="deptCheckStrictly"    column="dept_check_strictly"    />
         <result property="status"    column="status"    />
+        <result property="defaultRole"    column="default_role"    />
         <result property="delFlag"    column="del_flag"    />
         <result property="createBy"    column="create_by"    />
         <result property="createTime"    column="create_time"    />
@@ -23,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectCompanyRoleVo">
-        select role_id, company_id, role_name, role_key, role_sort, data_scope, menu_check_strictly, dept_check_strictly, status, del_flag, create_by, create_time, update_by, update_time, remark from company_role
+        select role_id, company_id, role_name, role_key, role_sort, data_scope, menu_check_strictly, dept_check_strictly, status, default_role, del_flag, create_by, create_time, update_by, update_time, remark from company_role
     </sql>
 
     <select id="selectCompanyRoleList" parameterType="CompanyRole" resultMap="CompanyRoleResult">
@@ -56,6 +57,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="menuCheckStrictly != null">menu_check_strictly,</if>
             <if test="deptCheckStrictly != null">dept_check_strictly,</if>
             <if test="status != null and status != ''">status,</if>
+            <if test="defaultRole != null and defaultRole != ''">default_role,</if>
             <if test="delFlag != null">del_flag,</if>
             <if test="createBy != null">create_by,</if>
             <if test="createTime != null">create_time,</if>
@@ -72,6 +74,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="menuCheckStrictly != null">#{menuCheckStrictly},</if>
             <if test="deptCheckStrictly != null">#{deptCheckStrictly},</if>
             <if test="status != null and status != ''">#{status},</if>
+            <if test="defaultRole != null and defaultRole != ''">#{defaultRole},</if>
             <if test="delFlag != null">#{delFlag},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="createTime != null">#{createTime},</if>
@@ -92,6 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="menuCheckStrictly != null">menu_check_strictly = #{menuCheckStrictly},</if>
             <if test="deptCheckStrictly != null">dept_check_strictly = #{deptCheckStrictly},</if>
             <if test="status != null and status != ''">status = #{status},</if>
+            <if test="defaultRole != null and defaultRole != ''">default_role = #{defaultRole},</if>
             <if test="delFlag != null">del_flag = #{delFlag},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
@@ -186,4 +190,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select role_id from company_role where  del_flag = '0' and status = '0' and  role_name= #{roleName}  and company_id = #{companyId}
     </select>
 
+    <select id="selectDefaultRoleByCompanyId" resultType="com.fs.company.domain.CompanyRole">
+        select * from company_role 
+        where del_flag = '0' and status = '0' and default_role = '1' and company_id = #{companyId}
+        limit 1
+    </select>
+
 </mapper>