From 1e0e97841ceb7db7d419f75b2d3110f4217ce632 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期六, 19 十一月 2022 09:05:00 +0800
Subject: [PATCH] #
---
src/main/java/com/zy/crm/manager/service/impl/PlanFollServiceImpl.java | 12 ++
src/main/java/com/zy/crm/manager/mapper/PlanFollMapper.java | 12 ++
src/main/java/com/zy/crm/manager/entity/PlanFoll.java | 76 ++++++++++++
src/main/java/com/zy/crm/manager/controller/PlanController.java | 63 ++++++++++
src/main/java/com/zy/crm/manager/controller/PlanFollController.java | 135 ++++++++++++++++++++++
src/main/java/com/zy/crm/common/CodeBuilder.java | 10
src/main/java/com/zy/crm/manager/service/PlanFollService.java | 8 +
src/main/resources/mapper/PlanFollMapper.xml | 13 ++
8 files changed, 324 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/zy/crm/common/CodeBuilder.java b/src/main/java/com/zy/crm/common/CodeBuilder.java
index e524948..663d6cd 100644
--- a/src/main/java/com/zy/crm/common/CodeBuilder.java
+++ b/src/main/java/com/zy/crm/common/CodeBuilder.java
@@ -23,12 +23,12 @@
// generator.url="localhost:1433;databasename=zy_crm";
// generator.username="sa";
// generator.password="sa@123";
- generator.table="man_plan";
+ generator.table="man_plan_foll";
generator.packagePath="com.zy.crm.manager";
-// generator.js = false;
-// generator.html = false;
-// generator.htmlDetail = false;
-// generator.sql = false;
+ generator.js = false;
+ generator.html = false;
+ generator.htmlDetail = false;
+ generator.sql = false;
generator.build();
}
diff --git a/src/main/java/com/zy/crm/manager/controller/PlanController.java b/src/main/java/com/zy/crm/manager/controller/PlanController.java
index 5a58fd7..53e3926 100644
--- a/src/main/java/com/zy/crm/manager/controller/PlanController.java
+++ b/src/main/java/com/zy/crm/manager/controller/PlanController.java
@@ -9,15 +9,22 @@
import com.core.common.Cools;
import com.core.common.R;
import com.core.domain.KeyValueVo;
+import com.core.exception.CoolException;
import com.zy.crm.common.web.BaseController;
+import com.zy.crm.manager.controller.result.FollowerTableVo;
import com.zy.crm.manager.entity.Plan;
+import com.zy.crm.manager.entity.PlanFoll;
+import com.zy.crm.manager.service.PlanFollService;
import com.zy.crm.manager.service.PlanService;
+import com.zy.crm.system.entity.User;
+import com.zy.crm.system.service.UserService;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@@ -166,4 +173,60 @@
}
+ /******************************** 璺熻繘浜� ***************************************/
+
+ @Autowired
+ private PlanFollService planFollService;
+ @Autowired
+ private UserService userService;
+
+ @RequestMapping(value = "/plan/followers/table/auth")
+ @ManagerAuth
+ public R planFollowersTable(@RequestParam("orderId") Long orderId) {
+ List<PlanFoll> planFolls = planFollService.selectList(new EntityWrapper<PlanFoll>().eq("plan_id", orderId).orderBy("id", false));
+ List<FollowerTableVo> result = new ArrayList<>();
+ for (PlanFoll planFoll : planFolls) {
+ User user = userService.selectById(planFoll.getUserId());
+ FollowerTableVo vo = new FollowerTableVo();
+ vo.setUserId(user.getId());
+ vo.setUserName(user.getNickname());
+ result.add(vo);
+ }
+ return R.ok().add(result);
+ }
+
+ @RequestMapping(value = "/plan/followers/add/auth")
+ @ManagerAuth
+ @Transactional
+ public R planFollowersAdd(@RequestParam("orderId") Long orderId,
+ @RequestParam("followerIds[]") Long[] followerIds) {
+ if (Cools.isEmpty(orderId, followerIds)) {
+ return R.parse(BaseRes.PARAM);
+ }
+ for (Long userId : followerIds) {
+ if (planFollService.selectCount(new EntityWrapper<PlanFoll>().eq("plan_id", orderId).eq("user_id", userId)) == 0) {
+ PlanFoll planFoll = new PlanFoll();
+ planFoll.setPlanId(orderId);
+ planFoll.setUserId(userId);
+ if (!planFollService.insert(planFoll)) {
+ throw new CoolException("娣诲姞澶辫触锛岃鑱旂郴绠$悊鍛�");
+ }
+ }
+ }
+ return R.ok("娣诲姞鎴愬姛");
+ }
+
+ @RequestMapping(value = "/plan/followers/remove/auth")
+ @ManagerAuth
+ public R planFollowersRemove(@RequestParam("orderId") Long orderId,
+ @RequestParam("userId") Long userId) {
+ if (Cools.isEmpty(orderId, userId)) {
+ return R.parse(BaseRes.PARAM);
+ }
+ if (!planFollService.delete(new EntityWrapper<PlanFoll>().eq("plan_id", orderId).eq("user_id", userId))) {
+ throw new CoolException("鍒犻櫎澶辫触锛岃鑱旂郴绠$悊鍛�");
+ }
+ return R.ok("鍒犻櫎鎴愬姛");
+ }
+
}
diff --git a/src/main/java/com/zy/crm/manager/controller/PlanFollController.java b/src/main/java/com/zy/crm/manager/controller/PlanFollController.java
new file mode 100644
index 0000000..bdaeba5
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/controller/PlanFollController.java
@@ -0,0 +1,135 @@
+package com.zy.crm.manager.controller;
+
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.mapper.Wrapper;
+import com.baomidou.mybatisplus.plugins.Page;
+import com.core.common.DateUtils;
+import com.zy.crm.manager.entity.PlanFoll;
+import com.zy.crm.manager.service.PlanFollService;
+import com.core.annotations.ManagerAuth;
+import com.core.common.BaseRes;
+import com.core.common.Cools;
+import com.core.common.R;
+import com.core.domain.KeyValueVo;
+import com.zy.crm.common.web.BaseController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.*;
+
+@RestController
+public class PlanFollController extends BaseController {
+
+ @Autowired
+ private PlanFollService planFollService;
+
+ @RequestMapping(value = "/planFoll/{id}/auth")
+ @ManagerAuth
+ public R get(@PathVariable("id") String id) {
+ return R.ok(planFollService.selectById(String.valueOf(id)));
+ }
+
+ @RequestMapping(value = "/planFoll/list/auth")
+ @ManagerAuth
+ public R list(@RequestParam(defaultValue = "1")Integer curr,
+ @RequestParam(defaultValue = "10")Integer limit,
+ @RequestParam(required = false)String orderByField,
+ @RequestParam(required = false)String orderByType,
+ @RequestParam(required = false)String condition,
+ @RequestParam Map<String, Object> param){
+ EntityWrapper<PlanFoll> wrapper = new EntityWrapper<>();
+ excludeTrash(param);
+ convert(param, wrapper);
+ allLike(PlanFoll.class, param.keySet(), wrapper, condition);
+ if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));}
+ return R.ok(planFollService.selectPage(new Page<>(curr, limit), wrapper));
+ }
+
+ private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){
+ for (Map.Entry<String, Object> entry : map.entrySet()){
+ String val = String.valueOf(entry.getValue());
+ if (val.contains(RANGE_TIME_LINK)){
+ String[] dates = val.split(RANGE_TIME_LINK);
+ wrapper.ge(entry.getKey(), DateUtils.convert(dates[0]));
+ wrapper.le(entry.getKey(), DateUtils.convert(dates[1]));
+ } else {
+ wrapper.like(entry.getKey(), val);
+ }
+ }
+ }
+
+ @RequestMapping(value = "/planFoll/add/auth")
+ @ManagerAuth
+ public R add(PlanFoll planFoll) {
+ planFollService.insert(planFoll);
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/planFoll/update/auth")
+ @ManagerAuth
+ public R update(PlanFoll planFoll){
+ if (Cools.isEmpty(planFoll) || null==planFoll.getId()){
+ return R.error();
+ }
+ planFollService.updateById(planFoll);
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/planFoll/delete/auth")
+ @ManagerAuth
+ public R delete(@RequestParam(value="ids[]") Long[] ids){
+ for (Long id : ids){
+ planFollService.deleteById(id);
+ }
+ return R.ok();
+ }
+
+ @RequestMapping(value = "/planFoll/export/auth")
+ @ManagerAuth
+ public R export(@RequestBody JSONObject param){
+ EntityWrapper<PlanFoll> wrapper = new EntityWrapper<>();
+ List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class);
+ Map<String, Object> map = excludeTrash(param.getJSONObject("planFoll"));
+ convert(map, wrapper);
+ List<PlanFoll> list = planFollService.selectList(wrapper);
+ return R.ok(exportSupport(list, fields));
+ }
+
+ @RequestMapping(value = "/planFollQuery/auth")
+ @ManagerAuth
+ public R query(String condition) {
+ EntityWrapper<PlanFoll> wrapper = new EntityWrapper<>();
+ wrapper.like("id", condition);
+ Page<PlanFoll> page = planFollService.selectPage(new Page<>(0, 10), wrapper);
+ List<Map<String, Object>> result = new ArrayList<>();
+ for (PlanFoll planFoll : page.getRecords()){
+ Map<String, Object> map = new HashMap<>();
+ map.put("id", planFoll.getId());
+ map.put("value", planFoll.getId());
+ result.add(map);
+ }
+ return R.ok(result);
+ }
+
+ @RequestMapping(value = "/planFoll/check/column/auth")
+ @ManagerAuth
+ public R query(@RequestBody JSONObject param) {
+ Wrapper<PlanFoll> wrapper = new EntityWrapper<PlanFoll>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val"));
+ if (null != planFollService.selectOne(wrapper)){
+ return R.parse(BaseRes.REPEAT).add(getComment(PlanFoll.class, String.valueOf(param.get("key"))));
+ }
+ return R.ok();
+ }
+
+ @RequestMapping("/planFoll/all/get/kv")
+ @ManagerAuth
+ public R getDataKV(@RequestParam(required = false) String condition) {
+ List<KeyValueVo> vos = new ArrayList<>();
+ Wrapper<PlanFoll> wrapper = new EntityWrapper<PlanFoll>().andNew().like("id", condition).orderBy("create_time", false);
+ planFollService.selectPage(new Page<>(1, 30), wrapper).getRecords().forEach(item -> vos.add(new KeyValueVo(String.valueOf(item.getId()), item.getId())));
+ return R.ok().add(vos);
+ }
+
+}
diff --git a/src/main/java/com/zy/crm/manager/entity/PlanFoll.java b/src/main/java/com/zy/crm/manager/entity/PlanFoll.java
new file mode 100644
index 0000000..a21a533
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/entity/PlanFoll.java
@@ -0,0 +1,76 @@
+package com.zy.crm.manager.entity;
+
+import com.core.common.Cools;import com.baomidou.mybatisplus.annotations.TableId;
+import com.baomidou.mybatisplus.enums.IdType;
+import com.core.common.SpringUtils;
+import com.zy.crm.manager.service.PlanService;
+import com.zy.crm.manager.entity.Plan;
+import com.baomidou.mybatisplus.annotations.TableField;
+import com.core.common.SpringUtils;
+import com.zy.crm.system.service.UserService;
+import com.zy.crm.system.entity.User;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import com.baomidou.mybatisplus.annotations.TableName;
+import java.io.Serializable;
+
+@Data
+@TableName("man_plan_foll")
+public class PlanFoll implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /**
+ * ID
+ */
+ @ApiModelProperty(value= "ID")
+ @TableId(value = "id", type = IdType.AUTO)
+ private Long id;
+
+ /**
+ * 瑙勫垝鍗�
+ */
+ @ApiModelProperty(value= "瑙勫垝鍗�")
+ @TableField("plan_id")
+ private Long planId;
+
+ /**
+ * 璺熻繘浜�
+ */
+ @ApiModelProperty(value= "璺熻繘浜�")
+ @TableField("user_id")
+ private Long userId;
+
+ public PlanFoll() {}
+
+ public PlanFoll(Long planId,Long userId) {
+ this.planId = planId;
+ this.userId = userId;
+ }
+
+// PlanFoll planFoll = new PlanFoll(
+// null, // 瑙勫垝鍗�
+// null // 璺熻繘浜篬闈炵┖]
+// );
+
+ public String getPlanId$(){
+ PlanService service = SpringUtils.getBean(PlanService.class);
+ Plan plan = service.selectById(this.planId);
+ if (!Cools.isEmpty(plan)){
+ return String.valueOf(plan.getName());
+ }
+ 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/PlanFollMapper.java b/src/main/java/com/zy/crm/manager/mapper/PlanFollMapper.java
new file mode 100644
index 0000000..9c1d35a
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/mapper/PlanFollMapper.java
@@ -0,0 +1,12 @@
+package com.zy.crm.manager.mapper;
+
+import com.zy.crm.manager.entity.PlanFoll;
+import com.baomidou.mybatisplus.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
+
+@Mapper
+@Repository
+public interface PlanFollMapper extends BaseMapper<PlanFoll> {
+
+}
diff --git a/src/main/java/com/zy/crm/manager/service/PlanFollService.java b/src/main/java/com/zy/crm/manager/service/PlanFollService.java
new file mode 100644
index 0000000..0be02c9
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/service/PlanFollService.java
@@ -0,0 +1,8 @@
+package com.zy.crm.manager.service;
+
+import com.zy.crm.manager.entity.PlanFoll;
+import com.baomidou.mybatisplus.service.IService;
+
+public interface PlanFollService extends IService<PlanFoll> {
+
+}
diff --git a/src/main/java/com/zy/crm/manager/service/impl/PlanFollServiceImpl.java b/src/main/java/com/zy/crm/manager/service/impl/PlanFollServiceImpl.java
new file mode 100644
index 0000000..00829f6
--- /dev/null
+++ b/src/main/java/com/zy/crm/manager/service/impl/PlanFollServiceImpl.java
@@ -0,0 +1,12 @@
+package com.zy.crm.manager.service.impl;
+
+import com.zy.crm.manager.mapper.PlanFollMapper;
+import com.zy.crm.manager.entity.PlanFoll;
+import com.zy.crm.manager.service.PlanFollService;
+import com.baomidou.mybatisplus.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+@Service("planFollService")
+public class PlanFollServiceImpl extends ServiceImpl<PlanFollMapper, PlanFoll> implements PlanFollService {
+
+}
diff --git a/src/main/resources/mapper/PlanFollMapper.xml b/src/main/resources/mapper/PlanFollMapper.xml
new file mode 100644
index 0000000..fb43287
--- /dev/null
+++ b/src/main/resources/mapper/PlanFollMapper.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.PlanFollMapper">
+
+ <!-- 閫氱敤鏌ヨ鏄犲皠缁撴灉 -->
+ <resultMap id="BaseResultMap" type="com.zy.crm.manager.entity.PlanFoll">
+ <id column="id" property="id" />
+ <result column="plan_id" property="planId" />
+ <result column="user_id" property="userId" />
+
+ </resultMap>
+
+</mapper>
--
Gitblit v1.9.1