src/main/java/com/zy/crm/common/CodeBuilder.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/crm/manager/controller/PlanController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/crm/manager/controller/PlanFollController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/crm/manager/entity/PlanFoll.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/crm/manager/mapper/PlanFollMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/crm/manager/service/PlanFollService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/crm/manager/service/impl/PlanFollServiceImpl.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/mapper/PlanFollMapper.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
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(); } 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("删除成功"); } } src/main/java/com/zy/crm/manager/controller/PlanFollController.java
New file @@ -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); } } src/main/java/com/zy/crm/manager/entity/PlanFoll.java
New file @@ -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; } } src/main/java/com/zy/crm/manager/mapper/PlanFollMapper.java
New file @@ -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> { } src/main/java/com/zy/crm/manager/service/PlanFollService.java
New file @@ -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> { } src/main/java/com/zy/crm/manager/service/impl/PlanFollServiceImpl.java
New file @@ -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 { } src/main/resources/mapper/PlanFollMapper.xml
New file @@ -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>