作者主页:夜未央5788
简介:Java领域优质创作者、Java项目、学习资料、技术互助
文末获取源码
项目介绍
本系统分为管理员与普通用户两种角色;
管理员功能:登录、注册、招标公式、投标公式、发布招标、服务商管理
用户功能:登录、注册、招标公式、投标公式、投标
由于本程序规模不大,可供课程设计,毕业设计学习演示之用
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
5.数据库:MySql 5.7版本;
6.是否Maven项目:是;
技术栈
1. 后端:spring+springmvc + hibernate
2. 前端:JSP+Bootstrap+jQuery
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中jdbc-hibernate-config-zrh.properties配置文件中的数据库配置改为自己的配置;
4. 修改resources/project-zrh.properties文件:pdfUploadAddress修改为本地地址;
修改完成后,需要将标书模板中的StandardBiddingBook.pdf放到所配置的目录中;
5. 运行项目,输入http://localhost:8080 登录
管理员账号/密码:admin/admin
用户账号/密码: 用户-3/3
运行截图
相关代码
BidController
package com.bjpowernode.controller;
import com.bjpowernode.cache.ActiveMenu;
import com.bjpowernode.cache.ApplicationCache;
import com.bjpowernode.entity.Bid;
import com.bjpowernode.entity.Users;
import com.bjpowernode.model.Result;
import com.bjpowernode.service.BidService;
import com.bjpowernode.service.TenderService;
import com.bjpowernode.util.JSONTransform;
import org.apache.tiles.autotag.core.runtime.annotation.Parameter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
/**
* 投标相关链接控制
*
*/
@Controller
@RequestMapping("bid")
public class BidController {
@Resource
private TenderService tenderService;
@Resource
private BidService bidService;
//招标展示所有内容首页
@RequestMapping(value = "goIndexPage")
public ModelAndView goIndexPage(@Parameter() String state) {
ModelAndView modelAndView = new ModelAndView("layouts.application_layout.bid.showAllBids");
modelAndView.addObject("tenders", JSONTransform.jsonTransform(bidService.searchBids(Bid.State.forName(state))));
modelAndView.addObject("state", state);
modelAndView.addObject("activeMenu", ActiveMenu.bidMenu);
return modelAndView;
}
//我的招标展示内容
@RequestMapping(value = "goMyIndexPage")
public ModelAndView goMyIndexPage(HttpServletRequest request, @Parameter() String state) {
ModelAndView modelAndView = new ModelAndView("layouts.application_layout.bid.showAllBids");
final Users users = ((Users) request.getSession().getAttribute("users"));
if (users == null) {
return modelAndView;
}
modelAndView.addObject("tenders", JSONTransform.jsonTransform(bidService.searchBids(users, Bid.State.forName(state))));
modelAndView.addObject("state", state);
modelAndView.addObject("activeMenu", ActiveMenu.myMenu);
return modelAndView;
}
//显示某个招标信息
@RequestMapping(value = "showOneBid")
public String showOneBid(HttpServletResponse response, @Parameter(required = true) int bidId) throws Exception {
ModelAndView modelAndView = new ModelAndView("layouts.application_layout.bid.showOneBid");
modelAndView.addObject("bidId", bidId);
modelAndView.addObject("activeMenu", ActiveMenu.bidMenu);
Bid bid = bidService.searchBid(bidId);
InputStream in = null;
OutputStream out = null;
try {
out = response.getOutputStream();
String name = ApplicationCache.pdfUploadAddress + "/" + bid.getPdf();
if (!new File(name).exists()) {
out.write(("查看内容过程出错:文件不存在").getBytes());
return null;
}
in = new FileInputStream(name);
int b;
while ((b = in.read()) != -1) {
out.write(b);
}
} catch (IOException e) {
out.write(("查看内容过程出错:" + e.getMessage()).getBytes());
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
return null;
}
//创建招标信息页
@RequestMapping(value = "createBidPage")
public ModelAndView createBidPage(int tenderId) {
ModelAndView modelAndView = new ModelAndView("layouts.application_layout.bid.createBid");
modelAndView.addObject("tender", tenderService.searchTender(tenderId));
modelAndView.addObject("activeMenu", ActiveMenu.bidMenu);
return modelAndView;
}
//保存招标
@RequestMapping(value = "createBid")
public
@ResponseBody
String
createBid(HttpServletRequest request) throws IOException {
return bidService.createBid(request);
}
//修改招标信息页
@RequestMapping(value = "goUpdatePage")
public ModelAndView goUpdatePage(int bidId) {
ModelAndView modelAndView = new ModelAndView("layouts.application_layout.bid.updateBid");
Bid bid = bidService.searchBid(bidId);
modelAndView.addObject("bid", bid);
modelAndView.addObject("activeMenu", ActiveMenu.bidMenu);
return modelAndView;
}
//修改招标信息
@RequestMapping(value = "updateBid")
public
@ResponseBody
String
updateBid(HttpServletRequest request) throws IOException {
return bidService.updateBid(request);
}
//删除招标信息页
@RequestMapping(value = "delete")
public
@ResponseBody
Result delete(int tenderId) throws Exception {
return bidService.delete(tenderId);
}
}
HomeController
package com.bjpowernode.controller;
import com.bjpowernode.cache.ActiveMenu;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
/**
*
*/
@Controller
@RequestMapping("home")
public class HomeController {
private static final Logger LOGGER = LoggerFactory.getLogger(HomeController.class);
//首页面展示
@RequestMapping(value = "goIndexPage")
public ModelAndView goIndexPage() throws Exception {
final ModelAndView modelAndView = new ModelAndView("layouts.application_layout.home");
modelAndView.addObject("activeMenu", ActiveMenu.homeMenu);
return modelAndView;
}
}
LoginController
package com.bjpowernode.controller;
import com.bjpowernode.cache.ActiveMenu;
import com.bjpowernode.entity.Users;
import com.bjpowernode.model.Result;
import com.bjpowernode.service.UsersService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
*
*/
@Controller
@RequestMapping("login")
public class LoginController {
private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);
@Resource
private UsersService usersService;
//登录页面
@RequestMapping(value = "goIndexPage")
public ModelAndView goIndexPage(HttpServletRequest request) {
final ModelAndView modelAndView = new ModelAndView("layouts.application_layout.login");
modelAndView.addObject("activeMenu", ActiveMenu.loginMenu);
modelAndView.addObject("Referer", request.getHeader("Referer"));
return modelAndView;
}
//验证登录信息
@RequestMapping(value = "verifyLogin")
public
@ResponseBody
Result verifyLogin(HttpServletRequest request, String userName, String passWd)
throws Exception {
final Result result = usersService.verifyLogin(userName, passWd);
if (result.isSuccess()) {
final Users user = ((Users) result.getData());
final HttpSession session = request.getSession();
session.setAttribute("users", user);
if (user.getType() == 2) {
session.setAttribute("isAdmin", true);
}
}
return result;
}
//注销登录
@RequestMapping(value = "loginOut")
public ModelAndView loginOut(HttpServletRequest request)
throws Exception {
final HttpSession session = request.getSession();
session.removeAttribute("users");
session.removeAttribute("isAdmin");
return new ModelAndView("redirect:/index.jsp");
}
}
TenderController
package com.bjpowernode.controller;
import com.bjpowernode.cache.ActiveMenu;
import com.bjpowernode.cache.ApplicationCache;
import com.bjpowernode.entity.Tender;
import com.bjpowernode.model.Result;
import com.bjpowernode.service.TenderService;
import com.bjpowernode.util.JSONTransform;
import org.apache.tiles.autotag.core.runtime.annotation.Parameter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
/**
* 投标相关链接控制
*
*/
@Controller
@RequestMapping("tender")
public class TenderController {
@Resource
private TenderService tenderService;
//投标展示所有内容首页
@RequestMapping(value = "goIndexPage")
public ModelAndView goIndexPage(@Parameter() String state) {
ModelAndView modelAndView = new ModelAndView("layouts.application_layout.tender.showAllTenders");
modelAndView.addObject("tenders", JSONTransform.jsonTransform(tenderService.searchTenders(Tender.State.forName(state))));
modelAndView.addObject("state", state);
modelAndView.addObject("activeMenu", ActiveMenu.tenderMenu);
return modelAndView;
}
//显示某个投标信息
@RequestMapping(value = "showOneTender")
public String showOneTender(HttpServletResponse response, @Parameter(required = true) int tenderId) throws Exception {
Tender tender = tenderService.searchTender(tenderId);
InputStream in = null;
OutputStream out = null;
try {
out = response.getOutputStream();
String name = ApplicationCache.pdfUploadAddress + "/" + tender.getPdf();
if (!new File(name).exists()) {
out.write(("查看内容过程出错:文件不存在").getBytes());
return null;
}
in = new FileInputStream(name);
int b;
while ((b = in.read()) != -1) {
out.write(b);
}
} catch (IOException e) {
out.write(("查看内容过程出错:" + e.getMessage()).getBytes());
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
return null;
}
//创建投标信息页
@RequestMapping(value = "createTenderPage")
public ModelAndView createTenderPage() {
ModelAndView modelAndView = new ModelAndView("layouts.application_layout.tender.createTender");
modelAndView.addObject("activeMenu", ActiveMenu.createTender);
return modelAndView;
}
//保存投标
@RequestMapping(value = "createTender")
public
@ResponseBody
String
createTender(HttpServletRequest request) throws IOException {
return tenderService.createTender(request);
}
//修改投标信息页
@RequestMapping(value = "goUpdatePage")
public ModelAndView goUpdatePage(int tenderId) {
ModelAndView modelAndView = new ModelAndView("layouts.application_layout.tender.updateTender");
Tender tender = tenderService.searchTender(tenderId);
modelAndView.addObject("tender", tender);
modelAndView.addObject("activeMenu", ActiveMenu.tenderMenu);
return modelAndView;
}
//修改投标信息
@RequestMapping(value = "updateTender")
public
@ResponseBody
String
updateTender(HttpServletRequest request) throws IOException {
return tenderService.updateTender(request);
}
//删除投标信息页
@RequestMapping(value = "delete")
public
@ResponseBody
Result delete(int tenderId) throws Exception {
return tenderService.delete(tenderId);
}
}
如果也想学习本系统,下面领取。关注并回复:017ssh