Explorar o código

根据表ctop_user_efficient_video_map生成对应基础文件

hcst_sunzhen %!s(int64=5) %!d(string=hai) anos
pai
achega
7a0ad48f5e

+ 24 - 0
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -887,5 +887,29 @@ public class DateUtils extends PropertyEditorSupport {
 
     }
 
+    /**
+     * 根据时间获取季度
+     * 1即Q1(1,2,3月),以此类推
+     * @param date
+     * @return
+     */
+    public static int getQuarter(Date date){
+        Calendar cal = Calendar.getInstance();
+        cal.setTime(date);
+        //获取当前月份
+        int month = cal.get(Calendar.MONDAY+1);
+        if(month<=3){
+            return 1;
+        }else if(month <=6){
+            return 2;
+        }else if(month<=9){
+            return 3;
+        }else if(month<=12){
+            return 4;
+        }
+
+        return 0;
+    }
+
 
 }

+ 243 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/controller/UserEfficientVideoMapController.java

@@ -0,0 +1,243 @@
+package cn.com.ctop.userefficientvideomap.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.util.oConvertUtils;
+import cn.com.ctop.userefficientvideomap.entity.UserEfficientVideoMap;
+import cn.com.ctop.userefficientvideomap.service.IUserEfficientVideoMapService;
+import java.util.Date;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+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 com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+ /**
+ * 有效视频与角色对应表
+ * @author jeecg-boot
+ * @date   2019-12-16
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="有效视频与角色对应表")
+@RestController
+@RequestMapping("/userefficientvideomap/userEfficientVideoMap")
+public class UserEfficientVideoMapController {
+	@Autowired
+	private IUserEfficientVideoMapService userEfficientVideoMapService;
+	
+	/**
+	  * 分页列表查询
+	 * @param userEfficientVideoMap
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "有效视频与角色对应表-分页列表查询")
+	@ApiOperation(value="有效视频与角色对应表-分页列表查询", notes="有效视频与角色对应表-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<UserEfficientVideoMap>> queryPageList(UserEfficientVideoMap userEfficientVideoMap,
+									  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+									  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+									  HttpServletRequest req) {
+		Result<IPage<UserEfficientVideoMap>> result = new Result<IPage<UserEfficientVideoMap>>();
+		QueryWrapper<UserEfficientVideoMap> queryWrapper = QueryGenerator.initQueryWrapper(userEfficientVideoMap, req.getParameterMap());
+		Page<UserEfficientVideoMap> page = new Page<UserEfficientVideoMap>(pageNo, pageSize);
+		IPage<UserEfficientVideoMap> pageList = userEfficientVideoMapService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+	
+	/**
+	  *   添加
+	 * @param userEfficientVideoMap
+	 * @return
+	 */
+	@AutoLog(value = "有效视频与角色对应表-添加")
+	@ApiOperation(value="有效视频与角色对应表-添加", notes="有效视频与角色对应表-添加")
+	@PostMapping(value = "/add")
+	public Result<UserEfficientVideoMap> add(@RequestBody UserEfficientVideoMap userEfficientVideoMap) {
+		Result<UserEfficientVideoMap> result = new Result<UserEfficientVideoMap>();
+		try {
+			userEfficientVideoMapService.save(userEfficientVideoMap);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+	
+	/**
+	  *  编辑
+	 * @param userEfficientVideoMap
+	 * @return
+	 */
+	@AutoLog(value = "有效视频与角色对应表-编辑")
+	@ApiOperation(value="有效视频与角色对应表-编辑", notes="有效视频与角色对应表-编辑")
+	@PutMapping(value = "/edit")
+	public Result<UserEfficientVideoMap> edit(@RequestBody UserEfficientVideoMap userEfficientVideoMap) {
+		Result<UserEfficientVideoMap> result = new Result<UserEfficientVideoMap>();
+		UserEfficientVideoMap userEfficientVideoMapEntity = userEfficientVideoMapService.getById(userEfficientVideoMap.getId());
+		if(userEfficientVideoMapEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = userEfficientVideoMapService.updateById(userEfficientVideoMap);
+			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 {
+			userEfficientVideoMapService.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<UserEfficientVideoMap> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<UserEfficientVideoMap> result = new Result<UserEfficientVideoMap>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.userEfficientVideoMapService.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<UserEfficientVideoMap> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<UserEfficientVideoMap> result = new Result<UserEfficientVideoMap>();
+		UserEfficientVideoMap userEfficientVideoMap = userEfficientVideoMapService.getById(id);
+		if(userEfficientVideoMap==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(userEfficientVideoMap);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+
+  /**
+      * 导出excel
+   *
+   * @param request
+   * @param response
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, HttpServletResponse response) {
+      // Step.1 组装查询条件
+      QueryWrapper<UserEfficientVideoMap> queryWrapper = null;
+      try {
+          String paramsStr = request.getParameter("paramsStr");
+          if (oConvertUtils.isNotEmpty(paramsStr)) {
+              String deString = URLDecoder.decode(paramsStr, "UTF-8");
+              UserEfficientVideoMap userEfficientVideoMap = JSON.parseObject(deString, UserEfficientVideoMap.class);
+              queryWrapper = QueryGenerator.initQueryWrapper(userEfficientVideoMap, request.getParameterMap());
+          }
+      } catch (UnsupportedEncodingException e) {
+          e.printStackTrace();
+      }
+
+      //Step.2 AutoPoi 导出Excel
+      ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+      List<UserEfficientVideoMap> pageList = userEfficientVideoMapService.list(queryWrapper);
+      //导出文件名称
+      mv.addObject(NormalExcelConstants.FILE_NAME, "有效视频与角色对应表列表");
+      mv.addObject(NormalExcelConstants.CLASS, UserEfficientVideoMap.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<UserEfficientVideoMap> listUserEfficientVideoMaps = ExcelImportUtil.importExcel(file.getInputStream(), UserEfficientVideoMap.class, params);
+              userEfficientVideoMapService.saveBatch(listUserEfficientVideoMaps);
+              return Result.ok("文件导入成功!数据行数:" + listUserEfficientVideoMaps.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("文件导入失败!");
+  }
+
+}

+ 65 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/UserEfficientVideoMap.java

@@ -0,0 +1,65 @@
+package cn.com.ctop.userefficientvideomap.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * 有效视频与角色对应表
+ * @author jeecg-boot
+ * @date   2019-12-16
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_user_efficient_video_map")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_user_efficient_video_map对象", description="有效视频与角色对应表")
+public class UserEfficientVideoMap {
+
+	/**id*/
+	@TableId(type = IdType.UUID)
+    @ApiModelProperty(value = "id")
+	private Integer id;
+	/**有效视频md5*/
+	@Excel(name = "有效视频md5", width = 15)
+    @ApiModelProperty(value = "有效视频md5")
+	private String efficientVideoSignature;
+	/**角色id*/
+	@Excel(name = "角色id", width = 15)
+    @ApiModelProperty(value = "角色id")
+	private String roleId;
+	/**用户id*/
+	@Excel(name = "用户id", width = 15)
+    @ApiModelProperty(value = "用户id")
+	private String userId;
+	/**季度*/
+	@Excel(name = "季度", width = 15)
+    @ApiModelProperty(value = "季度")
+	private Integer quarter;
+	/**年*/
+	@Excel(name = "年", width = 15)
+    @ApiModelProperty(value = "年")
+	private Integer year;
+	/**媒体类型1_快手2_头条*/
+	@Excel(name = "媒体类型1_快手2_头条", width = 15)
+    @ApiModelProperty(value = "媒体类型1_快手2_头条")
+	private Integer appType;
+	/**createTime*/
+    @ApiModelProperty(value = "createTime")
+	private Date createTime;
+	/**updateTime*/
+    @ApiModelProperty(value = "updateTime")
+	private Date updateTime;
+}

+ 17 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/UserEfficientVideoMapMapper.java

@@ -0,0 +1,17 @@
+package cn.com.ctop.userefficientvideomap.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import cn.com.ctop.userefficientvideomap.entity.UserEfficientVideoMap;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 有效视频与角色对应表
+ * @author: jeecg-boot
+ * @date:   2019-12-16
+ * @cersion: V1.0
+ */
+public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVideoMap> {
+
+}

+ 5 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/xml/UserEfficientVideoMapMapper.xml

@@ -0,0 +1,5 @@
+<?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="cn.com.ctop.userefficientvideomap.mapper.UserEfficientVideoMapMapper">
+
+</mapper>

+ 14 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/service/IUserEfficientVideoMapService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.userefficientvideomap.service;
+
+import cn.com.ctop.userefficientvideomap.entity.UserEfficientVideoMap;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 有效视频与角色对应表
+ * @author jeecg-boot
+ * @date   2019-12-16
+ * @version V1.0
+ */
+public interface IUserEfficientVideoMapService extends IService<UserEfficientVideoMap> {
+
+}

+ 19 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/service/impl/UserEfficientVideoMapServiceImpl.java

@@ -0,0 +1,19 @@
+package cn.com.ctop.userefficientvideomap.service.impl;
+
+import cn.com.ctop.userefficientvideomap.entity.UserEfficientVideoMap;
+import cn.com.ctop.userefficientvideomap.mapper.UserEfficientVideoMapMapper;
+import cn.com.ctop.userefficientvideomap.service.IUserEfficientVideoMapService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * 有效视频与角色对应表
+ * @author jeecg-boot
+ * @date   2019-12-16
+ * @version V1.0
+ */
+@Service
+public class UserEfficientVideoMapServiceImpl extends ServiceImpl<UserEfficientVideoMapMapper, UserEfficientVideoMap> implements IUserEfficientVideoMapService {
+
+}