Selaa lähdekoodia

代理商只查看分配给自己的卡

jinxia.mo 1 kuukausi sitten
vanhempi
commit
bfb9670664

BIN
back-ui/public/favicon.ico


BIN
back-ui/src/assets/images/profile.jpg


BIN
back-ui/src/assets/logo/logo.png


+ 1 - 1
back-ui/src/utils/request.js

@@ -93,7 +93,7 @@ service.interceptors.response.use(res => {
         isRelogin.show = false
       })
     }
-      return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
+      return Promise.reject('请重新登录。')
     } else if (code === 500) {
       ElMessage({ message: msg, type: 'error' })
       return Promise.reject(new Error(msg))

+ 6 - 1
back-ui/src/views/dz/cards/config/table.js

@@ -48,7 +48,12 @@ const tableConfig = {
       label: "机构",
       prop: "deptName",
       align: "center",
-
+      width: 120,
+    },
+    {
+      label: "代理商",
+      prop: "agentName",
+      align: "center",
       width: 120,
     },
     {

+ 10 - 1
ie-admin/src/main/java/com/ruoyi/web/controller/dz/DzCardsController.java

@@ -51,9 +51,18 @@ public class DzCardsController extends BaseController
     @ApiOperation("列表")
     public TableDataInfo list(DzCards dzCards)
     {
-        if(null==dzCards.getDeptId()){
+        String userType = SecurityUtils.getLoginUser().getUser().getUserType();
+        if(UserTypeEnum.isInstitution(userType)&&null==dzCards.getDeptId()){
             dzCards.setDeptId(SecurityUtils.getDeptId());
         }
+        if((UserTypeEnum.isAgent(userType)||UserTypeEnum.isTeacher(userType))&&null==dzCards.getAgentId()){
+            //代理商及老师只能查看分配给自己的卡
+            DzAgent agent = agentService.selectDzAgentByUserId(SecurityUtils.getUserId());
+            if (null!=agent){
+                dzCards.setAgentId(agent.getAgentId());
+            }
+        }
+
         startPage();
         List<DzCards> list = dzCardsService.selectDzCardsList(dzCards);
         return getDataTable(list);

+ 5 - 5
ie-admin/src/main/java/com/ruoyi/web/controller/front/UserController.java

@@ -233,11 +233,11 @@ public class UserController extends BaseController {
         if(null == cards || !cards.getPassword().equals(password)) {
             return AjaxResult.error("卡号或密码不正确");
         }
-        if(CardStatus.Free.getVal().equals(cards.getStatus())||CardStatus.Open.getVal().equals(cards.getStatus())) {
-            return AjaxResult.error("卡未分配");
-        }else if(CardStatus.Active.getVal().equals(cards.getStatus())) {
-            return AjaxResult.error("卡已使用");
-        }
+//        if(CardStatus.Free.getVal().equals(cards.getStatus())||CardStatus.Open.getVal().equals(cards.getStatus())) {
+//            return AjaxResult.error("卡未分配");
+//        }else if(CardStatus.Active.getVal().equals(cards.getStatus())) {
+//            return AjaxResult.error("卡已使用");
+//        }
 
         if(!CardStatus.Paid.getVal().equals(cards.getStatus())) {
             return AjaxResult.error("无效卡");

+ 9 - 8
ie-system/src/main/java/com/ruoyi/dz/mapper/DzAgentMapper.java

@@ -7,25 +7,26 @@ import org.apache.ibatis.annotations.Param;
 
 /**
  * 机构代理Mapper接口
- * 
+ *
  * @author ruoyi
  * @date 2025-09-12
  */
-public interface DzAgentMapper 
+public interface DzAgentMapper
 {
     public List<DzAgent> selectDzAgentByAgentIds(@Param("ids")Collection<Long> ids);
 
     /**
      * 查询机构代理
-     * 
+     *
      * @param agentId 机构代理主键
      * @return 机构代理
      */
     public DzAgent selectDzAgentByAgentId(Long agentId);
+    public DzAgent selectDzAgentByUserId(Long userId);
 
     /**
      * 查询机构代理列表
-     * 
+     *
      * @param dzAgent 机构代理
      * @return 机构代理集合
      */
@@ -33,7 +34,7 @@ public interface DzAgentMapper
 
     /**
      * 新增机构代理
-     * 
+     *
      * @param dzAgent 机构代理
      * @return 结果
      */
@@ -41,7 +42,7 @@ public interface DzAgentMapper
 
     /**
      * 修改机构代理
-     * 
+     *
      * @param dzAgent 机构代理
      * @return 结果
      */
@@ -49,7 +50,7 @@ public interface DzAgentMapper
 
     /**
      * 删除机构代理
-     * 
+     *
      * @param agentId 机构代理主键
      * @return 结果
      */
@@ -57,7 +58,7 @@ public interface DzAgentMapper
 
     /**
      * 批量删除机构代理
-     * 
+     *
      * @param agentIds 需要删除的数据主键集合
      * @return 结果
      */

+ 9 - 8
ie-system/src/main/java/com/ruoyi/dz/service/IDzAgentService.java

@@ -5,23 +5,24 @@ import com.ruoyi.dz.domain.DzAgent;
 
 /**
  * 机构代理Service接口
- * 
+ *
  * @author ruoyi
  * @date 2025-09-12
  */
-public interface IDzAgentService 
+public interface IDzAgentService
 {
     /**
      * 查询机构代理
-     * 
+     *
      * @param agentId 机构代理主键
      * @return 机构代理
      */
     public DzAgent selectDzAgentByAgentId(Long agentId);
+    public DzAgent selectDzAgentByUserId(Long userId);
 
     /**
      * 查询机构代理列表
-     * 
+     *
      * @param dzAgent 机构代理
      * @return 机构代理集合
      */
@@ -29,7 +30,7 @@ public interface IDzAgentService
 
     /**
      * 新增机构代理
-     * 
+     *
      * @param dzAgent 机构代理
      * @return 结果
      */
@@ -37,7 +38,7 @@ public interface IDzAgentService
 
     /**
      * 修改机构代理
-     * 
+     *
      * @param dzAgent 机构代理
      * @return 结果
      */
@@ -45,7 +46,7 @@ public interface IDzAgentService
 
     /**
      * 批量删除机构代理
-     * 
+     *
      * @param agentIds 需要删除的机构代理主键集合
      * @return 结果
      */
@@ -53,7 +54,7 @@ public interface IDzAgentService
 
     /**
      * 删除机构代理信息
-     * 
+     *
      * @param agentId 机构代理主键
      * @return 结果
      */

+ 16 - 9
ie-system/src/main/java/com/ruoyi/dz/service/impl/DzAgentServiceImpl.java

@@ -14,12 +14,12 @@ import com.ruoyi.dz.service.IDzAgentService;
 
 /**
  * 机构代理Service业务层处理
- * 
+ *
  * @author ruoyi
  * @date 2025-09-12
  */
 @Service
-public class DzAgentServiceImpl implements IDzAgentService 
+public class DzAgentServiceImpl implements IDzAgentService
 {
     @Autowired
     private DzAgentMapper dzAgentMapper;
@@ -28,7 +28,7 @@ public class DzAgentServiceImpl implements IDzAgentService
 
     /**
      * 查询机构代理
-     * 
+     *
      * @param agentId 机构代理主键
      * @return 机构代理
      */
@@ -38,9 +38,14 @@ public class DzAgentServiceImpl implements IDzAgentService
         return dzAgentMapper.selectDzAgentByAgentId(agentId);
     }
 
+    @Override
+    public DzAgent selectDzAgentByUserId(Long userId) {
+        return dzAgentMapper.selectDzAgentByUserId(userId);
+    }
+
     /**
      * 查询机构代理列表
-     * 
+     *
      * @param dzAgent 机构代理
      * @return 机构代理
      */
@@ -52,21 +57,23 @@ public class DzAgentServiceImpl implements IDzAgentService
 
     /**
      * 新增机构代理
-     * 
+     *
      * @param dzAgent 机构代理
      * @return 结果
      */
     @Override
     public int insertDzAgent(DzAgent dzAgent)
     {
+        Long userId = userService.insertRelateUser(UserTypeEnum.Agent, dzAgent.getAgentId(), dzAgent.getDeptId(), dzAgent.getUsername(), dzAgent.getName());
+
+        dzAgent.setUserId(userId);
         int iRet = dzAgentMapper.insertDzAgent(dzAgent);
-        userService.insertRelateUser(UserTypeEnum.Agent, dzAgent.getAgentId(), dzAgent.getDeptId(), dzAgent.getUsername(), dzAgent.getName());
         return iRet;
     }
 
     /**
      * 修改机构代理
-     * 
+     *
      * @param dzAgent 机构代理
      * @return 结果
      */
@@ -78,7 +85,7 @@ public class DzAgentServiceImpl implements IDzAgentService
 
     /**
      * 批量删除机构代理
-     * 
+     *
      * @param agentIds 需要删除的机构代理主键
      * @return 结果
      */
@@ -90,7 +97,7 @@ public class DzAgentServiceImpl implements IDzAgentService
 
     /**
      * 删除机构代理信息
-     * 
+     *
      * @param agentId 机构代理主键
      * @return 结果
      */

+ 37 - 0
ie-system/src/main/java/com/ruoyi/enums/UserTypeEnum.java

@@ -1,5 +1,6 @@
 package com.ruoyi.enums;
 
+import com.ruoyi.common.utils.StringUtils;
 import lombok.AllArgsConstructor;
 import lombok.Getter;
 
@@ -9,4 +10,40 @@ public enum UserTypeEnum {
     Sys("00"), Card("01"), Agent("10"), Teacher("11"), Institution("12"); // 用户类型(00系统01卡10代理11老师12机构)
 
     private final String val;
+
+    public static Boolean isInstitution(String val){
+        if (StringUtils.isEmpty(val)){
+            return false;
+        }
+        return Institution.val.equalsIgnoreCase(val)||Institution.name().equalsIgnoreCase(val);
+    }
+
+    public static Boolean isTeacher(String val){
+        if (StringUtils.isEmpty(val)){
+            return false;
+        }
+        return Teacher.val.equalsIgnoreCase(val)||Teacher.name().equalsIgnoreCase(val);
+    }
+
+    public static Boolean isAgent(String val){
+        if (StringUtils.isEmpty(val)){
+            return false;
+        }
+        return Agent.val.equalsIgnoreCase(val)||Agent.name().equalsIgnoreCase(val);
+    }
+
+    public static Boolean isCard(String val){
+        if (StringUtils.isEmpty(val)){
+            return false;
+        }
+        return Card.val.equalsIgnoreCase(val)||Card.name().equalsIgnoreCase(val);
+    }
+
+    public static Boolean isSys(String val){
+        if (StringUtils.isEmpty(val)){
+            return false;
+        }
+        return Sys.val.equalsIgnoreCase(val)||Sys.name().equalsIgnoreCase(val);
+    }
+
 }

+ 5 - 0
ie-system/src/main/resources/mapper/dz/DzAgentMapper.xml

@@ -53,6 +53,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where t1.agent_id = #{agentId}
     </select>
 
+    <select id="selectDzAgentByUserId" parameterType="Long" resultMap="DzAgentResult">
+        <include refid="selectDzAgentVo"/>
+        where t1.user_id = #{userId}
+    </select>
+
     <select id="selectDzAgentByAgentIds" resultMap="DzAgentResult">
         <include refid="selectDzAgentVo"/>
         where t1.agent_id in <foreach collection="ids" item="id" open="(" separator="," close=")">#{id}</foreach>

+ 3 - 1
ie-system/src/main/resources/mapper/dz/DzCardsMapper.xml

@@ -57,7 +57,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="deptId != null ">
                 AND (dept_id = #{deptId} OR dept_id IN ( SELECT t.dept_id FROM sys_dept t WHERE find_in_set(#{deptId}, ancestors) ))
             </if>
-            <if test="agentId != null "> and agent_id = #{agentId}</if>
+            <if test="agentId != null ">
+                AND (agent_id = #{agentId} OR agent_id IN ( SELECT t.agent_id FROM dz_agent t WHERE t.agent_id=#{agentId} ))
+            </if>
             <if test="leafAgentId != null "> and leaf_agent_id = #{leafAgentId}</if>
             <if test="campusId != null "> and campus_id = #{campusId}</if>
             <if test="assignLocation != null "> and assign_location = #{assignLocation}</if>