yumeng преди 4 години
родител
ревизия
590c2a398e

+ 0 - 337
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProductController.java

@@ -1,337 +0,0 @@
-package org.jeecg.modules.ctop.controller;
-
-import cn.com.ctop.common.module.entity.Advertiser;
-import cn.com.ctop.common.module.entity.Project;
-import cn.com.ctop.common.module.service.IProductService;
-import cn.com.ctop.common.module.utils.Check;
-import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
-
-import cn.com.ctop.common.module.vo.ProductInfoDto;
-import cn.com.ctop.common.module.vo.ProductVO;
-import cn.com.ctop.common.module.vo.ProjectVO;
-import cn.com.ctop.manage.modules.actor.entity.Actor;
-import cn.com.ctop.manage.modules.actor.entity.ActorComment;
-import cn.com.ctop.manage.modules.actor.entity.ActorPhoto;
-import cn.com.ctop.manage.modules.actor.entity.ActorVideo;
-import cn.com.ctop.manage.modules.actor.service.IActorCommentService;
-import cn.com.ctop.manage.modules.actor.service.IActorPhotoService;
-import cn.com.ctop.manage.modules.actor.service.IActorService;
-import cn.com.ctop.manage.modules.actor.service.IActorVideoService;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.github.pagehelper.PageInfo;
-import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.lang3.StringUtils;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.common.system.query.QueryGenerator;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-@RestController
-@Slf4j
-@RequestMapping("/ctop/product")
-public class ProductController {
-    @Autowired
-    private IProductService productService;
-
-    //获取广告主列表
-    @ResponseBody
-    @RequestMapping(value = "/advertiserList")
-    public Result<List<Advertiser>> advertiserList(HttpServletRequest request,HttpServletResponse response){
-        log.info("/ctop/product/advertiserList 方法开始");
-        Result<List<Advertiser>> result = new Result();
-
-        try {
-            List<Advertiser> advertiserList = productService.advertiserList();
-            result.setResult(advertiserList);
-        }catch (Exception e){
-            log.error(e.getMessage());
-            result.setSuccess(false);
-            result.setMessage("error");
-        }finally{
-            log.info("/ctop/product/advertiserList 方法结束");
-        }
-
-        return result;
-    }
-
-    //根据广告主id获取项目列表
-    @ResponseBody
-    @RequestMapping(value = "/getProjectListByAdvertiserId")
-    public Result<List<Project>> getProjectListByAdvertiserId(@RequestBody ProductInfoDto dto,
-            HttpServletRequest request, HttpServletResponse response){
-        log.info("/ctop/product/getProjectListByAdvertiserId 方法开始");
-        Result<List<Project>> result = new Result();
-        if(dto == null || dto.getAdvertiserId() ==null ){
-            result.setSuccess(false);
-            result.setMessage("advertiserId不能为空");
-            return result;
-        }
-
-        try {
-            List<Project> projectList = productService.getProjectListByAdvertiserId(dto.getAdvertiserId());
-            result.setResult(projectList);
-        }catch (Exception e){
-            log.error(e.getMessage());
-            result.setSuccess(false);
-            result.setMessage("error");
-        }finally{
-            log.info("/ctop/product/getProjectListByAdvertiserId 方法结束");
-        }
-
-        return result;
-    }
-
-    //根据项目列表获取运营和销售的信息
-    @ResponseBody
-    @RequestMapping(value = "/getSaleAndYunyingListByProjectIds")
-    public Result<Map<String, Object>> getSaleAndYunyingListByProjectIds(@RequestBody ProductInfoDto dto,
-                                                              HttpServletRequest request, HttpServletResponse response){
-        log.info("/ctop/product/getSaleAndYunyingListByProjectIds 方法开始");
-        Result<Map<String, Object>> result = new Result();
-        if(dto == null || dto.getProjectIds() ==null || dto.getProjectIds().size() ==0 ){
-            result.setSuccess(false);
-            result.setMessage("projectIds不能为空");
-            return result;
-        }
-
-        try {
-            Map<String, Object> map = productService.getSaleAndYunyingListByProjectIds(dto.getProjectIds());
-            result.setResult(map);
-        }catch (Exception e){
-            log.error(e.getMessage());
-            result.setSuccess(false);
-            result.setMessage("error");
-        }finally{
-            log.info("/ctop/product/getSaleAndYunyingListByProjectIds 方法结束");
-        }
-
-        return result;
-    }
-
-    //逻辑删除产品
-    @ResponseBody
-    @RequestMapping(value = "/deleteProduct")
-    public Result deleteProduct(@RequestBody ProductInfoDto dto,HttpServletRequest request, HttpServletResponse response){
-        log.info("/ctop/product/deleteProduct 方法开始");
-        Result result = new Result();
-        if(dto == null || dto.getProductId() ==null ){
-            result.setSuccess(false);
-            result.setMessage("productId不能为空");
-            return result;
-        }
-
-        try {
-            productService.deleteProduct(dto.getProductId());
-        }catch (Exception e){
-            log.error(e.getMessage());
-            result.setSuccess(false);
-            result.setMessage("error");
-        }finally{
-            log.info("/ctop/product/deleteProduct 方法结束");
-        }
-
-        return result;
-    }
-
-    //产品信息入库
-    @ResponseBody
-    @RequestMapping(value = "/insertOrUpdateProduct")
-    public Result insertOrUpdateProduct(@RequestBody ProductVO vo, HttpServletRequest request, HttpServletResponse response){
-        log.info("/ctop/product/insertOrUpdateProduct 方法开始");
-        Result result = new Result();
-
-        //if(vo==null || vo.getId() == null){
-        //    if(StringUtils.isBlank(vo.getProductName())){
-        //        result.setSuccess(false);
-        //        result.setMessage("产品不能为空");
-        //        return result;
-        //    }
-        //    Integer count = productService.getProductNameCount(vo.getProductName());
-        //    if(count != 0){
-        //        result.setSuccess(false);
-        //        result.setMessage("产品名字已存在");
-        //        return result;
-        //    }
-        //}
-
-        try {
-            productService.insertOrUpdateProduct(vo);
-        }catch (Exception e){
-            log.error(e.getMessage());
-            result.setSuccess(false);
-            result.setMessage("error");
-        }finally{
-            log.info("/ctop/product/insertOrUpdateProduct 方法结束");
-        }
-
-        return result;
-    }
-
-    //编辑产品反显
-    @ResponseBody
-    @RequestMapping(value = "/getProductInfo")
-    public Result<Map<String, Object>> getProductInfo(@RequestBody ProductInfoDto dto, HttpServletRequest request, HttpServletResponse response){
-        log.info("/ctop/product/getProductInfo 方法开始");
-        Result<Map<String, Object>> result = new Result();
-        if(dto==null || dto.getProductId() == null){
-            result.setSuccess(false);
-            result.setMessage("productId不能为空");
-            return result;
-        }
-
-        try {
-            Map<String, Object> productInfo = productService.getProductInfo(dto.getProductId());
-            result.setResult(productInfo);
-        }catch (Exception e){
-            log.error(e.getMessage());
-            result.setSuccess(false);
-            result.setMessage("error");
-        }finally{
-            log.info("/ctop/product/getProductInfo 方法结束");
-        }
-
-        return result;
-    }
-
-    //单独删除产品关联项目
-    @ResponseBody
-    @RequestMapping(value = "/deleteByProjectIdAndProductId")
-    public Result deleteByProjectIdAndProductId(@RequestBody ProductInfoDto dto, HttpServletRequest request, HttpServletResponse response){
-        log.info("/ctop/product/deleteByProjectIdAndProductId 方法开始");
-        Result result = new Result();
-        if(dto==null || dto.getProductId() == null || dto.getProjectId() ==null){
-            result.setSuccess(false);
-            result.setMessage("productId,projectId不能为空");
-            return result;
-        }
-
-        try {
-            productService.deleteByProjectIdAndProductId(dto.getProjectId(), dto.getProductId());
-        }catch (Exception e){
-            log.error(e.getMessage());
-            result.setSuccess(false);
-            result.setMessage("error");
-        }finally{
-            log.info("/ctop/product/deleteByProjectIdAndProductId 方法结束");
-        }
-
-        return result;
-    }
-
-    //编辑产品按钮反显
-    @ResponseBody
-    @RequestMapping(value = "/getProjectListByProductId")
-    public Result<List<ProjectVO>> getProjectListByProductId(@RequestBody ProductInfoDto dto, HttpServletRequest request, HttpServletResponse response){
-        log.info("/ctop/product/getProjectListByProductId 方法开始");
-        Result<List<ProjectVO>> result = new Result();
-        if(dto==null || dto.getProductId() == null){
-            result.setSuccess(false);
-            result.setMessage("productId,projectId不能为空");
-            return result;
-        }
-
-        try {
-            List<ProjectVO> projectListByProductId = productService.getProjectListByProductId(dto.getProductId());
-            result.setResult(projectListByProductId);
-        }catch (Exception e){
-            log.error(e.getMessage());
-            result.setSuccess(false);
-            result.setMessage("error");
-        }finally{
-            log.info("/ctop/product/getProjectListByProductId 方法结束");
-        }
-
-        return result;
-    }
-
-    //产品列表
-    @ResponseBody
-    @RequestMapping(value = "/getProductList")
-    public Result<PageInfo<ProductVO>> getProductList(@RequestBody ProductInfoDto dto, HttpServletRequest request, HttpServletResponse response){
-        log.info("/ctop/product/getProductList 方法开始");
-        Result<PageInfo<ProductVO>> result = new Result();
-        if(dto==null || dto.getPageNum() == 0 || dto.getPageSize() ==0){
-            dto.setPageNum(1);
-            dto.setPageSize(10);
-        }
-
-        try {
-            PageInfo<ProductVO> productList = productService.getProductList(dto.getAdvertiserName(), dto.getProductName(), dto.getPageNum(), dto.getPageSize());
-            result.setResult(productList);
-        }catch (Exception e){
-            log.error(e.getMessage());
-            result.setSuccess(false);
-            result.setMessage("error");
-        }finally{
-            log.info("/ctop/product/getProductList 方法结束");
-        }
-
-        return result;
-    }
-
-    //产品列表
-    @ResponseBody
-    @RequestMapping(value = "/insertProductProjectMap")
-    public Result insertProductProjectMap(@RequestBody ProductInfoDto dto, HttpServletRequest request, HttpServletResponse response){
-        log.info("/ctop/product/insertProductProjectMap 方法开始");
-        Result result = new Result();
-        if(dto==null || dto.getProductId() == null || dto.getProjectIds() == null){
-            result.setSuccess(false);
-            result.setMessage("productId,projectIds不能为空");
-            return result;
-        }
-
-        List<Long> dtoProjectIds = dto.getProjectIds();
-        List<Long> projectIdsHas = productService.getProjectIdsByProductId(dto.getProductId());
-        List<Long> addProjectIds = new ArrayList<>();
-
-        for(Long dtoProjectId:dtoProjectIds){
-            int filter = 0;
-            for(Long projectIdHas:projectIdsHas){
-                if(projectIdHas.equals(dtoProjectId)){
-                    filter = -1;
-                    break;
-                }
-            }
-            if(filter == 0){
-                addProjectIds.add(dtoProjectId);
-            }
-        }
-
-        if(addProjectIds==null || addProjectIds.size()==0){
-            return result;
-        }
-
-        try {
-            productService.insertProductProjectMap(dto.getProductId(), addProjectIds);
-        }catch (Exception e){
-            log.error(e.getMessage());
-            result.setSuccess(false);
-            result.setMessage("error");
-        }finally{
-            log.info("/ctop/product/insertProductProjectMap 方法结束");
-        }
-
-        return result;
-    }
-
-
-
-
-
-
-
-
-
-
-
-
-}

