From 58673ca240945a1d3719b4429119570817944b40 Mon Sep 17 00:00:00 2001
From: LSH
Date: 星期四, 09 十一月 2023 16:52:12 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/crm/manager/controller/PriOnline2Controller.java        |   38 +++++++++
 src/main/java/com/zy/crm/manager/service/impl/PriOnline2ServiceImpl.java     |   11 ++
 src/main/webapp/views/priOnline2/priOnline.html                              |    5 +
 src/main/java/com/zy/crm/manager/service/impl/PriOnline2FollServiceImpl.java |   12 +++
 src/main/java/com/zy/crm/manager/mapper/PriOnline2FollMapper.java            |   12 +++
 src/main/resources/mapper/PriOnline2FollMapper.xml                           |   13 +++
 src/main/java/com/zy/crm/manager/mapper/PriOnline2Mapper.java                |    2 
 src/main/java/com/zy/crm/manager/entity/PriOnline2Foll.java                  |   75 ++++++++++++++++++
 src/main/resources/mapper/PriOnline2Mapper.xml                               |   32 ++++++++
 src/main/webapp/static/js/priOnline2/priOnline.js                            |    5 
 src/main/java/com/zy/crm/manager/service/PriOnline2FollService.java          |    8 ++
 src/main/java/com/zy/crm/manager/service/PriOnline2Service.java              |    3 
 12 files changed, 212 insertions(+), 4 deletions(-)

diff --git a/src/main/java/com/zy/crm/manager/controller/PriOnline2Controller.java b/src/main/java/com/zy/crm/manager/controller/PriOnline2Controller.java
index ddc1a0a..84ae90d 100644
--- a/src/main/java/com/zy/crm/manager/controller/PriOnline2Controller.java
+++ b/src/main/java/com/zy/crm/manager/controller/PriOnline2Controller.java
@@ -57,6 +57,9 @@
     @Autowired
     private UserService userService;
 
+    @Autowired
+    private PriOnline2FollService priOnline2FollService;
+
     String PZH = " 鈥斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�斺�� ";
 
     @RequestMapping(value = "/priOnline2/{id}/auth")
@@ -86,12 +89,22 @@
                   @RequestParam(defaultValue = "10") Integer limit,
                   @RequestParam(required = false) String orderByField,
                   @RequestParam(required = false) String orderByType,
+                  @RequestParam(required = false) String allSwitch,
                   @RequestParam(required = false) String condition,
-                  @RequestParam Map<String, Object> param) {
+                  @RequestParam Map<String, Object> paramSou) {
         EntityWrapper<PriOnline2> wrapper = new EntityWrapper<>();
         wrapper.setSqlSelect("id,title,create_time as createTime,assistant_plan_id as assistantPlanId,host_plan_id as hostPlanId,assistant_host_sign as assistantHostSign,filepath,settle,settle_size as settleSize,item_id as itemId,order_num as orderNum,template_name as templateName,user_id as userId,dept_id as deptId,status,update_time as updateTime,check_data as checkData,update_user_id as updateUserId,member_id as memberId");
 //        wrapper.in("member_id", getUserRoleBelongsToUserId("allopen"));
-        excludeTrash(param);
+        excludeTrash(paramSou);
+        Map<String, Object> param = convertallSwitch(paramSou);
+
+        if (!Cools.isEmpty(allSwitch)){
+            List<PriOnline2> priOnline2List = priOnline2Service.listByAll(getUserId());
+            Page<PriOnline2> page1 = new Page<PriOnline2>(curr, limit).setRecords(priOnline2List);
+            page1.setTotal(priOnline2Service.listByAllTotal(getUserId()));
+            return R.ok(page1);
+        }
+
         convert(param, wrapper);
         allLike(PriOnline2.class, param.keySet(), wrapper, condition);
         wrapper.or().eq("member_id", getUserId());
@@ -101,6 +114,14 @@
         return R.ok(priOnline2Service.selectPage(new Page<>(curr, limit), wrapper));
     }
 
