尚筹网12发起项目

发起项目建模

创建数据库表

分类表

CREATE TABLE `t_type` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) DEFAULT NULL COMMENT '分类名称',
  `remark` varchar(255) DEFAULT NULL COMMENT '分类介绍',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

项目分类中间表

CREATE TABLE `t_project_type` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `projectid` int(11) DEFAULT NULL,
  `typeid` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=64 DEFAULT CHARSET=utf8;

标签表

CREATE TABLE `t_tag` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `pid` int(11) DEFAULT NULL,
  `name` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

项目标签中间表

CREATE TABLE `t_project_tag` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `projectid` int(11) DEFAULT NULL,
  `tagid` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=82 DEFAULT CHARSET=utf8;

项目表

CREATE TABLE `t_project` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_name` varchar(255) DEFAULT NULL COMMENT '项目名称',
  `project_description` varchar(255) DEFAULT NULL COMMENT '项目描述',
  `money` bigint(11) DEFAULT NULL COMMENT '筹集金额',
  `day` int(11) DEFAULT NULL COMMENT '筹集天数',
  `status` int(4) DEFAULT NULL COMMENT '0-即将开始,1-众筹中,2-众筹成功,3-众筹失败 ',
  `deploydate` varchar(10) DEFAULT NULL COMMENT '项目发起时间',
  `supportmoney` bigint(11) DEFAULT NULL COMMENT '已筹集到的金额',
  `supporter` int(11) DEFAULT NULL COMMENT '支持人数',
  `completion` int(3) DEFAULT NULL COMMENT '百分比完成度',
  `memberid` int(11) DEFAULT NULL COMMENT '发起人的会员 id',
  `createdate` varchar(19) DEFAULT NULL COMMENT '项目创建时间',
  `follower` int(11) DEFAULT NULL COMMENT '关注人数',
  `header_picture_path` varchar(255) DEFAULT NULL COMMENT '头图路径',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=utf8;

项目详情图片表

 

CREATE TABLE `t_project_item_pic` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `projectid` int(11) DEFAULT NULL,
  `item_pic_path` varchar(255) DEFAULT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=utf8;

 

项目发起人信息表

CREATE TABLE `t_member_launch_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `memberid` int(11) DEFAULT NULL COMMENT '会员 id',
  `description_simple` varchar(255) DEFAULT NULL COMMENT '简单介绍',
  `description_detail` varchar(255) DEFAULT NULL COMMENT '详细介绍',
  `phone_num` varchar(255) DEFAULT NULL COMMENT '联系电话',
  `service_num` varchar(255) DEFAULT NULL COMMENT '客服电话',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=utf8;

回报信息表

CREATE TABLE `t_return` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `projectid` int(11) DEFAULT NULL,
  `type` int(4) DEFAULT NULL COMMENT '0 - 实物回报, 1 虚拟物品回报',
  `supportmoney` int(11) DEFAULT NULL COMMENT '支持金额',
  `content` varchar(255) DEFAULT NULL COMMENT '回报内容',
  `count` int(11) DEFAULT NULL COMMENT '回报产品限额,“0”为不限回报数量',
  `signalpurchase` int(11) DEFAULT NULL COMMENT '是否设置单笔限购',
  `purchase` int(11) DEFAULT NULL COMMENT '具体限购数量',
  `freight` int(11) DEFAULT NULL COMMENT '运费,“0”为包邮',
  `invoice` int(4) DEFAULT NULL COMMENT '0 - 不开发票, 1 - 开发票',
  `returndate` int(11) DEFAULT NULL COMMENT '项目结束后多少天向支持者发送回报',
  `describ_pic_path` varchar(255) DEFAULT NULL COMMENT '说明图片路径',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=52 DEFAULT CHARSET=utf8;

发起人确认信息表

CREATE TABLE `t_member_confirm_info` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `memberid` int(11) DEFAULT NULL COMMENT '会员 id',
  `paynum` varchar(200) DEFAULT NULL COMMENT '易付宝企业账号',
  `cardnum` varchar(200) DEFAULT NULL COMMENT '法人身份证号',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;

逆向工程设置

 

 

尚筹网12发起项目_第1张图片


<table tableName="t_type" domainObjectName="TypePO" />
<table tableName="t_tag" domainObjectName="TagPO" />
<table tableName="t_project" domainObjectName="ProjectPO" />
<table tableName="t_project_item_pic" domainObjectName="ProjectItemPicPO" />
<table tableName="t_member_launch_info" domainObjectName="MemberLaunchInfoPO" /> 
<table tableName="t_return" domainObjectName="ReturnPO" /> 
<table tableName="t_member_confirm_info" domainObjectName="MemberConfirmInfoPO" /> 

创建VO对象

尚筹网12发起项目_第2张图片

projectVO

package com.example.entity.vo;
import java.io.Serializable;
import java.util.List;

