pragma solidity ^0.4.13;
contract TimeProject {
enum ProjectStatus { Open, Examing, Finshed }
//enum ProductCondition { New, Used }
uint public projectIndex;
mapping (address => mapping(uint => Project)) examer;
mapping (uint => address) projectIdInStore;
//项目信息结构
struct Project {
uint id;
string name;
string category;
//string imageLink;
string when;
string where;
string description;
uint price;
uint demandNum;
ProjectStatus status;
//ProductCondition condition;
}
constructor() public {
projectIndex = 0;
}
//添加项目信息上链
function addProject(string _name, string _category,string _when, string _where, string _description, uint _price, uint _demandNum) public {
require(_price>0,"The price is too low!");
projectIndex += 1;
Project memory project = Project(projectIndex, _name, _category, _when, _where, _description,_price,_demandNum, ProjectStatus.Open);
examer[msg.sender][projectIndex] = project;
projectIdInStore[projectIndex] = msg.sender;
}
//查询展示链上项目信息
function getProject(uint _projectId) view public returns (uint, string, string, string, string, string, uint, uint, ProjectStatus) {
Project memory project = examer[projectIdInStore[_projectId]][_projectId];
return (project.id, project.name, project.category, project.when, project.where, project.description, project.price, project.demandNum, project.status);
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)