+    private Map<String, Object>  convertallSwitch(Map<String, Object> map) {
+        for (Map.Entry<String, Object> entry : map.entrySet()) {
+            if (entry.getKey().equals("allSwitch")) {
+                map.remove("allSwitch");
+            }
+        }
+        return map;
+    }
     private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper) {
         boolean signUserId = false;
         boolean signDeptId = false;
@@ -284,6 +305,19 @@
 
         priOnline2Service.insert(priOnline2);
 
+        // 鑷姩娣诲姞璺熻繘浜�
+        for (User user:users){
+            List<PriOnline2Foll> priOnline2Folls = priOnline2FollService.selectList(new EntityWrapper<PriOnline2Foll>().eq("pri_online2_id", plan.getId()).eq("user_id", user.getId()));
+            if (Cools.isEmpty(priOnline2Folls) || priOnline2Folls.size()==0){
+                PriOnline2Foll priOnline2Foll = new PriOnline2Foll();
+                priOnline2Foll.setPriOnline2Id(plan.getId());
+                priOnline2Foll.setUserId(user.getId());
+                if (!priOnline2FollService.insert(priOnline2Foll)) {
+                    throw new CoolException("淇濆瓨澶辫触锛岃閲嶈瘯");
+                }
+            }
+        }
+
 
         if (plan.getAssistantHostSign()==1){
             Plan plan1 = planService.selectById(plan.getHostPlanId());
diff --git a/src/main/java/com/zy/crm/manager/entity/PriOnline2Foll.java b/src/main/java/com/zy/crm/manager/entity/PriOnline2Foll.java
new file mode 100644
index 0000000..eadc8b9
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/entity/PriOnline2Foll.java
@@ -0,0 +1,75 @@
+package com.zy.crm.manager.entity;
+
+import com.baomidou.mybatisplus.annotations.TableField;
+import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.annotations.TableName;
+import com.baomidou.mybatisplus.enums.IdType;
+import com.core.common.Cools;
+import com.core.common.SpringUtils;
+import com.zy.crm.manager.service.PriOnline2Service;
+import com.zy.crm.system.entity.User;
+import com.zy.crm.system.service.UserService;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+@TableName("man_pri_online2_foll")
+public class PriOnline2Foll implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    @ApiModelProperty(value= "ID")
+    @TableId(value = "id", type = IdType.AUTO)
+    private Long id;
+
+    /**
+     * 瑙勫垝鍗�
+     */
+    @ApiModelProperty(value= "瑙勫垝鍗�")
+    @TableField("pri_online2_id")
+    private Long priOnline2Id;
+
+    /**
+     * 璺熻繘浜�
+     */
+    @ApiModelProperty(value= "璺熻繘浜�")
+    @TableField("user_id")
+    private Long userId;
+
+    public PriOnline2Foll() {}
+
+    public PriOnline2Foll(Long priOnline2Id, Long userId) {
+        this.priOnline2Id = priOnline2Id;
+        this.userId = userId;
+    }
+
+//    PlanFoll planFoll = new PlanFoll(
+//            null,    // 瑙勫垝鍗�
+//            null    // 璺熻繘浜篬闈炵┖]
+//    );
+
+    public String getPriOnline2Id$(){
+        PriOnline2Service service = SpringUtils.getBean(PriOnline2Service.class);
+        PriOnline2 priOnline2 = service.selectById(this.priOnline2Id);
+        if (!Cools.isEmpty(priOnline2)){
+            return String.valueOf(priOnline2.getTemplateName());
+        }
+        return null;
+    }
+
+    public String getUserId$(){
+        UserService service = SpringUtils.getBean(UserService.class);
+        User user = service.selectById(this.userId);
+        if (!Cools.isEmpty(user)){
+            return String.valueOf(user.getNickname());
+        }
+        return null;
+    }
+
+
+}
diff --git a/src/main/java/com/zy/crm/manager/mapper/PriOnline2FollMapper.java b/src/main/java/com/zy/crm/manager/mapper/PriOnline2FollMapper.java
new file mode 100644
index 0000000..bc0e0aa
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/mapper/PriOnline2FollMapper.java
@@ -0,0 +1,12 @@
+package com.zy.crm.manager.mapper;
+
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import com.zy.crm.manager.entity.PriOnline2Foll;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface PriOnline2FollMapper extends BaseMapper<PriOnline2Foll> {
+
+}
diff --git a/src/main/java/com/zy/crm/manager/mapper/PriOnline2Mapper.java b/src/main/java/com/zy/crm/manager/mapper/PriOnline2Mapper.java
index 13c70af..6749dbf 100644
--- a/src/main/java/com/zy/crm/manager/mapper/PriOnline2Mapper.java
+++ b/src/main/java/com/zy/crm/manager/mapper/PriOnline2Mapper.java
@@ -15,5 +15,7 @@
 public interface PriOnline2Mapper extends BaseMapper<PriOnline2> {
 
     List<PriOnline2> listByPage(Page<PriOnline2> page, @Param("userIds") ArrayList<Long> userIds , @Param("condition") String condition);
+    List<PriOnline2> listByAll( @Param("userId") Long userId );
+    Integer listByAllTotal( @Param("userId") Long userId );
 
 }
diff --git a/src/main/java/com/zy/crm/manager/service/PriOnline2FollService.java b/src/main/java/com/zy/crm/manager/service/PriOnline2FollService.java
new file mode 100644
index 0000000..99fa2d7
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/service/PriOnline2FollService.java
@@ -0,0 +1,8 @@
+package com.zy.crm.manager.service;
+
+import com.baomidou.mybatisplus.service.IService;
+import com.zy.crm.manager.entity.PriOnline2Foll;
+
+public interface PriOnline2FollService extends IService<PriOnline2Foll> {
+
+}
diff --git a/src/main/java/com/zy/crm/manager/service/PriOnline2Service.java b/src/main/java/com/zy/crm/manager/service/PriOnline2Service.java
index 86ba431..f2e9126 100644
--- a/src/main/java/com/zy/crm/manager/service/PriOnline2Service.java
+++ b/src/main/java/com/zy/crm/manager/service/PriOnline2Service.java
@@ -5,9 +5,12 @@
 import com.zy.crm.manager.entity.PriOnline2;
 
 import java.util.ArrayList;
+import java.util.List;
 
 public interface PriOnline2Service extends IService<PriOnline2> {
 
     Page<PriOnline2> listByPage(Page<PriOnline2> page, ArrayList<Long> userIds , String condition);
+    List<PriOnline2> listByAll(Long userId);
+    Integer listByAllTotal(Long userId);
 
 }
diff --git a/src/main/java/com/zy/crm/manager/service/impl/PriOnline2FollServiceImpl.java b/src/main/java/com/zy/crm/manager/service/impl/PriOnline2FollServiceImpl.java
new file mode 100644
index 0000000..ba1bdeb
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/service/impl/PriOnline2FollServiceImpl.java
@@ -0,0 +1,12 @@
+package com.zy.crm.manager.service.impl;
+
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import com.zy.crm.manager.entity.PriOnline2Foll;
+import com.zy.crm.manager.mapper.PriOnline2FollMapper;
+import com.zy.crm.manager.service.PriOnline2FollService;
+import org.springframework.stereotype.Service;
+
+@Service("priOnline2FollService")
+public class PriOnline2FollServiceImpl extends ServiceImpl<PriOnline2FollMapper, PriOnline2Foll> implements PriOnline2FollService {
+
+}
diff --git a/src/main/java/com/zy/crm/manager/service/impl/PriOnline2ServiceImpl.java b/src/main/java/com/zy/crm/manager/service/impl/PriOnline2ServiceImpl.java
index c1bf5d8..b9e4276 100644
--- a/src/main/java/com/zy/crm/manager/service/impl/PriOnline2ServiceImpl.java
+++ b/src/main/java/com/zy/crm/manager/service/impl/PriOnline2ServiceImpl.java
@@ -8,6 +8,7 @@
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.List;
 
 @Service("priOnline2Service")
 public class PriOnline2ServiceImpl extends ServiceImpl<PriOnline2Mapper, PriOnline2> implements PriOnline2Service {
@@ -16,4 +17,14 @@
     public Page<PriOnline2> listByPage(Page<PriOnline2> page, ArrayList<Long> userIds, String condition) {
         return page.setRecords(this.baseMapper.listByPage(page, userIds, condition));
     }
+
+    @Override
+    public List<PriOnline2> listByAll(Long userId) {
+        return this.baseMapper.listByAll(userId);
+    }
+
+    @Override
+    public Integer listByAllTotal(Long userId) {
+        return this.baseMapper.listByAllTotal(userId);
+    }
 }
diff --git a/src/main/resources/mapper/PriOnline2FollMapper.xml b/src/main/resources/mapper/PriOnline2FollMapper.xml
new file mode 100644
index 0000000..8bf3b61
--- /dev/null
+++ b/src/main/resources/mapper/PriOnline2FollMapper.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zy.crm.manager.mapper.PriOnline2FollMapper">
+
+    <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
+    <resultMap id="BaseResultMap" type="com.zy.crm.manager.entity.PriOnline2Foll">
+        <id column="id" property="id" />
+        <result column="pri_online2_id" property="priOnline2Id" />
+        <result column="user_id" property="userId" />
+
+    </resultMap>
+
+</mapper>
diff --git a/src/main/resources/mapper/PriOnline2Mapper.xml b/src/main/resources/mapper/PriOnline2Mapper.xml
index 6a1cc3d..dee724a 100644
--- a/src/main/resources/mapper/PriOnline2Mapper.xml
+++ b/src/main/resources/mapper/PriOnline2Mapper.xml
@@ -75,4 +75,36 @@
         ORDER BY id DESC
     </select>
 
+    <select id="listByAll" resultMap="NoDataResultMap">
+        SELECT
+        *
+        FROM man_pri_online2 mp
+        WHERE 1=1
+        and
+            mp.id in
+            (
+            select
+            pri_online2_id
+            from man_pri_online2_foll
+            where 1=1
+            and user_id = #{userId}
+            )
+        ORDER BY id DESC
+    </select>
+
+    <select id="listByAllTotal" resultType="java.lang.Integer">
+        SELECT
+        count (1)
+        FROM man_pri_online2 mp
+        WHERE 1=1
+        and
+            mp.id in
+            (
+            select
+            pri_online2_id
+            from man_pri_online2_foll
+            where 1=1
+            and user_id = #{userId}
+            )
+    </select>
 </mapper>
diff --git a/src/main/webapp/static/js/priOnline2/priOnline.js b/src/main/webapp/static/js/priOnline2/priOnline.js
index ce892f9..0a90cb0 100644
--- a/src/main/webapp/static/js/priOnline2/priOnline.js
+++ b/src/main/webapp/static/js/priOnline2/priOnline.js
@@ -29,13 +29,14 @@
 
     // 鏍戝舰鍥�
     var organizationTree;
-    window.loadTree = function (condition) {
+    window.loadTree = function (condition,allSwitch) {
         var loadIndex = layer.load(2);
         $.ajax({
             url: baseUrl + "/dept/user/tree/auth",
             headers: {'token': localStorage.getItem('token')},
             data: {
-                'condition': condition
+                'condition': condition,
+                'allSwitch': allSwitch
             },
             method: 'POST',
             success: function (res) {
diff --git a/src/main/webapp/views/priOnline2/priOnline.html b/src/main/webapp/views/priOnline2/priOnline.html
index c79b53c..5f0b8b2 100644
--- a/src/main/webapp/views/priOnline2/priOnline.html
+++ b/src/main/webapp/views/priOnline2/priOnline.html
@@ -45,11 +45,16 @@
                     </div>
                 </div>
                 <div class="layui-form-item">
+
                     <div class="layui-inline">
                         <div class="layui-input-inline">
                             <input class="layui-input" type="text" name="condition" placeholder="璇疯緭鍏�" autocomplete="off"
                                    style="border-color: #e1e1e1">
                         </div>
+                        <label class="layui-form-label">ALL锛�</label>
+                        <div class="layui-input-inline" style="text-align: left">
+                            <input id="allSwitch" name="allSwitch" class="layui-input" type="checkBox" lay-skin="primary" lay-filter='detailCheckbox'>
+                        </div>
                     </div>
                     <div class="layui-inline">&emsp;
                         <button class="layui-btn icon-btn layui-btn-sm" lay-filter="search" lay-submit>

--
Gitblit v1.9.1