public class ProjectVO implements Serializable {
    private static final long serialVersionUID = 1L;
    // 分类 id 集合
    private List typeIdList;
    // 标签 id 集合
    private List tagIdList;
    // 项目名称
    private String projectName;
    // 项目描述
    private String projectDescription;
    // 计划筹集的金额
    private Integer money;
    // 筹集资金的天数
    private Integer day;
    // 创建项目的日期
    private String createdate;
    // 头图的路径
    private String headerPicturePath;
    // 详情图片的路径
    private List detailPicturePathList;
    // 发起人信息
    private MemberLauchInfoVO memberLauchInfoVO;
    // 回报信息集合
    private List returnVOList;
    // 发起人确认信息
    private MemberConfirmInfoVO memberConfirmInfoVO;
    public ProjectVO() {
    }

    public ProjectVO(List typeIdList, List tagIdList, String projectName, String projectDescription, Integer money, Integer day, String createdate, String headerPicturePath, List detailPicturePathList, MemberLauchInfoVO memberLauchInfoVO, List returnVOList, MemberConfirmInfoVO memberConfirmInfoVO) {
        this.typeIdList = typeIdList;
        this.tagIdList = tagIdList;
        this.projectName = projectName;
        this.projectDescription = projectDescription;
        this.money = money;
        this.day = day;
        this.createdate = createdate;
        this.headerPicturePath = headerPicturePath;
        this.detailPicturePathList = detailPicturePathList;
        this.memberLauchInfoVO = memberLauchInfoVO;
        this.returnVOList = returnVOList;
        this.memberConfirmInfoVO = memberConfirmInfoVO;
    }
    }

MemberLaunchInfoVO

public class MemberLauchInfoVO implements Serializable {
    private static final long serialVersionUID = 1L;
    // 简单介绍
    private String descriptionSimple;
    // 详细介绍
    private String descriptionDetail;
    // 联系电话
    private String phoneNum;
    // 客服电话
    private String serviceNum;

    public MemberLauchInfoVO() {
    }

    public MemberLauchInfoVO(String descriptionSimple, String descriptionDetail, String phoneNum, String serviceNum) {
        this.descriptionSimple = descriptionSimple;
        this.descriptionDetail = descriptionDetail;
        this.phoneNum = phoneNum;
        this.serviceNum = serviceNum;
    }
}

ReturnVO

public class ReturnVO implements Serializable {
    private static final long serialVersionUID = 1L;
    // 回报类型:0 - 实物回报, 1 虚拟物品回报
    private Integer type;
    // 支持金额
    private Integer supportmoney;
    // 回报内容介绍
    private String content;
    // 总回报数量,0 为不限制
    private Integer count;
    // 是否限制单笔购买数量,0 表示不限购,1 表示限购
    private Integer signalpurchase;
    // 如果单笔限购,那么具体的限购数量
    private Integer purchase;
    // 运费,“0”为包邮
    private Integer freight;
    // 是否开发票,0 - 不开发票, 1 - 开发票
    private Integer invoice;
    // 众筹结束后返还回报物品天数
    private Integer returndate;
    // 说明图片路径
    private String describPicPath;

    public ReturnVO() {
    }

    public ReturnVO(Integer type, Integer supportmoney, String content, Integer count, Integer signalpurchase, Integer purchase, Integer freight, Integer invoice, Integer returndate, String describPicPath) {
        this.type = type;
        this.supportmoney = supportmoney;
        this.content = content;
        this.count = count;
        this.signalpurchase = signalpurchase;
        this.purchase = purchase;
        this.freight = freight;
        this.invoice = invoice;
        this.returndate = returndate;
        this.describPicPath = describPicPath;
    }
}

MemberConfirmInfoVO

public class MemberConfirmInfoVO implements Serializable {
    private static final long serialVersionUID = 1L;
    // 易付宝账号
     private String paynum;
    // 法人身份证号
     private String cardnum;

    public MemberConfirmInfoVO() {
    }

    public MemberConfirmInfoVO(String paynum, String cardnum) {
        this.paynum = paynum;
        this.cardnum = cardnum;
    }
}

发起项目

总目标

 

将各个表单页面提交的数据汇总到一起保存到数据库.

思路 

尚筹网12发起项目_第3张图片 

代码:跳转页面

配置访问project-consumer工程的路由规则

尚筹网12发起项目_第4张图片

project-consumer工程配置view-controller

尚筹网12发起项目_第5张图片

public class CrowdWebMvcConfig implements WebMvcConfigurer {

    public void addViewControllers(ViewControllerRegistry registry) {
        //view-controller是在project-consumer内部定义的
        //所以这是一个不经过zuul访问的地址,所以这个路径不加路由规则中定义的前缀
        registry.addViewController("/agree/protocol/page").setViewName("project-agree");
        registry.addViewController("/launch/project/page").setViewName("project-launch");

    }
}

页面上写地址需要注意

需要注意:前面要写上域名(如果没有配置域名写localhost一样),确保通过Zuul访问具体功能.

