From a5827bbd6a857bd6b5f49b5d0ceade1703332957 Mon Sep 17 00:00:00 2001
From: weicd <weicd@yhzhg.cn>
Date: Mon, 06 Feb 2023 07:09:18 +0000
Subject: [PATCH] 客户资源管理
---
eladmin-web-master/src/views/system/customerResources/index.vue | 275 ++++++++++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/CustomerResources.java | 85 +++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/CustomerResourcesUserController.java | 87 +++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesUserQueryCriteria.java | 29 +
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/CustomerResourcesController.java | 103 +++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ResourceReminderMethod.java | 67 ++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesUserDto.java | 41 +
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesQueryCriteria.java | 37 +
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java | 216 ++++++++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/CustomerResourcesUserService.java | 83 +++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesDto.java | 52 ++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesUserServiceImpl.java | 109 ++++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/CustomerResourcesUserMapper.java | 32 +
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java | 7
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/CustomerResourcesUserRepository.java | 42 +
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/CustomerResourcesRepository.java | 28 +
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/CustomerResourcesService.java | 91 +++
eladmin-web-master/src/api/system/customerResources.js | 43 +
eladmin-web-master/src/utils/constant.js | 12
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/OpaiDingTalkServiceImpl.java | 2
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/CustomerResourcesMapper.java | 32 +
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/CustomerResourcesUser.java | 60 ++
22 files changed, 1,531 insertions(+), 2 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
index 3b58366..5444e0c 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
@@ -222,4 +222,11 @@
// key iv
public static final String key = "1234567890123456";
public static final String iv = "1234567890123456";
+
+ // 提醒状态
+ public static final String RESOURCES_TYPE = "resources_type";
+ // 提醒状态:提醒
+ public static final String RESOURCES_TYPE_REMIND = "resources_type_remind";
+ // 提醒状态:不提醒
+ public static final String RESOURCES_TYPE_NOREMIND = "resources_type_noRemind";
}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/OpaiDingTalkServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/OpaiDingTalkServiceImpl.java
index 8bd1d83..5ad964c 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/OpaiDingTalkServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/OpaiDingTalkServiceImpl.java
@@ -115,7 +115,7 @@
msg.getActionCard().setTitle(title);
msg.getActionCard().setMarkdown(content);
msg.getActionCard().setSingleTitle("详情");
- msg.getActionCard().setSingleUrl("http://pms.yhzhg.cn/");
+ msg.getActionCard().setSingleUrl("http://pms-upgrade.yhzhg.cn/");
msg.setMsgtype("action_card");
}
request.setMsg(msg);
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ResourceReminderMethod.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ResourceReminderMethod.java
new file mode 100644
index 0000000..ac20ed4
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ResourceReminderMethod.java
@@ -0,0 +1,67 @@
+package me.zhengjie.modules.quartz.task;
+
+import cn.hutool.core.util.ObjectUtil;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import me.zhengjie.modules.constant.Constant;
+import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
+import me.zhengjie.modules.system.domain.*;
+import me.zhengjie.modules.system.repository.*;
+import org.springframework.stereotype.Service;
+
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.time.Instant;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 客户资源管理提醒(延时)
+ * @author 魏传栋
+ * @date 2023-01-10
+ */
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class ResourceReminderMethod {
+
+ private final UserRepository userRepository;
+ private final OpaiDingTalkService opaiDingTalkService;
+ private final CustomerResourcesRepository customerResourcesRepository;
+ private final CustomerResourcesUserRepository customerResourcesUserRepository;
+
+ /**
+ * 客户资源管理提醒
+ * @throws Exception
+ */
+ public void resourceReminder() throws Exception {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ // 当前时间
+ String nowTime = sdf.format(new Date());
+ // 查询客户资源管理表
+ List<CustomerResources> customerResourcesList = customerResourcesRepository.findAll();
+ for(CustomerResources customerResources : customerResourcesList){
+ // 表中的提醒时间与当前的时间一致,发送钉钉消息
+ if(customerResources.getOpeningTime() != null && customerResources.getOpeningTime().compareTo(Timestamp.valueOf(nowTime)) == 0){
+ // 钉钉List
+ List<String> dingDingList = new ArrayList<>();
+ // 查询中间表
+ List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(customerResources.getId());
+ for(int i = 0; i < customerResourcesUserList.size(); i++){
+ // 查询用户
+ User user = userRepository.findById(customerResourcesUserList.get(i).getUserId()).orElseGet(User::new);
+ dingDingList.add(user.getDingding());
+ }
+ // 发送信息至被提醒人钉钉
+ opaiDingTalkService.sendNotice(dingDingList, "客户资源管理提示", "### 客户资源管理提示 \n >" +
+ " \n 标题:" + customerResources.getTitle() +
+ " \n 分类: " + customerResources.getClassification() +
+ " \n 新增客户资源,请登录PMS系统查看。", "card");
+ }
+ }
+ }
+}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/CustomerResources.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/CustomerResources.java
new file mode 100644
index 0000000..f4b7956
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/CustomerResources.java
@@ -0,0 +1,85 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.domain;
+
+import lombok.Data;
+import cn.hutool.core.bean.BeanUtil;
+import io.swagger.annotations.ApiModelProperty;
+import cn.hutool.core.bean.copier.CopyOptions;
+import me.zhengjie.base.BaseEntity;
+
+import javax.persistence.*;
+import javax.validation.constraints.*;
+import java.sql.Timestamp;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+* @website https://eladmin.vip
+* @description /
+* @author wcd
+* @date 2023-02-02
+**/
+@Entity
+@Data
+@Table(name="customer_resources")
+public class CustomerResources extends BaseEntity implements Serializable {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "`id`")
+ @ApiModelProperty(value = "id")
+ private Long id;
+
+ @Column(name = "`title`",nullable = false)
+ @NotBlank
+ @ApiModelProperty(value = "标题")
+ private String title;
+
+ @Column(name = "`classification`",nullable = false)
+ @NotBlank
+ @ApiModelProperty(value = "分类")
+ private String classification;
+
+ @Column(name = "`record_time`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "记录时间")
+ private Timestamp recordTime;
+
+ @Column(name = "`record_content`")
+ @ApiModelProperty(value = "记录内容")
+ private String recordContent;
+
+ @Column(name = "`opening_time`")
+ @ApiModelProperty(value = "开启提醒(提醒时间)")
+ private Timestamp openingTime;
+
+ @Column(name = "`remarks`")
+ @ApiModelProperty(value = "备注")
+ private String remarks;
+
+ @Transient
+ @ApiModelProperty(value = "提醒人")
+ private List<Long> remindPeople;
+
+ @Transient
+ @ApiModelProperty(value = "提醒状态")
+ private String remind;
+
+ public void copy(CustomerResources source){
+ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
+ }
+}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/CustomerResourcesUser.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/CustomerResourcesUser.java
new file mode 100644
index 0000000..bd4ed52
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/CustomerResourcesUser.java
@@ -0,0 +1,60 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.domain;
+
+import lombok.Data;
+import cn.hutool.core.bean.BeanUtil;
+import io.swagger.annotations.ApiModelProperty;
+import cn.hutool.core.bean.copier.CopyOptions;
+import me.zhengjie.base.BaseEntity;
+
+import javax.persistence.*;
+import javax.validation.constraints.*;
+import java.sql.Timestamp;
+import java.io.Serializable;
+
+/**
+* @website https://eladmin.vip
+* @description /
+* @author wcd
+* @date 2023-02-03
+**/
+@Entity
+@Data
+@Table(name="customer_resources_user")
+public class CustomerResourcesUser extends BaseEntity implements Serializable {
+
+ @Id
+ @GeneratedValue(strategy = GenerationType.IDENTITY)
+ @Column(name = "`id`")
+ @ApiModelProperty(value = "id")
+ private Long id;
+
+ @Column(name = "`customer_resources_id`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "客户资源 id")
+ private Long customerResourcesId;
+
+ @Column(name = "`user_id`",nullable = false)
+ @NotNull
+ @ApiModelProperty(value = "用户 id")
+ private Long userId;
+
+
+ public void copy(CustomerResourcesUser source){
+ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
+ }
+}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/CustomerResourcesRepository.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/CustomerResourcesRepository.java
new file mode 100644
index 0000000..ebc706c
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/CustomerResourcesRepository.java
@@ -0,0 +1,28 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.repository;
+
+import me.zhengjie.modules.system.domain.CustomerResources;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2023-02-02
+**/
+public interface CustomerResourcesRepository extends JpaRepository<CustomerResources, Long>, JpaSpecificationExecutor<CustomerResources> {
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/CustomerResourcesUserRepository.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/CustomerResourcesUserRepository.java
new file mode 100644
index 0000000..35f7160
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/CustomerResourcesUserRepository.java
@@ -0,0 +1,42 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.repository;
+
+import me.zhengjie.modules.system.domain.CustomerResourcesUser;
+import me.zhengjie.modules.system.domain.SysConfigProportion;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.jpa.repository.Modifying;
+import org.springframework.data.jpa.repository.Query;
+
+import java.util.List;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2023-02-03
+**/
+public interface CustomerResourcesUserRepository extends JpaRepository<CustomerResourcesUser, Long>, JpaSpecificationExecutor<CustomerResourcesUser> {
+
+ //根据客户资源id查询中间表
+ @Query
+ List<CustomerResourcesUser> findByCustomerResourcesId(Long cuId);
+
+ // 根据用户资源id删除中间表数据
+ @Modifying
+ @Query(value = "delete from customer_resources_user where customer_resources_id = ?1",nativeQuery = true)
+ void deleteByCustomerResourcesId(Long custId);
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/CustomerResourcesController.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/CustomerResourcesController.java
new file mode 100644
index 0000000..afc4dc7
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/CustomerResourcesController.java
@@ -0,0 +1,103 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.rest;
+
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.system.domain.CustomerResources;
+import me.zhengjie.modules.system.service.CustomerResourcesService;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2023-02-02
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "客户资源管理管理")
+@RequestMapping("/api/customerResources")
+public class CustomerResourcesController {
+
+ private final CustomerResourcesService customerResourcesService;
+
+ @Log("导出数据")
+ @ApiOperation("导出数据")
+ @GetMapping(value = "/download")
+ @PreAuthorize("@el.check('customerResources:download')")
+ public void exportCustomerResources(HttpServletResponse response, CustomerResourcesQueryCriteria criteria) throws IOException {
+ customerResourcesService.download(customerResourcesService.queryAll(criteria), response);
+ }
+
+ @GetMapping
+ @Log("查询客户资源管理")
+ @ApiOperation("查询客户资源管理")
+ @PreAuthorize("@el.check('customerResources:list')")
+ public ResponseEntity<Object> queryCustomerResources(CustomerResourcesQueryCriteria criteria, Pageable pageable){
+ return new ResponseEntity<>(customerResourcesService.queryAll(criteria,pageable),HttpStatus.OK);
+ }
+
+ @GetMapping(value = "/all")
+ @Log("查询客户资源管理")
+ @ApiOperation("查询客户资源管理")
+ @PreAuthorize("@el.check('customerResources:list')")
+ public ResponseEntity<Object> queryCustomerResources(CustomerResourcesQueryCriteria criteria){
+ return new ResponseEntity<>(customerResourcesService.queryAll(criteria),HttpStatus.OK);
+ }
+
+ @PostMapping
+ @Log("新增客户资源管理")
+ @ApiOperation("新增客户资源管理")
+ @PreAuthorize("@el.check('customerResources:add')")
+ public ResponseEntity<Object> createCustomerResources(@Validated @RequestBody CustomerResources resources) throws Exception {
+ customerResourcesService.create(resources);
+ return new ResponseEntity<>(HttpStatus.CREATED);
+ }
+
+ @PutMapping
+ @Log("修改客户资源管理")
+ @ApiOperation("修改客户资源管理")
+ @PreAuthorize("@el.check('customerResources:edit')")
+ public ResponseEntity<Object> updateCustomerResources(@Validated @RequestBody CustomerResources resources) throws Exception {
+ customerResourcesService.update(resources);
+ return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+ }
+
+ @DeleteMapping
+ @Log("删除客户资源管理")
+ @ApiOperation("删除客户资源管理")
+ @PreAuthorize("@el.check('customerResources:del')")
+ public ResponseEntity<Object> deleteCustomerResources(@RequestBody Long[] ids) {
+ customerResourcesService.deleteAll(ids);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+
+ @PostMapping(value = "/getRemindUser")
+ @Log("查询被提醒人")
+ @ApiOperation("查询被提醒人")
+ public ResponseEntity<Object> getRemindUser(@Validated @RequestBody CustomerResources resources){
+ return new ResponseEntity<>(customerResourcesService.getRemindUser(resources),HttpStatus.OK);
+ }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/CustomerResourcesUserController.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/CustomerResourcesUserController.java
new file mode 100644
index 0000000..1e16e86
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/CustomerResourcesUserController.java
@@ -0,0 +1,87 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.rest;
+
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.system.domain.CustomerResourcesUser;
+import me.zhengjie.modules.system.service.CustomerResourcesUserService;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesUserQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2023-02-03
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "客户资源与用户中间表管理")
+@RequestMapping("/api/customerResourcesUser")
+public class CustomerResourcesUserController {
+
+ private final CustomerResourcesUserService customerResourcesUserService;
+
+ @Log("导出数据")
+ @ApiOperation("导出数据")
+ @GetMapping(value = "/download")
+ @PreAuthorize("@el.check('customerResourcesUser:list')")
+ public void exportCustomerResourcesUser(HttpServletResponse response, CustomerResourcesUserQueryCriteria criteria) throws IOException {
+ customerResourcesUserService.download(customerResourcesUserService.queryAll(criteria), response);
+ }
+
+ @GetMapping
+ @Log("查询客户资源与用户中间表")
+ @ApiOperation("查询客户资源与用户中间表")
+ @PreAuthorize("@el.check('customerResourcesUser:list')")
+ public ResponseEntity<Object> queryCustomerResourcesUser(CustomerResourcesUserQueryCriteria criteria, Pageable pageable){
+ return new ResponseEntity<>(customerResourcesUserService.queryAll(criteria,pageable),HttpStatus.OK);
+ }
+
+ @PostMapping
+ @Log("新增客户资源与用户中间表")
+ @ApiOperation("新增客户资源与用户中间表")
+ @PreAuthorize("@el.check('customerResourcesUser:add')")
+ public ResponseEntity<Object> createCustomerResourcesUser(@Validated @RequestBody CustomerResourcesUser resources){
+ return new ResponseEntity<>(customerResourcesUserService.create(resources),HttpStatus.CREATED);
+ }
+
+ @PutMapping
+ @Log("修改客户资源与用户中间表")
+ @ApiOperation("修改客户资源与用户中间表")
+ @PreAuthorize("@el.check('customerResourcesUser:edit')")
+ public ResponseEntity<Object> updateCustomerResourcesUser(@Validated @RequestBody CustomerResourcesUser resources){
+ customerResourcesUserService.update(resources);
+ return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+ }
+
+ @DeleteMapping
+ @Log("删除客户资源与用户中间表")
+ @ApiOperation("删除客户资源与用户中间表")
+ @PreAuthorize("@el.check('customerResourcesUser:del')")
+ public ResponseEntity<Object> deleteCustomerResourcesUser(@RequestBody Long[] ids) {
+ customerResourcesUserService.deleteAll(ids);
+ return new ResponseEntity<>(HttpStatus.OK);
+ }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/CustomerResourcesService.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/CustomerResourcesService.java
new file mode 100644
index 0000000..b5b0df0
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/CustomerResourcesService.java
@@ -0,0 +1,91 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.service;
+
+import me.zhengjie.modules.system.domain.CustomerResources;
+import me.zhengjie.modules.system.domain.User;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesDto;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @description 服务接口
+* @author wcd
+* @date 2023-02-02
+**/
+public interface CustomerResourcesService {
+
+ /**
+ * 查询数据分页
+ * @param criteria 条件
+ * @param pageable 分页参数
+ * @return Map<String,Object>
+ */
+ Map<String,Object> queryAll(CustomerResourcesQueryCriteria criteria, Pageable pageable);
+
+ /**
+ * 查询所有数据不分页
+ * @param criteria 条件参数
+ * @return List<CustomerResourcesDto>
+ */
+ List<CustomerResourcesDto> queryAll(CustomerResourcesQueryCriteria criteria);
+
+ /**
+ * 根据ID查询
+ * @param id ID
+ * @return CustomerResourcesDto
+ */
+ CustomerResourcesDto findById(Long id);
+
+ /**
+ * 创建
+ * @param resources /
+ * @return CustomerResourcesDto
+ */
+ void create(CustomerResources resources) throws Exception;
+
+ /**
+ * 编辑
+ * @param resources /
+ */
+ void update(CustomerResources resources) throws Exception;
+
+ /**
+ * 多选删除
+ * @param ids /
+ */
+ void deleteAll(Long[] ids);
+
+ /**
+ * 导出数据
+ * @param all 待导出的数据
+ * @param response /
+ * @throws IOException /
+ */
+ void download(List<CustomerResourcesDto> all, HttpServletResponse response) throws IOException;
+
+ /**
+ * 查询被提醒人
+ * @param resources
+ * @return
+ */
+ List<User> getRemindUser(CustomerResources resources);
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/CustomerResourcesUserService.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/CustomerResourcesUserService.java
new file mode 100644
index 0000000..d6a48d1
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/CustomerResourcesUserService.java
@@ -0,0 +1,83 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.service;
+
+import me.zhengjie.modules.system.domain.CustomerResourcesUser;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesUserDto;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesUserQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @description 服务接口
+* @author wcd
+* @date 2023-02-03
+**/
+public interface CustomerResourcesUserService {
+
+ /**
+ * 查询数据分页
+ * @param criteria 条件
+ * @param pageable 分页参数
+ * @return Map<String,Object>
+ */
+ Map<String,Object> queryAll(CustomerResourcesUserQueryCriteria criteria, Pageable pageable);
+
+ /**
+ * 查询所有数据不分页
+ * @param criteria 条件参数
+ * @return List<CustomerResourcesUserDto>
+ */
+ List<CustomerResourcesUserDto> queryAll(CustomerResourcesUserQueryCriteria criteria);
+
+ /**
+ * 根据ID查询
+ * @param id ID
+ * @return CustomerResourcesUserDto
+ */
+ CustomerResourcesUserDto findById(Long id);
+
+ /**
+ * 创建
+ * @param resources /
+ * @return CustomerResourcesUserDto
+ */
+ CustomerResourcesUserDto create(CustomerResourcesUser resources);
+
+ /**
+ * 编辑
+ * @param resources /
+ */
+ void update(CustomerResourcesUser resources);
+
+ /**
+ * 多选删除
+ * @param ids /
+ */
+ void deleteAll(Long[] ids);
+
+ /**
+ * 导出数据
+ * @param all 待导出的数据
+ * @param response /
+ * @throws IOException /
+ */
+ void download(List<CustomerResourcesUserDto> all, HttpServletResponse response) throws IOException;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesDto.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesDto.java
new file mode 100644
index 0000000..f25bd00
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesDto.java
@@ -0,0 +1,52 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.service.dto;
+
+import lombok.Data;
+import me.zhengjie.base.BaseDTO;
+
+import java.sql.Timestamp;
+import java.io.Serializable;
+
+/**
+* @website https://eladmin.vip
+* @description /
+* @author wcd
+* @date 2023-02-02
+**/
+@Data
+public class CustomerResourcesDto extends BaseDTO implements Serializable {
+
+ private Long id;
+
+ /** 标题 */
+ private String title;
+
+ /** 分类 */
+ private String classification;
+
+ /** 记录时间 */
+ private Timestamp recordTime;
+
+ /** 记录内容 */
+ private String recordContent;
+
+ /** 开启提醒(提醒时间) */
+ private Timestamp openingTime;
+
+ /** 备注 */
+ private String remarks;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesQueryCriteria.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesQueryCriteria.java
new file mode 100644
index 0000000..c3cb9e2
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesQueryCriteria.java
@@ -0,0 +1,37 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.service.dto;
+
+import lombok.Data;
+import java.util.List;
+import me.zhengjie.annotation.Query;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2023-02-02
+**/
+@Data
+public class CustomerResourcesQueryCriteria{
+
+ //标题
+ @Query(type = Query.Type.INNER_LIKE, propName = "title")
+ private String title;
+
+ //分类
+ @Query(type = Query.Type.INNER_LIKE, propName = "classification")
+ private String classification;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesUserDto.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesUserDto.java
new file mode 100644
index 0000000..79f955d
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesUserDto.java
@@ -0,0 +1,41 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.service.dto;
+
+import lombok.Data;
+import me.zhengjie.base.BaseDTO;
+
+import java.sql.Timestamp;
+import java.io.Serializable;
+
+/**
+* @website https://eladmin.vip
+* @description /
+* @author wcd
+* @date 2023-02-03
+**/
+@Data
+public class CustomerResourcesUserDto extends BaseDTO implements Serializable {
+
+ private Long id;
+
+ /** 客户资源 id */
+ private Long customerResourcesId;
+
+ /** 用户 id */
+ private Long userId;
+
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesUserQueryCriteria.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesUserQueryCriteria.java
new file mode 100644
index 0000000..bafbbbe
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/CustomerResourcesUserQueryCriteria.java
@@ -0,0 +1,29 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.service.dto;
+
+import lombok.Data;
+import java.util.List;
+import me.zhengjie.annotation.Query;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2023-02-03
+**/
+@Data
+public class CustomerResourcesUserQueryCriteria{
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java
new file mode 100644
index 0000000..54d1074
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java
@@ -0,0 +1,216 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.service.impl;
+
+import me.zhengjie.modules.constant.Constant;
+import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
+import me.zhengjie.modules.system.domain.CustomerResources;
+import me.zhengjie.modules.system.domain.CustomerResourcesUser;
+import me.zhengjie.modules.system.domain.User;
+import me.zhengjie.modules.system.repository.CustomerResourcesUserRepository;
+import me.zhengjie.modules.system.repository.UserRepository;
+import me.zhengjie.utils.ValidationUtil;
+import me.zhengjie.utils.FileUtil;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.system.repository.CustomerResourcesRepository;
+import me.zhengjie.modules.system.service.CustomerResourcesService;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesDto;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesQueryCriteria;
+import me.zhengjie.modules.system.service.mapstruct.CustomerResourcesMapper;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import me.zhengjie.utils.PageUtil;
+import me.zhengjie.utils.QueryHelp;
+
+import java.sql.Timestamp;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @description 服务实现
+* @author wcd
+* @date 2023-02-02
+**/
+@Service
+@Transactional
+@RequiredArgsConstructor
+public class CustomerResourcesServiceImpl implements CustomerResourcesService {
+
+ private final CustomerResourcesRepository customerResourcesRepository;
+ private final CustomerResourcesMapper customerResourcesMapper;
+ private final UserRepository userRepository;
+ private final OpaiDingTalkService opaiDingTalkService;
+ private final CustomerResourcesUserRepository customerResourcesUserRepository;
+
+ @Override
+ public Map<String,Object> queryAll(CustomerResourcesQueryCriteria criteria, Pageable pageable){
+ Page<CustomerResources> page = customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+ return PageUtil.toPage(page.map(customerResourcesMapper::toDto));
+ }
+
+ @Override
+ public List<CustomerResourcesDto> queryAll(CustomerResourcesQueryCriteria criteria){
+ return customerResourcesMapper.toDto(customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+ }
+
+ @Override
+ @Transactional
+ public CustomerResourcesDto findById(Long id) {
+ CustomerResources customerResources = customerResourcesRepository.findById(id).orElseGet(CustomerResources::new);
+ ValidationUtil.isNull(customerResources.getId(),"CustomerResources","id",id);
+ return customerResourcesMapper.toDto(customerResources);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void create(CustomerResources resources) throws Exception {
+ // 提醒时间为空,状态为提醒说明是立即提醒,发送钉钉消息
+ if(ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)){
+ // 调用
+ resources = setDingding(resources);
+ }
+ // 保存
+ customerResourcesRepository.save(resources);
+ // 中间表添加数据
+ if(resources.getRemindPeople().size() != 0){
+ for(int i = 0; i < resources.getRemindPeople().size(); i++){
+ // 中间表添加数据
+ CustomerResourcesUser customerResourcesUser = new CustomerResourcesUser();
+ customerResourcesUser.setCustomerResourcesId(resources.getId());
+ customerResourcesUser.setUserId(resources.getRemindPeople().get(i));
+ customerResourcesUserRepository.save(customerResourcesUser);
+ }
+ }
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(CustomerResources resources) throws Exception {
+ CustomerResources customerResources = customerResourcesRepository.findById(resources.getId()).orElseGet(CustomerResources::new);
+ ValidationUtil.isNull( customerResources.getId(),"CustomerResources","id",resources.getId());
+ customerResources.copy(resources);
+ // 提醒时间为空,状态为提醒说明是立即提醒,发送钉钉消息
+ if(ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)){
+ // 调用
+ customerResources = setDingding(customerResources);
+ }else if(resources.getRemind().equals(Constant.RESOURCES_TYPE_NOREMIND)){
+ customerResources.setOpeningTime(null);
+ }
+ customerResourcesRepository.save(customerResources);
+ // 删除中间表数据
+ List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(customerResources.getId());
+ for(int i = 0; i < customerResourcesUserList.size(); i++){
+ customerResourcesUserRepository.deleteByCustomerResourcesId(customerResourcesUserList.get(i).getCustomerResourcesId());
+ }
+ // 中间表添加数据
+ if(resources.getRemindPeople().size() != 0){
+ for(int i = 0; i < resources.getRemindPeople().size(); i++){
+ // 中间表添加数据
+ CustomerResourcesUser customerResourcesUser = new CustomerResourcesUser();
+ customerResourcesUser.setCustomerResourcesId(resources.getId());
+ customerResourcesUser.setUserId(resources.getRemindPeople().get(i));
+ customerResourcesUserRepository.save(customerResourcesUser);
+ }
+ }
+ }
+
+ /**
+ * 发送钉钉(公共)
+ * @param resources
+ * @return
+ * @throws Exception
+ */
+ public CustomerResources setDingding(CustomerResources resources) throws Exception {
+ // 获取当前时间
+ SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String time = sf.format(new Date());
+ resources.setOpeningTime(Timestamp.valueOf(time));
+ // 获取存储用户钉钉号
+ List<String> dingDingList = new ArrayList<>();
+ if(resources.getRemindPeople().size() != 0){
+ for(Long userId : resources.getRemindPeople()){
+ // 查询用户
+ User user = userRepository.findById(userId).orElseGet(User::new);
+ if(ObjectUtils.isNotEmpty(user.getDingding())){
+ dingDingList.add(user.getDingding());
+ }
+ }
+ }
+ // 发送内容至钉钉
+ opaiDingTalkService.sendNotice(dingDingList, "客户资源管理提示", "### 客户资源管理提示 \n >" +
+ " \n 标题:" + resources.getTitle() +
+ " \n 分类: " + resources.getClassification() +
+ " \n 客户资源有变动,请登录PMS系统查看。", "card");
+ return resources;
+ }
+
+ @Override
+ public void deleteAll(Long[] ids) {
+ for (Long id : ids) {
+ // 查询中间表
+ List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(id);
+ for(int i = 0; i < customerResourcesUserList.size(); i++){
+ customerResourcesUserRepository.deleteByCustomerResourcesId(customerResourcesUserList.get(i).getCustomerResourcesId());
+ }
+ customerResourcesRepository.deleteById(id);
+ }
+ }
+
+ @Override
+ public void download(List<CustomerResourcesDto> all, HttpServletResponse response) throws IOException {
+ List<Map<String, Object>> list = new ArrayList<>();
+ for (CustomerResourcesDto customerResources : all) {
+ Map<String,Object> map = new LinkedHashMap<>();
+ map.put("标题", customerResources.getTitle());
+ map.put("分类", customerResources.getClassification());
+ map.put("记录时间", customerResources.getRecordTime());
+ map.put("记录内容", customerResources.getRecordContent());
+ map.put("提醒时间", customerResources.getOpeningTime() == null ? "不提醒" : customerResources.getOpeningTime());
+ map.put("备注", customerResources.getRemarks());
+ map.put("创建者", customerResources.getCreateBy());
+ map.put("创建时间", customerResources.getCreateTime());
+ map.put("更新者", customerResources.getUpdateBy());
+ map.put("更新时间", customerResources.getUpdateTime());
+ list.add(map);
+ }
+ FileUtil.downloadExcel(list, response);
+ }
+
+ /**
+ * 查询被提醒人
+ * @param resources
+ * @return
+ */
+ @Override
+ public List<User> getRemindUser(CustomerResources resources) {
+ // 根据客户资源管理Id查询被提醒人表
+ List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(resources.getId());
+ // 用户信息
+ List<User> userList = new ArrayList<>();
+ for(int i = 0; i < customerResourcesUserList.size(); i++){
+ // 查询用户表
+ User user = userRepository.findById(customerResourcesUserList.get(i).getUserId()).orElseGet(User::new);
+ userList.add(user);
+ }
+ return userList;
+ }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesUserServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesUserServiceImpl.java
new file mode 100644
index 0000000..abe8979
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesUserServiceImpl.java
@@ -0,0 +1,109 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.service.impl;
+
+import me.zhengjie.modules.system.domain.CustomerResourcesUser;
+import me.zhengjie.utils.ValidationUtil;
+import me.zhengjie.utils.FileUtil;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.system.repository.CustomerResourcesUserRepository;
+import me.zhengjie.modules.system.service.CustomerResourcesUserService;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesUserDto;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesUserQueryCriteria;
+import me.zhengjie.modules.system.service.mapstruct.CustomerResourcesUserMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import me.zhengjie.utils.PageUtil;
+import me.zhengjie.utils.QueryHelp;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+/**
+* @website https://eladmin.vip
+* @description 服务实现
+* @author wcd
+* @date 2023-02-03
+**/
+@Service
+@RequiredArgsConstructor
+public class CustomerResourcesUserServiceImpl implements CustomerResourcesUserService {
+
+ private final CustomerResourcesUserRepository customerResourcesUserRepository;
+ private final CustomerResourcesUserMapper customerResourcesUserMapper;
+
+ @Override
+ public Map<String,Object> queryAll(CustomerResourcesUserQueryCriteria criteria, Pageable pageable){
+ Page<CustomerResourcesUser> page = customerResourcesUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+ return PageUtil.toPage(page.map(customerResourcesUserMapper::toDto));
+ }
+
+ @Override
+ public List<CustomerResourcesUserDto> queryAll(CustomerResourcesUserQueryCriteria criteria){
+ return customerResourcesUserMapper.toDto(customerResourcesUserRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+ }
+
+ @Override
+ @Transactional
+ public CustomerResourcesUserDto findById(Long id) {
+ CustomerResourcesUser customerResourcesUser = customerResourcesUserRepository.findById(id).orElseGet(CustomerResourcesUser::new);
+ ValidationUtil.isNull(customerResourcesUser.getId(),"CustomerResourcesUser","id",id);
+ return customerResourcesUserMapper.toDto(customerResourcesUser);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public CustomerResourcesUserDto create(CustomerResourcesUser resources) {
+ return customerResourcesUserMapper.toDto(customerResourcesUserRepository.save(resources));
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(CustomerResourcesUser resources) {
+ CustomerResourcesUser customerResourcesUser = customerResourcesUserRepository.findById(resources.getId()).orElseGet(CustomerResourcesUser::new);
+ ValidationUtil.isNull( customerResourcesUser.getId(),"CustomerResourcesUser","id",resources.getId());
+ customerResourcesUser.copy(resources);
+ customerResourcesUserRepository.save(customerResourcesUser);
+ }
+
+ @Override
+ public void deleteAll(Long[] ids) {
+ for (Long id : ids) {
+ customerResourcesUserRepository.deleteById(id);
+ }
+ }
+
+ @Override
+ public void download(List<CustomerResourcesUserDto> all, HttpServletResponse response) throws IOException {
+ List<Map<String, Object>> list = new ArrayList<>();
+ for (CustomerResourcesUserDto customerResourcesUser : all) {
+ Map<String,Object> map = new LinkedHashMap<>();
+ map.put("客户资源 id", customerResourcesUser.getCustomerResourcesId());
+ map.put("用户 id", customerResourcesUser.getUserId());
+ map.put("创建者", customerResourcesUser.getCreateBy());
+ map.put("创建时间", customerResourcesUser.getCreateTime());
+ map.put("更新者", customerResourcesUser.getUpdateBy());
+ map.put("更新时间", customerResourcesUser.getUpdateTime());
+ list.add(map);
+ }
+ FileUtil.downloadExcel(list, response);
+ }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/CustomerResourcesMapper.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/CustomerResourcesMapper.java
new file mode 100644
index 0000000..ce5b146
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/CustomerResourcesMapper.java
@@ -0,0 +1,32 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.service.mapstruct;
+
+import me.zhengjie.base.BaseMapper;
+import me.zhengjie.modules.system.domain.CustomerResources;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2023-02-02
+**/
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface CustomerResourcesMapper extends BaseMapper<CustomerResourcesDto, CustomerResources> {
+
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/CustomerResourcesUserMapper.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/CustomerResourcesUserMapper.java
new file mode 100644
index 0000000..953f3f9
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/CustomerResourcesUserMapper.java
@@ -0,0 +1,32 @@
+/*
+* Copyright 2019-2020 Zheng Jie
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+package me.zhengjie.modules.system.service.mapstruct;
+
+import me.zhengjie.base.BaseMapper;
+import me.zhengjie.modules.system.domain.CustomerResourcesUser;
+import me.zhengjie.modules.system.service.dto.CustomerResourcesUserDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+* @website https://eladmin.vip
+* @author wcd
+* @date 2023-02-03
+**/
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface CustomerResourcesUserMapper extends BaseMapper<CustomerResourcesUserDto, CustomerResourcesUser> {
+
+}
\ No newline at end of file
diff --git a/eladmin-web-master/src/api/system/customerResources.js b/eladmin-web-master/src/api/system/customerResources.js
new file mode 100644
index 0000000..e9b2a95
--- /dev/null
+++ b/eladmin-web-master/src/api/system/customerResources.js
@@ -0,0 +1,43 @@
+import request from '@/utils/request'
+
+export function getAll(params) {
+ return request({
+ url: 'api/customerResources/all',
+ method: 'get',
+ params
+ })
+}
+
+export function add(data) {
+ return request({
+ url: 'api/customerResources',
+ method: 'post',
+ data
+ })
+}
+
+export function del(ids) {
+ return request({
+ url: 'api/customerResources/',
+ method: 'delete',
+ data: ids
+ })
+}
+
+export function edit(data) {
+ return request({
+ url: 'api/customerResources',
+ method: 'put',
+ data
+ })
+}
+
+export function getRemindUser(data) {
+ return request({
+ url: 'api/customerResources/getRemindUser',
+ method: 'post',
+ data
+ })
+}
+
+export default { add, edit, del, getAll, getRemindUser }
diff --git a/eladmin-web-master/src/utils/constant.js b/eladmin-web-master/src/utils/constant.js
index 2a8bef3..113a251 100644
--- a/eladmin-web-master/src/utils/constant.js
+++ b/eladmin-web-master/src/utils/constant.js
@@ -256,6 +256,13 @@
// 公示状态:已公示
export const PUBLICITY_STATUS_YES = 'publicity_status_yes'
+// 提醒状态
+export const RESOURCES_TYPE = 'resources_type'
+// 提醒状态:提醒
+export const RESOURCES_TYPE_REMIND = 'resources_type_remind'
+// 提醒状态:不提醒
+export const RESOURCES_TYPE_NOREMIND = 'resources_type_noRemind'
+
export default {
ROLE_LEVEL_SUPER,
ROLE_LEVEL_GENERAL,
@@ -373,5 +380,8 @@
BUSSINESS_APPROVE_STATUS_REFUSE,
PUBLICITY_STATUS,
PUBLICITY_STATUS_NOT,
- PUBLICITY_STATUS_YES
+ PUBLICITY_STATUS_YES,
+ RESOURCES_TYPE,
+ RESOURCES_TYPE_REMIND,
+ RESOURCES_TYPE_NOREMIND
}
diff --git a/eladmin-web-master/src/views/system/customerResources/index.vue b/eladmin-web-master/src/views/system/customerResources/index.vue
new file mode 100644
index 0000000..f305694
--- /dev/null
+++ b/eladmin-web-master/src/views/system/customerResources/index.vue
@@ -0,0 +1,275 @@
+<template>
+ <div class="app-container">
+ <!--工具栏-->
+ <div class="head-container">
+ <div>
+ <el-input
+ v-model="query.title"
+ clearable
+ size="small"
+ placeholder="请输入标题"
+ style="width: 200px;"
+ class="filter-item"
+ @keyup.enter.native="crud.toQuery"
+ />
+ <el-select v-model="query.classification" filterable clearable placeholder="请输入分类" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+ <el-option
+ v-for="item in classifications"
+ :key="item.id"
+ :label="item.classification"
+ :value="item.classification"
+ />
+ </el-select>
+ <rrOperation />
+ </div>
+ <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
+ <crudOperation :permission="permission" />
+ <!--表单组件-->
+ <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
+ <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
+ <el-form-item label="标题" prop="title">
+ <el-input v-model="form.title" style="width: 370px;" />
+ </el-form-item>
+ <el-form-item label="分类" prop="classification">
+ <el-autocomplete
+ v-model="form.classification"
+ class="inline-input"
+ :fetch-suggestions="querySearch"
+ placeholder="请输入内容"
+ style="width: 370px;"
+ @select="handleSubmit"
+ />
+ </el-form-item>
+ <el-form-item label="记录时间" prop="recordTime">
+ <el-date-picker
+ v-model="form.recordTime"
+ type="datetime"
+ placeholder="选择日期时间"
+ style="width: 370px;"
+ value-format="yyyy-MM-dd HH:mm:ss"
+ align="right"
+ default-time="09:00:00"
+ />
+ </el-form-item>
+ <el-form-item label="记录内容">
+ <el-input v-model="form.recordContent" type="textarea" rows="3" style="width: 370px;" />
+ </el-form-item>
+ <el-form-item label="是否提醒" prop="remind">
+ <el-select v-model="form.remind" clearable style="width: 370px;" @change="remindChange()">
+ <el-option
+ v-for="item in dict[dictResourceType]"
+ :key="item.value"
+ :label="item.label"
+ :value="item.value"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item v-if="form.remind === dictResourcesTypeRemind" label="请选择" prop="resource">
+ <el-radio-group v-model="form.resource" @change="remindChange()">
+ <el-radio label="立即提醒" />
+ <el-radio label="稍后提醒" />
+ </el-radio-group>
+ </el-form-item>
+ <el-form-item v-if="form.remind === dictResourcesTypeRemind && form.resource === resourceTitle" label="提醒时间" prop="openingTime">
+ <el-date-picker
+ v-model="form.openingTime"
+ type="datetime"
+ placeholder="选择日期时间"
+ style="width: 370px;"
+ value-format="yyyy-MM-dd HH:00:00"
+ align="right"
+ default-time="09:00:00"
+ />
+ </el-form-item>
+ <el-form-item v-if="form.remind === dictResourcesTypeRemind" label="提醒人" prop="remindPeople">
+ <el-select v-model="form.remindPeople" filterable multiple placeholder="请选择人员" style="width: 370px;" @change="change">
+ <el-option
+ v-for="(item, index) in users"
+ :key="index"
+ :label="item.nickName"
+ :value="item.id"
+ />
+ </el-select>
+ </el-form-item>
+ <el-form-item label="备注">
+ <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 370px;" />
+ </el-form-item>
+ </el-form>
+ <div slot="footer" class="dialog-footer">
+ <el-button type="text" @click="crud.cancelCU">取消</el-button>
+ <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
+ </div>
+ </el-dialog>
+ <!--表格渲染-->
+ <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
+ <el-table-column type="selection" width="55" />
+ <el-table-column prop="title" label="标题" show-overflow-tooltip>
+ <template slot-scope="scope">
+ <el-tag>{{ scope.row.title }}</el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column prop="classification" label="分类" show-overflow-tooltip />
+ <el-table-column prop="recordTime" label="记录时间" show-overflow-tooltip />
+ <el-table-column prop="recordContent" label="记录内容" show-overflow-tooltip />
+ <el-table-column prop="openingTime" label="提醒时间" show-overflow-tooltip>
+ <template slot-scope="scope">
+ <el-tag v-if="scope.row.openingTime == null" type="warning">{{ '不提醒' }}</el-tag>
+ <el-tag v-if="scope.row.openingTime != null">{{ scope.row.openingTime }}</el-tag>
+ </template>
+ </el-table-column>
+ <el-table-column prop="remarks" label="备注" show-overflow-tooltip />
+ <el-table-column prop="createTime" label="创建时间" show-overflow-tooltip />
+ <el-table-column v-if="checkPer(['admin','customerResources:edit','customerResources:del'])" label="操作" width="150px" align="center">
+ <template slot-scope="scope">
+ <udOperation
+ :data="scope.row"
+ :permission="permission"
+ />
+ </template>
+ </el-table-column>
+ </el-table>
+ <!--分页组件-->
+ <pagination />
+ </div>
+ </div>
+</template>
+
+<script>
+import crudCustomerResources from '@/api/system/customerResources'
+import CRUD, { presenter, header, form, crud } from '@crud/crud'
+import crudUser from '@/api/system/user'
+import rrOperation from '@crud/RR.operation'
+import crudOperation from '@crud/CRUD.operation'
+import udOperation from '@crud/UD.operation'
+import pagination from '@crud/Pagination'
+import constant from '@/utils/constant'
+
+const defaultForm = { id: null, title: null, classification: null, recordTime: null, recordContent: null, openingTime: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null, remind: null, resource: [], remindPeople: [], type: null }
+export default {
+ name: 'CustomerResources',
+ components: { pagination, crudOperation, rrOperation, udOperation },
+ mixins: [presenter(), header(), form(defaultForm), crud()],
+ // 数据字典
+ dicts: [constant.RESOURCES_TYPE],
+ cruds() {
+ return CRUD({ title: '客户资源管理', url: 'api/customerResources', idField: 'id', sort: 'id,desc', crudMethod: { ...crudCustomerResources }})
+ },
+ data() {
+ var checkv = (rule, value, callback) => {
+ if (value == null || value === '') {
+ callback(new Error('不能为空'))
+ } else {
+ callback()
+ }
+ }
+ var checkRemindPeople = (rule, value, callback) => {
+ if (value === 0) {
+ callback(new Error('被提醒人不能为空'))
+ } else {
+ callback()
+ }
+ }
+ return {
+ permission: {
+ add: ['admin', 'customerResources:add'],
+ edit: ['admin', 'customerResources:edit'],
+ del: ['admin', 'customerResources:del'],
+ download: ['admin', 'customerResources:download']
+ },
+ rules: {
+ title: [
+ { required: true, message: '标题不能为空', trigger: 'blur' }
+ ],
+ classification: [
+ { required: true, message: '分类不能为空', trigger: 'change' }
+ ],
+ recordTime: [
+ { required: true, message: '记录时间不能为空', trigger: 'blur' }
+ ],
+ remind: [
+ { required: true, message: '不能为空', trigger: 'change' }
+ ],
+ openingTime: [
+ { required: true, message: '请选择提醒时间', trigger: 'blur' }
+ ],
+ resource: [
+ { required: true, validator: checkv, trigger: 'change' }
+ ],
+ remindPeople: [
+ { required: true, validator: checkRemindPeople, trigger: 'change' }
+ ]
+ },
+ dictResourceType: constant.RESOURCES_TYPE,
+ dictResourcesTypeRemind: constant.RESOURCES_TYPE_REMIND,
+ dictResourcesTypeNoRemind: constant.RESOURCES_TYPE_NOREMIND,
+ resourceTitle: '稍后提醒',
+ resourceTitles: '立即提醒',
+ users: [],
+ time: ':00:00',
+ remindUsers: [],
+ classifications: [],
+ restaurants: [],
+ state: '',
+ timeout: null }
+ },
+ methods: {
+ // 钩子:在获取表格数据之前执行,false 则代表不获取数据
+ [CRUD.HOOK.beforeRefresh]() {
+ crudUser.getAll().then(res => {
+ this.users = res
+ })
+ crudCustomerResources.getAll().then(res => {
+ this.classifications = res
+ })
+ return true
+ },
+ // 钩子:编辑之前
+ [CRUD.HOOK.beforeToEdit]() {
+ if (this.form.openingTime !== null) {
+ this.form.remind = this.dictResourcesTypeRemind
+ if (this.form.openingTime.substring(13, 19) === this.time) {
+ this.form.resource = this.resourceTitle
+ } else {
+ this.form.resource = this.resourceTitles
+ }
+ crudCustomerResources.getRemindUser(this.form).then(res => {
+ const users = []
+ res.forEach(data => {
+ users.push(data.id)
+ })
+ this.form.remindPeople = users
+ })
+ } else {
+ this.form.remind = this.dictResourcesTypeNoRemind
+ }
+ },
+ // 改变时间
+ remindChange() {
+ this.form.openingTime = null
+ this.form.remindPeople = []
+ },
+ // 多选
+ change() {
+ this.$forceUpdate()
+ },
+ handleSubmit() {
+ },
+ // 输入框获取焦点时调用的方法
+ querySearch(queryString, cb) {
+ let results = this.classifications
+ results = queryString ? results.filter(this.createFilter(queryString)) : results
+ cb(results)
+ },
+ createFilter(queryString) {
+ return (item) => {
+ item.value = item.classification
+ return item.value.toUpperCase().match(queryString.toUpperCase())
+ }
+ }
+ }
+}
+</script>
+
+<style scoped>
+
+</style>
--
Gitblit v1.9.3