Commit 3df84b21 authored by 陈祥烨's avatar 陈祥烨

导入

parent d9192645
......@@ -32,6 +32,46 @@
</dependency>
<!-- easy-poi -->
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-base</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-web</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>cn.afterturn</groupId>
<artifactId>easypoi-annotation</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>2.0.5</version>
<exclusions>
<exclusion>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.7</version>
</dependency>
<!-- JSON -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.67_noneautotype2</version>
</dependency>
<dependency>
<groupId>org.typroject</groupId>
<artifactId>tyboot-core-foundation</artifactId>
......
package com.yeejoin.amos.api.tool.controller;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.api.tool.face.model.FileImportModel;
import com.yeejoin.amos.api.tool.face.model.TplModel;
import com.yeejoin.amos.api.tool.face.model.TplVoModel;
import com.yeejoin.amos.api.tool.face.service.TplService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
......@@ -31,11 +37,14 @@ public class TplResource {
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@PostMapping(value = "/save")
@ApiOperation(httpMethod = "POST", value = "新增", notes = "新增")
public ResponseModel<TplModel> save(@RequestBody TplModel tplModel) throws Exception{
tplModel.setIsDel(false);
tplModel.setDisplayName(tplModel.getComName());
public ResponseModel<TplModel> save(@RequestBody TplVoModel tplVoModel) throws Exception{
tplVoModel.setIsDel(false);
tplVoModel.setDisplayName(tplVoModel.getComName());
TplModel tplModel = new TplModel();
BeanUtils.copyProperties(tplVoModel,tplModel,"thumbs","sketches");
tplModel.setThumb(tplVoModel.getThumbs().get(0).getUrl());
tplModel.setSketch(tplVoModel.getSketches().get(0).getUrl());
tplModel = tplService.createWithModel(tplModel);
System.out.println(tplModel.getThumb());
return ResponseHelper.buildResponse(tplModel);
}
/**
......@@ -77,17 +86,17 @@ public class TplResource {
/**
* 列表分页查询
*@param current 当前页
*@param current 每页大小
*@param size 每页大小
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "分页查询", notes = "分页查询")
public ResponseModel<Page<TplModel>> queryForPage(@RequestParam(value = "current") int current, @RequestParam(value = "size") int size,@RequestParam(value = "categorySeq")Long categorySeq){
Page<TplModel> page = new Page<TplModel>();
public ResponseModel<Page<TplModel>> queryForPage(@RequestParam(value = "current") int current, @RequestParam(value = "size") int size,@RequestParam(value = "categorySeq")Long categorySeq,@RequestParam(value = "displayName")String displayName){
Page<TplModel> page = new Page<>();
page.setCurrent(current);
page.setSize(size);
return ResponseHelper.buildResponse(tplService.queryForTplPage(page,categorySeq));
return ResponseHelper.buildResponse(tplService.queryForTplPage(page, categorySeq, displayName));
}
/**
*列表全部数据查询
......@@ -99,4 +108,27 @@ public class TplResource {
public ResponseModel<List<TplModel>> selectForList(){
return ResponseHelper.buildResponse(tplService.queryForTplList());
}
/**
*导入
*@return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(httpMethod = "POST",value = "导入", notes = "导入")
@PostMapping(value = "/import")
public ResponseModel<List<FileImportModel>> importTpl(@RequestParam("file") MultipartFile multipartFile) throws Exception {
ImportParams params = new ImportParams();
// params.setHeadRows(0);
params.setTitleRows(0);
List<FileImportModel> fileImportModels =
ExcelImportUtil.importExcel(multipartFile.getInputStream(), FileImportModel.class, params);
for(FileImportModel fileImportModel:fileImportModels){
TplModel tplModel = new TplModel();
BeanUtils.copyProperties(fileImportModel,tplModel);
tplModel = tplService.createWithModel(tplModel);
}
System.out.println(fileImportModels);
return ResponseHelper.buildResponse(fileImportModels);
}
}
package com.yeejoin.amos.api.tool.face.model;
import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import java.util.Date;
@Data
public class FileImportModel {
@Excel(name = "SEQUENCE_NBR")
private Long sequenceNbr;
@Excel(name = "DISPLAY_NAME")
private String displayName;
@Excel(name = "COMPONENT_KEY")
private String comKey;
@Excel(name = "COMPONENT_NAME")
private String comName;
@Excel(name = "CONTENT")
private String content;
@Excel(name = "CATEGORY_SEQ")
private Long cateSeq;
@Excel(name = "THUMB")
private String thumb;
@Excel(name = "SKETCH")
private String sketch;
@Excel(name = "IS_DELETE")
private Boolean isDel;
@Excel(name = "OPEN_STATUS")
private Boolean openStatus;
@Excel(name = "REC_DATE",format = "yyyy-MM-dd HH:mm:ss")
private Date recDate;
@Excel(name = "REC_USER_ID")
private String recUserId;
private String fileName;
}
package com.yeejoin.amos.api.tool.face.model;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class PicModel {
private String name;
private String uid;
private String url;
private String status;
}
......@@ -4,52 +4,29 @@ import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="TplCateModel", description="")
public class TplModel extends BaseModel {
@ApiModelProperty(value = "展示名称")
private String displayName;
@ApiModelProperty(value = "模板标识")
private String comKey;
@ApiModelProperty(value = "模板名称")
private String comName;
@ApiModelProperty(value = "模板内容")
private String content;
@ApiModel(value="TplModel", description="")
public class TplModel extends TplVoModel {
@ApiModelProperty(value = "分类ID")
private String cateSeq;
@ApiModelProperty(value = "模板状态")
private Boolean openStatus;
@ApiModelProperty(value = "缩略图")
private MultipartFile thumb;
private String thumb;
@ApiModelProperty(value = "效果图")
private String sketch;
@ApiModelProperty(value = "是否删除")
private Boolean isDel;
public void setIsDel(Boolean isDel) {
this.isDel = isDel;
}
public String getComName() {
return comName;
public void setThumb(String thumb) {
this.thumb = thumb ;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
public void setSketch(String sketch) {
this.sketch = sketch;
}
}
package com.yeejoin.amos.api.tool.face.model;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.ArrayList;
import java.util.List;
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="TplVoModel", description="")
@JsonIgnoreProperties({"hibernateLazyInitializer","handler"})
public class TplVoModel extends BaseModel {
@ApiModelProperty(value = "展示名称")
public String displayName;
@ApiModelProperty(value = "模板标识")
public String comKey;
@ApiModelProperty(value = "模板名称")
public String comName;
@ApiModelProperty(value = "模板内容")
public String content;
@ApiModelProperty(value = "分类ID")
public Long cateSeq;
@ApiModelProperty(value = "模板状态")
public Boolean openStatus;
@ApiModelProperty(value = "缩略图")
private List<PicModel> thumbs = new ArrayList<>();
@ApiModelProperty(value = "效果图")
private List<PicModel> sketches = new ArrayList<>();
@ApiModelProperty(value = "是否删除")
public Boolean isDel;
public void setIsDel(Boolean isDel) {
this.isDel = isDel;
}
public String getComName() {
return comName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
}
package com.yeejoin.amos.api.tool.face.orm.entity;
import com.baomidou.mybatisplus.annotation.SqlCondition;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
......@@ -17,7 +18,7 @@ public class Tpl extends BaseEntity {
/**
*展示名称
*/
@TableField("DISPLAY_NAME")
@TableField(value = "DISPLAY_NAME",condition = SqlCondition.LIKE)
private String displayName;
/**
......@@ -42,7 +43,7 @@ public class Tpl extends BaseEntity {
*分类ID
*/
@TableField("CATEGORY_SEQ")
private String cateSeq;
private Long cateSeq;
/**
*模板状态
......@@ -54,7 +55,7 @@ public class Tpl extends BaseEntity {
*缩略图
*/
@TableField("THUMB")
private String[] thumb;
private String thumb;
/**
*状态图
......
......@@ -14,8 +14,8 @@ public class TplService extends BaseService<TplModel, Tpl, TplMapper> {
/**
* 分页查询
*/
public Page<TplModel> queryForTplPage(Page<TplModel> page, Long categorySeq) {
return this.queryForPage(page, null, false, categorySeq);
public Page<TplModel> queryForTplPage(Page<TplModel> page, Long categorySeq, String displayName) {
return this.queryForPage(page, null, false, categorySeq, displayName);
}
/**
......@@ -25,4 +25,6 @@ public class TplService extends BaseService<TplModel, Tpl, TplMapper> {
return this.queryForList("" , false);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment