17 changed files with 450 additions and 10 deletions
@ -0,0 +1,56 @@ |
|||
package com.ccsens.page.api; |
|||
|
|||
import com.ccsens.page.bean.dto.PageDto; |
|||
import com.ccsens.page.bean.dto.QueryDto; |
|||
import com.ccsens.page.bean.vo.PageInfoVo; |
|||
import com.ccsens.page.bean.vo.PageVo; |
|||
import com.ccsens.page.service.IPageService; |
|||
import com.ccsens.page.util.JsonResponse; |
|||
import io.swagger.annotations.ApiImplicitParams; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiOperation; |
|||
import io.swagger.annotations.ApiParam; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.validation.annotation.Validated; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
import org.springframework.web.bind.annotation.RequestMapping; |
|||
import org.springframework.web.bind.annotation.RequestMethod; |
|||
import org.springframework.web.bind.annotation.RestController; |
|||
|
|||
import javax.annotation.Resource; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/9/15 11:10 |
|||
*/ |
|||
@Slf4j |
|||
@RestController |
|||
@RequestMapping("/page") |
|||
public class PageController { |
|||
|
|||
@Resource |
|||
private IPageService pageService; |
|||
|
|||
@ApiOperation(value = "/项目列表",notes = "") |
|||
@ApiImplicitParams({ |
|||
}) |
|||
@RequestMapping(value="list",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse<PageVo.Detail> list(@ApiParam @Validated @RequestBody QueryDto<PageDto.Query> dto) { |
|||
log.info("项目列表:{}", dto); |
|||
PageInfoVo<PageVo.Detail> list = pageService.list(dto.getParam(), dto.getUserId()); |
|||
log.info("项目列表结果:{}", list); |
|||
return JsonResponse.newInstance().ok(list); |
|||
} |
|||
|
|||
@ApiOperation(value = "/添加项目",notes = "") |
|||
@ApiImplicitParams({ |
|||
}) |
|||
@RequestMapping(value="add",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"}) |
|||
public JsonResponse add(@ApiParam @Validated @RequestBody QueryDto<PageDto.Detail> dto) { |
|||
log.info("添加项目:{}", dto); |
|||
pageService.add(dto.getParam(), dto.getUserId()); |
|||
log.info("添加项目结果:{}"); |
|||
return JsonResponse.newInstance().ok(); |
|||
} |
|||
} |
@ -0,0 +1,31 @@ |
|||
package com.ccsens.page.bean.dto; |
|||
|
|||
import com.ccsens.page.bean.po.Project; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/9/15 11:14 |
|||
*/ |
|||
public class PageDto { |
|||
|
|||
@ApiModel("查询-请求") |
|||
@Data |
|||
public static class Query{ |
|||
@ApiModelProperty("页码") |
|||
private int pageNum; |
|||
@ApiModelProperty("每页几条") |
|||
private int pageSize; |
|||
// @ApiModelProperty("查询方向 -1:向前 1:向后")
|
|||
// private byte direction;
|
|||
} |
|||
|
|||
@ApiModel("添加项目-请求") |
|||
@Data |
|||
public static class Detail extends Project { |
|||
|
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
package com.ccsens.page.bean.dto; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import javax.validation.Valid; |
|||
|
|||
/** |
|||
* @program: ptpro |
|||
* @description: 编辑病人信息 |
|||
* @author: wu huijuan |
|||
* @create: 2019/10/30 14:33 |
|||
*/ |
|||
@ApiModel |
|||
@Data |
|||
public class QueryDto<T> { |
|||
@ApiModelProperty("真正的请求参数") |
|||
@Valid |
|||
private T param; |
|||
@ApiModelProperty("登录用户ID 前端不为userId赋值") |
|||
private Long userId; |
|||
@ApiModelProperty("用户名") |
|||
private String userName; |
|||
@ApiModelProperty("头像") |
|||
private String avatarUrl; |
|||
} |
@ -0,0 +1,133 @@ |
|||
package com.ccsens.page.bean.po; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/9/15 11:32 |
|||
*/ |
|||
@ApiModel("项目") |
|||
@Data |
|||
public class Project { |
|||
// private Long _id;
|
|||
private String logo; |
|||
private String name; |
|||
private Db db; |
|||
private List<Page> pages; |
|||
|
|||
|
|||
@Data |
|||
@ApiModel("数据库配置") |
|||
public static class Db{ |
|||
// private Long _id;
|
|||
@ApiModelProperty("类型 1:mysql") |
|||
private byte type; |
|||
} |
|||
@Data |
|||
@ApiModel("页面") |
|||
public static class Page{ |
|||
// private Long _id;
|
|||
@ApiModelProperty("标题") |
|||
private String title; |
|||
@ApiModelProperty("风格 0:表格 1:手风琴") |
|||
private byte style; |
|||
@ApiModelProperty("搜索条件") |
|||
private List<Search> searches; |
|||
@ApiModelProperty("表头属性") |
|||
private List<DataField> fields; |
|||
@ApiModelProperty("SQL") |
|||
private String sql; |
|||
@ApiModelProperty("操作") |
|||
private List<Operate> operates; |
|||
} |
|||
|
|||
@ApiModel("搜索条件") |
|||
@Data |
|||
private static class Search { |
|||
// private Long _id;
|
|||
@ApiModelProperty("类型:0:文本 1:数字 2:多行文本 3:单选(待补充)") |
|||
private String type; |
|||
@ApiModelProperty("展示文字") |
|||
private String show; |
|||
@ApiModelProperty("变量名") |
|||
private String name; |
|||
@ApiModelProperty("选项") |
|||
private Option options; |
|||
} |
|||
|
|||
@ApiModel("选项") |
|||
@Data |
|||
private static class Option { |
|||
// private Long _id;
|
|||
@ApiModelProperty("选项获取类型 0:配置 1:接口查询") |
|||
private byte dataFetchType; |
|||
@ApiModelProperty("路径") |
|||
private String fetchUrl; |
|||
@ApiModelProperty("选项") |
|||
private List<OptionSingle> data; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("选项-单个") |
|||
private static class OptionSingle { |
|||
// private Long _id;
|
|||
@ApiModelProperty("提交") |
|||
private String key; |
|||
@ApiModelProperty("显示") |
|||
private String value; |
|||
} |
|||
|
|||
@Data |
|||
@ApiModel("数据属性") |
|||
private static class DataField { |
|||
// private Long _id;
|
|||
@ApiModelProperty("展示") |
|||
private String show; |
|||
@ApiModelProperty("类型:0:字段 1:操作 2:序号 ") |
|||
private byte type; |
|||
@ApiModelProperty("属性名") |
|||
private String field; |
|||
@ApiModelProperty("操作") |
|||
private List<Operate> operates; |
|||
} |
|||
@Data |
|||
@ApiModel("操作") |
|||
private static class Operate { |
|||
// private Long _id;
|
|||
private String icon; |
|||
@ApiModelProperty("展示") |
|||
private String show; |
|||
@ApiModelProperty("操作类型 0: 打开页面 1: 弹框询问 2: 下载 3: 上传") |
|||
private byte type; |
|||
@ApiModelProperty("路径") |
|||
private String url; |
|||
@ApiModelProperty("弹框") |
|||
private Dialogs dialogs; |
|||
} |
|||
|
|||
@ApiModel("弹框") |
|||
@Data |
|||
private static class Dialogs { |
|||
// private Long _id;
|
|||
@ApiModelProperty("弹框展示文本") |
|||
private String show; |
|||
@ApiModelProperty("按钮") |
|||
private List<DialogsButton> button; |
|||
} |
|||
|
|||
@ApiModel("弹框按钮") |
|||
@Data |
|||
private static class DialogsButton { |
|||
@ApiModelProperty("展示") |
|||
private String show; |
|||
@ApiModelProperty("接口") |
|||
public String url; |
|||
@ApiModelProperty("响应 0:结束 1: 接口调用") |
|||
public byte responseType; |
|||
} |
|||
} |
@ -0,0 +1,34 @@ |
|||
package com.ccsens.page.bean.vo; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Data; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/9/15 11:23 |
|||
*/ |
|||
@Data |
|||
@ApiModel("分页") |
|||
public class PageInfoVo<T> { |
|||
@ApiModelProperty("页码") |
|||
private int pageNum; |
|||
@ApiModelProperty("每页几条") |
|||
private int pageSize; |
|||
@ApiModelProperty("总页数") |
|||
private long total; |
|||
@ApiModelProperty("数据") |
|||
private List<T> list; |
|||
|
|||
public PageInfoVo(){} |
|||
|
|||
public PageInfoVo(int pageNum, int pageSize, long total, List<T> list) { |
|||
this.pageNum = pageNum; |
|||
this.pageSize = pageSize; |
|||
this.total = total; |
|||
this.list = list; |
|||
} |
|||
} |
@ -0,0 +1,18 @@ |
|||
package com.ccsens.page.bean.vo; |
|||
|
|||
import com.ccsens.page.bean.po.Project; |
|||
import io.swagger.annotations.ApiModel; |
|||
import lombok.Data; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/9/15 11:14 |
|||
*/ |
|||
public class PageVo { |
|||
@ApiModel |
|||
@Data |
|||
public static class Detail extends Project { |
|||
|
|||
} |
|||
} |
@ -0,0 +1,32 @@ |
|||
package com.ccsens.page.persist; |
|||
|
|||
import com.ccsens.page.bean.dto.PageDto; |
|||
import com.ccsens.page.bean.po.Project; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author whj |
|||
*/ |
|||
public interface IProjectDao { |
|||
|
|||
/** |
|||
* 查找项目 |
|||
* @param param 条件 |
|||
* @return 项目 |
|||
*/ |
|||
List<? super Project> list(PageDto.Query param); |
|||
|
|||
/** |
|||
* 统计项目 |
|||
* @param param 条件 |
|||
* @return 总数 |
|||
*/ |
|||
long count(PageDto.Query param); |
|||
|
|||
/** |
|||
* 添加项目 |
|||
* @param detail 项目详情 |
|||
*/ |
|||
void add(PageDto.Detail detail); |
|||
} |
@ -0,0 +1,42 @@ |
|||
package com.ccsens.page.persist; |
|||
|
|||
import com.ccsens.page.bean.dto.PageDto; |
|||
import com.ccsens.page.bean.po.Project; |
|||
import org.springframework.data.mongodb.core.MongoTemplate; |
|||
import org.springframework.data.mongodb.core.query.Criteria; |
|||
import org.springframework.data.mongodb.core.query.Query; |
|||
import org.springframework.stereotype.Repository; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author whj |
|||
*/ |
|||
@Repository |
|||
public class ProjectDao implements IProjectDao { |
|||
private static final String COLLECTION_PROJECT = "project"; |
|||
@Resource |
|||
private MongoTemplate mongoTemplate; |
|||
|
|||
@Override |
|||
public List<? super Project> list(PageDto.Query param) { |
|||
Query query = new Query(); |
|||
// TODO 分页待完善
|
|||
query.skip((param.getPageNum() - 1) * param.getPageSize()).limit(param.getPageSize()); |
|||
return mongoTemplate.find(query, Project.class); |
|||
} |
|||
|
|||
@Override |
|||
public long count(PageDto.Query param) { |
|||
Query query = new Query(); |
|||
// TODO 分页待完善
|
|||
query.skip((param.getPageNum() - 1) * param.getPageSize()).limit(param.getPageSize()); |
|||
return mongoTemplate.count(query, Project.class); |
|||
} |
|||
|
|||
@Override |
|||
public void add(PageDto.Detail detail) { |
|||
mongoTemplate.save(detail, COLLECTION_PROJECT); |
|||
} |
|||
} |
@ -0,0 +1,22 @@ |
|||
package com.ccsens.page.service; |
|||
|
|||
import com.ccsens.page.bean.dto.PageDto; |
|||
import com.ccsens.page.bean.vo.PageInfoVo; |
|||
import com.ccsens.page.bean.vo.PageVo; |
|||
|
|||
public interface IPageService { |
|||
/** |
|||
* 列表 |
|||
* @param param 请求参数 |
|||
* @param userId 操作人ID |
|||
* @return 项目列表 |
|||
*/ |
|||
PageInfoVo<PageVo.Detail> list(PageDto.Query param, Long userId); |
|||
|
|||
/** |
|||
* 添加项目 |
|||
* @param param 项目详情 |
|||
* @param userId 操作人ID |
|||
*/ |
|||
void add(PageDto.Detail param, Long userId); |
|||
} |
@ -0,0 +1,42 @@ |
|||
package com.ccsens.page.service; |
|||
|
|||
import com.ccsens.page.bean.dto.PageDto; |
|||
import com.ccsens.page.bean.po.Project; |
|||
import com.ccsens.page.bean.vo.PageInfoVo; |
|||
import com.ccsens.page.bean.vo.PageVo; |
|||
import com.ccsens.page.persist.IProjectDao; |
|||
import lombok.Data; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.data.mongodb.core.query.Criteria; |
|||
import org.springframework.data.mongodb.core.query.Query; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @description: |
|||
* @author: whj |
|||
* @time: 2021/9/15 11:29 |
|||
*/ |
|||
@Data |
|||
@Slf4j |
|||
@Service |
|||
public class PageService implements IPageService { |
|||
|
|||
@Resource |
|||
private IProjectDao projectDao; |
|||
|
|||
@Override |
|||
public PageInfoVo<PageVo.Detail> list(PageDto.Query param, Long userId) { |
|||
List<? super Project> list = projectDao.list(param); |
|||
long count = projectDao.count(param); |
|||
PageInfoVo vo = new PageInfoVo(param.getPageNum(), param.getPageSize(), count, list); |
|||
return vo; |
|||
} |
|||
|
|||
@Override |
|||
public void add(PageDto.Detail param, Long userId) { |
|||
projectDao.add(param); |
|||
} |
|||
} |
@ -1,4 +1,4 @@ |
|||
spring: |
|||
profiles: |
|||
active: dev |
|||
active: test |
|||
include: common |
|||
|
Loading…
Reference in new issue