+ 2 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ProjectController.java

@@ -195,9 +195,9 @@ public class ProjectController {
         } else if ("operator".equals(roleCode) || "operationAssistant".equals(roleCode)) {
             queryWrapper.eq("responsible_id", userId);
             pageList = projectService.page(page, queryWrapper);
-        }else{
+        } else {
             queryWrapper.eq("responsible_id", userId);
-            pageList = projectService.page(page,queryWrapper);
+            pageList = projectService.page(page, queryWrapper);
         }
         List<Project> records = pageList.getRecords();
         if (!Check.isNull(records)) {

+ 21 - 21
jeecg-boot-module-system/src/main/resources/application-dev.yml

@@ -10,28 +10,28 @@ server:
     mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
 
 management:
- endpoints:
-  web:
-   exposure:
-    include: metrics,httptrace
+  endpoints:
+    web:
+      exposure:
+        include: metrics,httptrace
 
 spring:
   servlet:
-     multipart:
-        max-file-size: 10MB
-        max-request-size: 10MB
+    multipart:
+      max-file-size: 10MB
+      max-request-size: 10MB
   mail:
-      host: smtp.exmail.qq.com
-      username: notice@c-top.com.cn
-      password: Hcst@2019
-      properties:
-        mail:
-          smtp:
-            ssl.enable: enable
-            auth: true
-            starttls:
-              enable: true
-              required: true
+    host: smtp.exmail.qq.com
+    username: notice@c-top.com.cn
+    password: Hcst@2019
+    properties:
+      mail:
+        smtp:
+          ssl.enable: enable
+          auth: true
+          starttls:
+            enable: true
+            required: true
   ## quartz定时任务,采用数据库方式
   quartz:
     job-store-type: jdbc
@@ -132,9 +132,9 @@ spring:
         connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
       datasource:
         master:
-          url: jdbc:mysql://39.106.184.70:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
-          username: hcst
-          password: test@20190531
+          url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
+          username: root
+          password: 123456
           driver-class-name: com.mysql.jdbc.Driver
           # 多数据源配置
           #multi-datasource1:

+ 3 - 3
jeecg-boot-module-system/src/main/resources/jeecg/jeecg_database.properties

@@ -1,8 +1,8 @@
 #mysql
 diver_name=com.mysql.jdbc.Driver
-url=jdbc:mysql://39.106.184.70:3306/jeecg-boot?useUnicode=true&characterEncoding=UTF-8
-username=hcst
-password=test@20190531
+url=jdbc:mysql://127.0.0.1:3306/jeecg-boot?useUnicode=true&characterEncoding=UTF-8
+username=root
+password=123456
 database_name=jeecg-boot
 #oracle
 #diver_name=oracle.jdbc.driver.OracleDriver

+ 274 - 0
module-common/src/main/java/cn/com/ctop/common/module/controller/ProductController.java

@@ -0,0 +1,274 @@
+package cn.com.ctop.common.module.controller;
+
+import cn.com.ctop.common.module.annotation.AutoLog;
+import cn.com.ctop.common.module.entity.Product;
+import cn.com.ctop.common.module.service.IProductService;
+import cn.com.ctop.common.module.utils.Check;
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 产品表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-09-08
+ */
+@Slf4j
+@Api(tags = "产品表")
+@RestController
+@RequestMapping("/ctop/product")
+public class ProductController {
+    @Autowired
+    private IProductService productService;
+
+    /**
+     * 分页列表查询
+     *
+     * @param product
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @AutoLog(value = "产品表-分页列表查询")
+    @ApiOperation(value = "产品表-分页列表查询", notes = "产品表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<Product>> queryPageList(Product product,
+                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                HttpServletRequest req) {
+        Result<IPage<Product>> result = new Result<>();
+        QueryWrapper<Product> queryWrapper = QueryGenerator.initQueryWrapper(product, req.getParameterMap());
+        Page<Product> page = new Page<Product>(pageNo, pageSize);
+        IPage<Product> pageList = productService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+
+    @AutoLog(value = "产品表-分页列表查询")
+    @ApiOperation(value = "产品表-分页列表查询", notes = "产品表-分页列表查询")
+    @GetMapping(value = "/productList")
+    public Result<List<Product>> productList(Product product,
+                                             HttpServletRequest req) {
+        Result<List<Product>> result = new Result<>();
+        QueryWrapper<Product> queryWrapper = QueryGenerator.initQueryWrapper(product, req.getParameterMap());
+        List<Product> list = productService.list(queryWrapper);
+        if (!Check.isNull(list)) {
+            for (Product productVo : list) {
+                String userName = productService.getUserNameByUserId(productVo.getUserId());
+                if (!Check.isNull(userName)) {
+                    productVo.setUserName(userName);
+                }
+            }
+        }
+
+
+        result.setSuccess(true);
+        result.setResult(list);
+        return result;
+    }
+
+
+    /**
+     * 添加
+     *
+     * @param product
+     * @return
+     */
+    @AutoLog(value = "产品表-添加")
+    @ApiOperation(value = "产品表-添加", notes = "产品表-添加")
+    @PostMapping(value = "/add")
+    public Result<Product> add(@RequestBody Product product) {
+        Result<Product> result = new Result<>();
+        try {
+            productService.save(product);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+    /**
+     * 编辑
+     *
+     * @param product
+     * @return
+     */
+    @AutoLog(value = "产品表-编辑")
+    @ApiOperation(value = "产品表-编辑", notes = "产品表-编辑")
+    @PutMapping(value = "/edit")
+    public Result<Product> edit(@RequestBody Product product) {
+        Result<Product> result = new Result<Product>();
+        Product productEntity = productService.getById(product.getId());
+        if (productEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = productService.updateById(product);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过id删除
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "产品表-通过id删除")
+    @ApiOperation(value = "产品表-通过id删除", notes = "产品表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            productService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+    /**
+     * 批量删除
+     *
+     * @param ids
+     * @return
+     */
+    @AutoLog(value = "产品表-批量删除")
+    @ApiOperation(value = "产品表-批量删除", notes = "产品表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<Product> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<Product> result = new Result<>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.productService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+    /**
+     * 通过id查询
+     *
+     * @param id
+     * @return
+     */
+    @AutoLog(value = "产品表-通过id查询")
+    @ApiOperation(value = "产品表-通过id查询", notes = "产品表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<Product> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<Product> result = new Result<>();
+        Product product = productService.getById(id);
+        if (product == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(product);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    /**
+     * 导出excel
+     *
+     * @param request
+     * @param response
+     */
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+        // Step.1 组装查询条件
+        QueryWrapper<Product> queryWrapper = null;
+        try {
+            String paramsStr = request.getParameter("paramsStr");
+            if (oConvertUtils.isNotEmpty(paramsStr)) {
+                String deString = URLDecoder.decode(paramsStr, "UTF-8");
+                Product product = JSON.parseObject(deString, Product.class);
+                queryWrapper = QueryGenerator.initQueryWrapper(product, request.getParameterMap());
+            }
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+        }
+
+        //Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        List<Product> pageList = productService.list(queryWrapper);
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "产品表列表");
+        mv.addObject(NormalExcelConstants.CLASS, Product.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("产品表列表数据", "导出人:Jeecg", "导出信息"));
+        mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        return mv;
+    }
+
+    /**
+     * 通过excel导入数据
+     *
+     * @param request
+     * @param response
+     * @return
+     */
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
+        Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
+        for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
+            MultipartFile file = entity.getValue();
+            ImportParams params = new ImportParams();
+            params.setTitleRows(2);
+            params.setHeadRows(1);
+            params.setNeedSave(true);
+            try {
+                List<Product> listProducts = ExcelImportUtil.importExcel(file.getInputStream(), Product.class, params);
+                productService.saveBatch(listProducts);
+                return Result.ok("文件导入成功!数据行数:" + listProducts.size());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+                return Result.error("文件导入失败:" + e.getMessage());
+            } finally {
+                try {
+                    file.getInputStream().close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return Result.ok("文件导入失败!");
+    }
+
+}

+ 44 - 13
module-common/src/main/java/cn/com/ctop/common/module/entity/Product.java

@@ -1,44 +1,75 @@
 package cn.com.ctop.common.module.entity;
 
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
 
 import java.util.Date;
 
 /**
- * 产品
+ * 产品表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-09-08
  */
 @Data
+@TableName("ctop_product")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value = "ctop_product对象", description = "产品表")
 public class Product {
+
     /**
      * id
      */
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "id")
     private Long id;
     /**
-     * 产品名
+     * 产品名
      */
+    @Excel(name = "产品名", width = 15)
+    @ApiModelProperty(value = "产品名")
     private String productName;
     /**
-     * 广告主id
+     * advertiserId
      */
+    @Excel(name = "advertiserId", width = 15)
+    @ApiModelProperty(value = "advertiserId")
     private String advertiserId;
-
-    private String advertiserName;
-
     /**
      * 创建人
      */
-    private String createUserId;
-
+    @Excel(name = "创建人", width = 15)
+    @ApiModelProperty(value = "创建人")
+    private String userId;
     /**
-     * 媒体类型
+     * 1正常0删除
      */
-    private String mediaId;
-
+    @Excel(name = "1正常0删除", width = 15)
+    @ApiModelProperty(value = "1正常0删除")
+    private Integer productStatus;
     /**
-     * 创建时间
+     * createTime
      */
+    @ApiModelProperty(value = "createTime")
     private Date createTime;
-
+    /**
+     * updateTime
+     */
+    @ApiModelProperty(value = "updateTime")
     private Date updateTime;
 
+    @TableField(exist = false)
+    private String userName;
+
+
 }

+ 8 - 40
module-common/src/main/java/cn/com/ctop/common/module/mapper/ProductMapper.java

@@ -1,49 +1,17 @@
 package cn.com.ctop.common.module.mapper;
 
-import cn.com.ctop.common.module.entity.Advertiser;
 import cn.com.ctop.common.module.entity.Product;
-import cn.com.ctop.common.module.entity.Project;
-import cn.com.ctop.common.module.vo.*;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.apache.ibatis.annotations.Param;
 
-import java.util.List;
-
-
+/**
+ * 产品表
+ *
+ * @author: jeecg-boot
+ * @date: 2020-09-08
+ * @cersion: V1.0
+ */
 public interface ProductMapper extends BaseMapper<Product> {
 
-    Long insertProduct(@Param("product") ProductVO product);
-
-    List<Advertiser> getAdvertiserList();
-
-    List<Project> getProjectListByAdvertiserId(@Param("advertiserId")String advertiserId);
-
-    List<ProductDto> getYunyingListByProjectIds(@Param("projectIds")List<Long> projectIds);
-
-    List<ProductDto> getSaleListByProjectIds(@Param("projectIds")List<Long> projectIds);
-
-    void logicDeleteProductById(@Param("id")Long id);
-
-    void deleteProductProjectMapByProductId(@Param("id")Long ProductId);
-
-    void insertProductProjectMap(@Param("projectIds")List<Long> projectIds, @Param("productId")Long productId);
-
-    Integer getProductNameCount(@Param("productName")String productName);
-
-    void updateProduct(@Param("product")ProductVO product);
-
-    Product getProductInfo(@Param("id")Long id);
-
-    List<ProjectVO> getProjectListByProductId(@Param("productId")Long productId);
-
-    List<Long> getProjectIdsByProductId(@Param("productId")Long productId);
-
-    void deleteByProjectIdAndProductId(@Param("productId")Long productId, @Param("projectId")Long projectId);
-
-    List<ProductVO> getProductList(@Param("advertiserName")String advertiserName, @Param("productName")String productName);
-
-    List<SaleVO> getSalesListByProductId(@Param("productId")Long productId);
-
-    List<UserDto> getYunyingListByProductId(@Param("productId")Long productId);
-
+    String getUserNameByUserId(@Param("userId") String userId);
 }

+ 4 - 224
module-common/src/main/java/cn/com/ctop/common/module/mapper/xml/ProductMapper.xml

@@ -2,229 +2,9 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.common.module.mapper.ProductMapper">
 
-    <insert id="insertProduct" useGeneratedKeys="true" keyProperty="id">
-        insert into
-        ctop_product
-        (
-            product_name,
-            media_id,
-            advertiser_id,
-            advertiser_name,
-            create_user_id,
-            product_status
-        )values(
-            #{product.productName},
-            #{product.mediaId},
-            #{product.advertiserId},
-            #{product.advertiserName},
-            #{product.createUserId},
-            1
-        )
-    </insert>
-
-    <select id="getAdvertiserList" resultType="cn.com.ctop.common.module.entity.Advertiser">
-        select
-        id as id,
-        name as name
-        from
-        ctop_advertiser
-    </select>
-
-    <select id="getProjectListByAdvertiserId" resultType="cn.com.ctop.common.module.entity.Project">
-        select
-        id,
-        project_name as projectName,
-        media_id as mediaId
-        from
-        ctop_project
-        where
-        advertiser_id = #{advertiserId}
-        and media_id in (1,2)
-    </select>
-
-    <select id="getYunyingListByProjectIds" resultType="cn.com.ctop.common.module.vo.ProductDto">
-        select
-        distinct user_id as userId,
-        user_name as userName
-        from
-        ctop_user_allocation
-        where
-        project_id in
-        <foreach collection="projectIds" item="item" separator=","
-                 open="(" close=")">
-            #{item}
-        </foreach>
-
-    </select>
-
-    <select id="getSaleListByProjectIds" resultType="cn.com.ctop.common.module.vo.ProductDto">
-        select
-        distinct a.sale_id as saleId,
-        b.realname as saleName
-        from
-        ctop_project a
-        left join sys_user b on a.sale_id = b.id
-        where
-        a.id in
-        <foreach collection="projectIds" item="item" separator=","
-                       open="(" close=")">
-        #{item}
-        </foreach>
-    </select>
-
-    <update id="logicDeleteProductById">
-        update
-        ctop_product
-        set product_status = 0
-        where
-        id = #{id}
-    </update>
-
-    <delete id="deleteProductProjectMapByProductId">
-        delete
-        from
-        ctop_product_project_map
-        where
-        product_id  = #{id}
-    </delete>
-
-    <insert id="insertProductProjectMap">
-        insert into
-        ctop_product_project_map
-        (
-            product_id,
-            project_id
-        )
-        values
-        <foreach collection="projectIds" item="projectId" separator=",">
-            (
-             #{productId},
-             #{projectId}
-            )
-        </foreach>
-    </insert>
-
-    <select id="getProductNameCount" resultType="integer">
-        select
-        count(1)
-        from
-        ctop_product
-        where
-        product_name = #{productName}
-    </select>
-
-    <update id="updateProduct">
-        update
-        ctop_product
-        set
-        product_name = #{product.productName},
-        media_id = #{product.mediaId}
-      <!--  advertiser_id = #{product.advertiserId},
-        advertiser_name = #{product.advertiserName}  -->
-        where
-        id = #{product.id}
-    </update>
-
-    <select id="getProductInfo" resultType="cn.com.ctop.common.module.entity.Product">
-        select
-        id as id,
-        product_name as productName,
-        media_id as mediaId,
-        advertiser_id as advertiserId,
-        advertiser_name as advertiserName,
-        create_user_id as createUserId,
-        product_status as productStatus
-        from
-        ctop_product
-        where
-        id = #{id}
-    </select>
-
-    <select id="getProjectListByProductId" resultType="cn.com.ctop.common.module.vo.ProjectVO">
-        select
-        a.project_id as projectId,
-        b.project_name as projectName
-        from
-        ctop_product_project_map a
-        left join ctop_project b on a.project_id = b.id
-        where
-        a.product_id = #{productId}
+    <select id="getUserNameByUserId" resultType="java.lang.String">
+     select  realname  from sys_user
+     where  id = #{userId}
     </select>
 
-    <select id="getProjectIdsByProductId" resultType="Long">
-        select
-        a.project_id as projectId
-        from
-        ctop_product_project_map a
-        left join ctop_project b on a.project_id = b.id
-        where
-        a.product_id = #{productId}
-    </select>
-
-
-
-
-    <select id="deleteByProjectIdAndProductId">
-        delete
-        from
-        ctop_product_project_map
-        where
-        project_id = #{projectId}
-        and
-        product_id = #{productId}
-    </select>
-
-    <select id="getProductList" resultType="cn.com.ctop.common.module.vo.ProductVO">
-            select
-            id as id,
-            product_name as productName,
-            media_id as mediaId,
-            advertiser_id as advertiserId,
-            advertiser_name as advertiserName,
-            create_user_id as createUserId,
-            product_status as productStatus
-        from
-        ctop_product
-        where
-        product_status = 1 and
-        <if test="advertiserName != null and advertiserName != '' ">
-            advertiser_name like concat('%', #{advertiserName},'%') and
-        </if>
-        <if test="productName != null and productName != '' ">
-            product_name like concat('%', #{productName}, '%') and
-        </if>
-        1=1
-    </select>
-
-    <select id="getSalesListByProductId" resultType="cn.com.ctop.common.module.vo.SaleVO">
-        select
-        distinct b.sale_id as saleId,
-        c.realname as saleName
-        from
-        ctop_product_project_map a
-        left join (select id,project_name,sale_id from ctop_project) b on a.project_id = b.id
-        left join sys_user c on b.sale_id = c.id
-        where
-        product_id = #{productId}
-    </select>
-
-    <select id="getYunyingListByProductId" resultType="cn.com.ctop.common.module.vo.UserDto">
-        select
-        distinct user_id as userId,
-        user_name as realname
-        from
-        ctop_user_allocation a
-        where
-        project_id in (
-        select project_id
-        from
-        ctop_product_project_map
-        where product_id = #{productId}
-        )
-
-    </select>
-
-
-
-
-</mapper>
+</mapper>

+ 5 - 38
module-common/src/main/java/cn/com/ctop/common/module/service/IProductService.java

@@ -1,48 +1,15 @@
 package cn.com.ctop.common.module.service;
 
-import cn.com.ctop.common.module.entity.Advertiser;
 import cn.com.ctop.common.module.entity.Product;
-import cn.com.ctop.common.module.entity.Project;
-import cn.com.ctop.common.module.vo.ProductVO;
-import cn.com.ctop.common.module.vo.ProjectVO;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.github.pagehelper.PageInfo;
-import org.apache.ibatis.annotations.Param;
-
-import java.util.List;
-import java.util.Map;
 
 /**
- * 项目
- *
- * @author jeecg-boot
- * @version V1.0
- * @date 2019-11-19
+ * @Description: 产品表
+ * @Author: jeecg-boot
+ * @Date: 2020-09-08
+ * @Version: V1.0
  */
 public interface IProductService extends IService<Product> {
 
-    List<Advertiser> advertiserList();
-
-    List<Project> getProjectListByAdvertiserId(String advertiserId);
-
-    Map<String,Object> getSaleAndYunyingListByProjectIds(List<Long> projectIds);
-
-    void deleteProduct(Long id);
-
-    void insertOrUpdateProduct(ProductVO product);
-
-    Integer getProductNameCount(String productName);
-
-    void insertProductProjectMap(Long productId, List<Long> projectIds);
-
-    Map<String, Object> getProductInfo(Long productId);
-
-    void deleteByProjectIdAndProductId(Long projectId, Long productId);
-
-    List<ProjectVO> getProjectListByProductId(Long productId);
-
-    PageInfo<ProductVO> getProductList(String advertiserName, String productName, Integer pageNum, Integer pageSize);
-
-    List<Long> getProjectIdsByProductId(Long productId);
-
+    String getUserNameByUserId(String userId);
 }

+ 9 - 137
module-common/src/main/java/cn/com/ctop/common/module/service/impl/ProductServiceImpl.java

@@ -1,154 +1,26 @@
 package cn.com.ctop.common.module.service.impl;
 
-import cn.com.ctop.common.module.entity.Advertiser;
 import cn.com.ctop.common.module.entity.Product;
-import cn.com.ctop.common.module.entity.Project;
 import cn.com.ctop.common.module.mapper.ProductMapper;
 import cn.com.ctop.common.module.service.IProductService;
-import cn.com.ctop.common.module.vo.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.github.pagehelper.PageHelper;
-import com.github.pagehelper.PageInfo;
-import org.apache.ibatis.annotations.Param;
-import org.apache.shiro.SecurityUtils;
-import org.jeecg.common.system.vo.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-
+/**
+ * 产品表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2020-09-08
+ */
 @Service
 public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {
-
     @Autowired
     private ProductMapper productMapper;
 
     @Override
-    public List<Advertiser> advertiserList(){
-        return productMapper.getAdvertiserList();
-    }
-
-    @Override
-    public List<Project> getProjectListByAdvertiserId(String advertiserId){
-        return productMapper.getProjectListByAdvertiserId(advertiserId);
-    }
-
-    @Override
-    public Map<String,Object> getSaleAndYunyingListByProjectIds(List<Long> projectIds){
-        Map<String,Object> map = new HashMap<>();
-
-        List<ProductDto> saleList = productMapper.getSaleListByProjectIds(projectIds);
-        List<ProductDto> yunyingeList = productMapper.getYunyingListByProjectIds(projectIds);
-
-        map.put("saleList",saleList);
-        map.put("yunyingList",yunyingeList);
-
-        return map;
-    }
-
-    @Override
-    public void deleteProduct(Long id){
-        productMapper.logicDeleteProductById(id);
-    }
-
-    @Override
-    public void insertOrUpdateProduct(ProductVO product){
-        //更新
-        if(product.getId() != null){
-            //productMapper.deleteProductProjectMapByProductId(product.getId());
-            //if(product.getProjectIds() != null && product.getProjectIds().size() != 0 ){
-            //    productMapper.insertProductProjectMap(product.getProjectIds(), product.getId());
-            //}
-            productMapper.updateProduct(product);
-        }else { //入库
-            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-            product.setCreateUserId(sysUser.getId());
-            productMapper.insertProduct(product);
-
-            if(product.getProjectIds() != null && product.getProjectIds().size() != 0 ){
-                productMapper.insertProductProjectMap(product.getProjectIds(), product.getId());
-            }
-        }
-    }
-
-    @Override
-    public Integer getProductNameCount(String productName){
-        return productMapper.getProductNameCount(productName);
-    }
-
-    @Override
-    public void insertProductProjectMap(Long productId, List<Long> projectIds){
-        productMapper.insertProductProjectMap(projectIds, productId);
-    }
-
-  @Override
-    public Map<String, Object> getProductInfo(Long productId){
-        Map<String,Object> map = new HashMap<>();
-
-        Product product = productMapper.getProductInfo(productId);
-        List<ProjectVO> projectList = productMapper.getProjectListByProductId(productId);
-
-        List<Long> projectIds = new ArrayList<>();
-        for(ProjectVO vo:projectList){
-            projectIds.add(vo.getProjectId());
-        }
-
-        List<ProductDto> saleList = productMapper.getSaleListByProjectIds(projectIds);
-        List<ProductDto> yunyingeList = productMapper.getYunyingListByProjectIds(projectIds);
-
-        map.put("saleList",saleList);
-        map.put("yunyingList",yunyingeList);
-        map.put("product",product);
-        map.put("projectList",projectList);
-
-        return map;
-    }
-
-    @Override
-    public void deleteByProjectIdAndProductId(Long projectId, Long productId){
-        productMapper.deleteByProjectIdAndProductId(productId, projectId);
-    }
-
-    @Override
-    public List<ProjectVO> getProjectListByProductId(Long productId){
-        return productMapper.getProjectListByProductId(productId);
-    }
-
-    @Override
-    public PageInfo<ProductVO> getProductList(String advertiserName, String productName, Integer pageNum, Integer pageSize){
-        PageHelper.startPage(pageNum, pageSize);
-        List<ProductVO> productList = productMapper.getProductList(advertiserName, productName);
-
-        for(ProductVO product:productList){
-            List<ProjectVO> projectListByProductId = productMapper.getProjectListByProductId(product.getId());
-            List<SaleVO> salesListByProductId = productMapper.getSalesListByProductId(product.getId());
-            List<UserDto> yunyingListByProductId = productMapper.getYunyingListByProductId(product.getId());
-            List<Long> projectIds = productMapper.getProjectIdsByProductId(product.getId());
-
-            product.setProjectIds(projectIds);
-            product.setProjectList(projectListByProductId);
-            product.setSaleList(salesListByProductId);
-            product.setYunyingList(yunyingListByProductId);
-        }
-
-        return new PageInfo<>(productList);
-
-    }
-
-    @Override
-    public List<Long> getProjectIdsByProductId(Long productId){
-
-        return productMapper.getProjectIdsByProductId(productId);
-
+    public String getUserNameByUserId(String userId) {
+        return productMapper.getUserNameByUserId(userId);
     }
-
-
-
-
-
-
 }

+ 0 - 25
module-common/src/main/java/cn/com/ctop/common/module/vo/ProductDto.java

@@ -1,25 +0,0 @@
-package cn.com.ctop.common.module.vo;
-
-import lombok.Data;
-
-import java.io.Serializable;
-import java.math.BigDecimal;
-
-@Data
-public class ProductDto implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    private String userId;
-
-    private String userName;
-
-    private String saleId;
-
-    private String saleName;
-
-    private Long projectId;
-
-    private String projectName;
-
-}

+ 0 - 28
module-common/src/main/java/cn/com/ctop/common/module/vo/ProductInfoDto.java

@@ -1,28 +0,0 @@
-package cn.com.ctop.common.module.vo;
-
-import com.github.pagehelper.PageInfo;
-import lombok.Data;
-
-import java.io.Serializable;
-import java.util.List;
-
-@Data
-public class ProductInfoDto extends PageInfo implements Serializable {
-
-    private static final long serialVersionUID = 1L;
-
-    private String advertiserId;
-
-    private List<Long> projectIds;
-
-    private Long productId;
-
-    private Long projectId;
-
-    private String advertiserName;
-
-    private String productName;
-
-    private Integer mediaId;
-
-}

+ 0 - 52
module-common/src/main/java/cn/com/ctop/common/module/vo/ProductVO.java

@@ -1,52 +0,0 @@
-package cn.com.ctop.common.module.vo;
-
-import lombok.Data;
-
-import java.util.Date;
-import java.util.List;
-
-/**
- * 产品
- */
-@Data
-public class ProductVO {
-    /**
-     * id
-     */
-    private Long id;
-    /**
-     * 产品名称
-     */
-    private String productName;
-    /**
-     * 广告主id
-     */
-    private String advertiserId;
-    private String advertiserName;
-
-    /**
-     * 创建人
-     */
-    private String createUserId;
-
-    /**
-     * 媒体类型
-     */
-    private String mediaId;
-
-    /**
-     * 创建时间
-     */
-    private Date createTime;
-
-    private Date updateTime;
-
-    private List<Long> projectIds;
-
-    private List<ProjectVO> projectList;
-
-    private List<SaleVO> saleList;
-
-    private List<UserDto> yunyingList;
-
-}