因为必须通过zuul访问具体功能才能保持cookie,进而保持session一致.

尚筹网12发起项目_第6张图片

尚筹网12发起项目_第7张图片

代码:接收表单数据

尚筹网12发起项目_第8张图片

/**
 * @param projectVO         接收除了上传图片之外的其他普通数据
 * @param headerPicture     //接收上传的头图
 * @param detailPictureList //接收上传的详情图片
 * @param session           //用来将收集了一部分数据的ProjectVO对象存入Session域
 * @param modelMap          //用来在当前操作失败后返回上一个表单页面时携带提示信息
 * @return
 */
@RequestMapping("/create/project/information")
public String saveProjectBasicInfo(
        ProjectVO projectVO,
        MultipartFile headerPicture,
        List detailPictureList,
        HttpSession session,
        ModelMap modelMap
) throws IOException {
    //一、完成头图上传
    //1、获取当前headerPicture对象是否为空
    boolean headerPictureEmpty = headerPicture.isEmpty();
    if (headerPictureEmpty) {
        //2、如果没有上传头图则返回到表单页面并显示错误消息
        modelMap.addAttribute(ConstantUtil.ATTR_NANE_MESSAGE, ConstantUtil.MESSAGE_HEADER_PIC_EMPTY);
        return "project-launch";
    }
    //3、如果用户确实上传了有内容的文件,则执行上传
    ResultEntity uploadHeaderPicResultEntity = CrowdUtil.uploadFileToOss(ossProperties.getEndPoint(),
            ossProperties.getAccessKeyId(),
            ossProperties.getAccessKeySecret(),
            headerPicture.getInputStream(),
            ossProperties.getBucketName(),
            ossProperties.getBucketDomain(),
            headerPicture.getOriginalFilename());

    String result = uploadHeaderPicResultEntity.getResult();
    
    //判断头图是否上传成功
    if (ResultEntity.SUCCESS.equals(result)){
        //5、如果成功则从返回的数据中获取图片访问路径
        String headerPicturePath = uploadHeaderPicResultEntity.getData();
        //6、存入ProjectVO对象中
        projectVO.setHeaderPicturePath(headerPicturePath);

    }else {
        //7、如果上传失败则返回到表单页面并显示错误消息
        modelMap.addAttribute(ConstantUtil.ATTR_NANE_MESSAGE,
                ConstantUtil.MESSAGE_DETAL_PIC_UPLOAD_FAILD);
        return "project-launch";
    }

    //二、上传详情图片
    //1、创建一个用来存放详情图片路径的集合
    List detailPicturePathList = new ArrayList();
    //2、检查detailPicture是否有效
    if (detailPictureList == null|| detailPictureList.size() ==0){
        modelMap.addAttribute(ConstantUtil.ATTR_NANE_MESSAGE,
                ConstantUtil.MESSAGE_HEADER_PIC_EMPTY);
        return "project-launch";
    }
    //3、遍历detailPictureList是否有效
    for (MultipartFile detailPicture : detailPictureList) {
        //4、当前detailPicture是否为空
        if (detailPicture.isEmpty()){
            //5、检测到详情图片中单个文件为空也是回去显示错误消息
            modelMap.addAttribute(ConstantUtil.ATTR_NANE_MESSAGE,
                    ConstantUtil.MESSAGE_HEADER_PIC_EMPTY);
            return "project-launch";
        }
        //6、执行上传
        ResultEntity detailUploadResultEntity = CrowdUtil.uploadFileToOss(ossProperties.getEndPoint(),
                ossProperties.getAccessKeyId(),
                ossProperties.getAccessKeySecret(),
                detailPicture.getInputStream(),
                ossProperties.getBucketName(),
                ossProperties.getBucketDomain(),
                detailPicture.getOriginalFilename());
        //7、检查上传结果
        String detailUploadResultEntityResult = detailUploadResultEntity.getResult();
        if (ResultEntity.SUCCESS.equals(detailUploadResultEntityResult)){
            String detailPicturePath = detailUploadResultEntity.getData();
            //8、收集刚刚上传的图片的访问路径
            detailPicturePathList.add(detailPicturePath);
        }else {
            //9、如果上传失败则返回到表单页面并显示错误消息
            modelMap.addAttribute(ConstantUtil.ATTR_NANE_MESSAGE,
                    ConstantUtil.MESSAGE_DETAL_PIC_UPLOAD_FAILD);
            return "project-launch";
        }
    }
    //10、将存放了详情图片访问路径的集合存入ProjectVO中
    projectVO.setDetailPicturePathList(detailPicturePathList);
    //三、后续操作
    //1、将projectVO对象存入Session域
    session.setAttribute(ConstantUtil.ATTR_MANE_TEMPLE_PROJECT, projectVO);
    //2、以完整的访问路径前往下一个收集回报信息的页面

    return "redirect:http://www.crowd.com/project/return/info/page";
}

 

你可能感兴趣的:(尚筹网12发起项目)