作者主页:夜未央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. 后端:mysql+Spring+hibernate+Struts 2
2. 前端:HTML+CSS+JavaScript+jsp
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入localhost:8080/ 登录
运行截图
管理员角色
企业用户角色
用户角色
相关代码
登录Action
@Controller("loginAction")
@Scope("prototype")
public class LoginAction extends ActionSupport implements ModelDriven<User>{
private User user;
@Autowired
private UserService userService;
private int otherId;
@Autowired
private ExtensionService extensionService;
@Autowired
private SpecialService specialService;
@Autowired
private NewsService newsService;
@Autowired
private AdvertisementService advertisementService;
@Override
public User getModel() {
if(user==null) user = new User();
return user;
}
//首页
public String index(){
return "success";
}
//登陆页面
public String login() {
//1查询合作站点以及友情链接
List<Extension> es = extensionService.findAll();
ActionContext.getContext().put("es", es);
//2专题
List<Special> ss = specialService.findAll();
ActionContext.getContext().put("ss", ss);
return "success";
}
//注册页面
public void register() throws IOException {
HttpServletResponse resp = ServletActionContext.getResponse();
resp.setContentType("application/json;charset=UTF-8");
PrintWriter out = null;
JSONObject js = new JSONObject();
user.setCreateTime(new Date());
User u = userService.isregister(user);
if(u != null){
js.put("message", "用户名已存在!");
}else{
userService.add(user);
js.put("message", "注册成功!");
}
out = resp.getWriter();
out.write(js.toString());
}
//退出
public String tuichu() {
ActionContext ac = ActionContext.getContext();
Map session = ac.getSession();
session.remove("userName");
session.remove("userId");
//1查询合作站点以及友情链接
List<Extension> es = extensionService.findAll();
ActionContext.getContext().put("es", es);
//2专题
List<Special> ss = specialService.findAll();
ActionContext.getContext().put("ss", ss);
return "login";
}
}
管理Action
@Controller("manageAction")
@Scope("prototype")
public class ManageAction extends ActionSupport implements ModelDriven<Manage>{
private Manage manage;
@Autowired
private UserService userService;
@Autowired
private ManageService manageService;
@Autowired
private MessageService messageService;
private int userId;
private String userName;
private int sayId;
public int getSayId() {
return sayId;
}
public void setSayId(int sayId) {
this.sayId = sayId;
}
private File file;
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
//提交过来的file的名字
private String fileFileName;
//提交过来的file的MIME类型
private String fileContentType;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
@Override
public Manage getModel() {
if(manage==null) manage = new Manage();
return manage;
}
/**
* 登陆以后进入首页
* @return
*/
public String index(){
Manage ma = manageService.login(manage);
if(ma == null){
return "login";
}
HttpSession session = ServletActionContext.getRequest().getSession();
session.setAttribute("userName", ma.getName());
session.setAttribute("userId", ma.getId());
return SUCCESS;
}
/**
* 获取用户列表
* @return
*/
public String userList(){
Pager<User> pagers = userService.listAll(userName);
//这里需要对等级进行遍历
/*List<Grade> list = gradeService.list();
if(pagers != null && pagers.getDatas() != null && pagers.getDatas().size()>0){
for(User u : pagers.getDatas()){
//对这里的人 进行遍历
for(Grade g: list){
if(u.getJifen()>=g.getStartMin() && u.getJifen() <=g.getEndMax()){
u.setDengji(g.getName());
}
}
}
}*/
ActionContext.getContext().put("pagers", pagers);
ActionContext.getContext().put("userName1", userName);
return SUCCESS;
}
/**
* 根据用户id查询所有图片
* @return
*/
/*public String userPhotos(){
Pager<SayMood> pagers = sayMoodService.findAllphotosById(userId);
ActionContext.getContext().put("pagers", pagers);
return SUCCESS;
}
*/
/**
* 删除照片
* @return
*/
/*public String delsay(){
sayMoodService.del(sayId);
ActionContext.getContext().put("url", "/manage_userPhotos.do");
return "redirect";
}*/
//删除用户
public String delUse(){
userService.delUse(userId);
ActionContext.getContext().put("url", "/manage_userList.do");
return "redirect";
}
//经警告用户
public String jinggao(){
messageService.updatejinggao(userId);
ActionContext.getContext().put("url", "/manage_userList.do");
return "redirect";
}
购物Action
/**
* 购物Action类
* @author Administrator
*
*/
@Controller
public class ShoppingAction extends ActionSupport implements ServletRequestAware {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* 商品service
*/
@Resource
private ProductService productService;
private HttpServletRequest request;
private int productId; // 商品ID
private int count; // 商品数量
private String mainPage; // 主页
private String navCode; // 导航代码
public int getProductId() {
return productId;
}
public void setProductId(int productId) {
this.productId = productId;
}
public String getMainPage() {
return mainPage;
}
public void setMainPage(String mainPage) {
this.mainPage = mainPage;
}
public String getNavCode() {
return navCode;
}
public void setNavCode(String navCode) {
this.navCode = navCode;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
/**
* 添加购物车商品类
* @return
* @throws Exception
*/
public String addShoppingCartItem()throws Exception{
//获取Session
HttpSession session=request.getSession();
JSONObject result=new JSONObject();
Product product=productService.getProductById(productId);
ShoppingCartItem shoppingCarItem=new ShoppingCartItem();
ShoppingCart shoppingCart=(ShoppingCart)session.getAttribute("shoppingCart");
//如果购物车为空
if(shoppingCart==null){
shoppingCart=new ShoppingCart();
User currentUser=(User)session.getAttribute("currentUser");
shoppingCart.setUserId(currentUser.getId());
}
List<ShoppingCartItem> shoppingCartItemList=shoppingCart.getShoppingCartItems();
if(shoppingCartItemList==null){
shoppingCartItemList=new LinkedList<ShoppingCartItem>();
}
boolean flag=true;
for(ShoppingCartItem shoppingCartItem:shoppingCartItemList){
if(shoppingCartItem.getProduct().getId()==product.getId()){
shoppingCartItem.setCount(shoppingCartItem.getCount()+1);
flag=false;
break;
}
}
if(flag){
shoppingCarItem.setProduct(product);
shoppingCarItem.setCount(1);
shoppingCartItemList.add(shoppingCarItem);
}
//添加到Session
session.setAttribute("shoppingCart", shoppingCart);
result.put("success", true);
ResponseUtil.write(ServletActionContext.getResponse(), result);
return null;
}
/**
* 删除一条商品记录
* @return
* @throws Exception
*/
public String removeShoppingCartItem()throws Exception{
HttpSession session=request.getSession();
JSONObject result=new JSONObject();
ShoppingCart shoppingCart=(ShoppingCart)session.getAttribute("shoppingCart");
List<ShoppingCartItem> shoppingCartItemList=shoppingCart.getShoppingCartItems();
for(int i=0;i<shoppingCartItemList.size();i++){
if(productId==shoppingCartItemList.get(i).getProduct().getId()){
shoppingCartItemList.remove(i);
break;
}
}
shoppingCart.setShoppingCartItems(shoppingCartItemList);
session.setAttribute("shoppingCart", shoppingCart);
result.put("success", true);
ResponseUtil.write(ServletActionContext.getResponse(), result);
return null;
}
商品小类Action类
/**
* 商品小类Action类
* @author Administrator
*
*/
@Controller
public class ProductSmallTypeAction extends ActionSupport{
/**
*
*/
private static final long serialVersionUID = 1L;
@Resource
private ProductSmallTypeService productSmallTypeService;
@Resource
private ProductService productService;
private String page;
private String rows;
private ProductSmallType productSmallType;
private ProductSmallType s_productSmallType;
private String ids;
public String getPage() {
return page;
}
public void setPage(String page) {
this.page = page;
}
public String getRows() {
return rows;
}
public void setRows(String rows) {
this.rows = rows;
}
public ProductSmallType getProductSmallType() {
return productSmallType;
}
public void setProductSmallType(ProductSmallType productSmallType) {
this.productSmallType = productSmallType;
}
public ProductSmallType getS_productSmallType() {
return s_productSmallType;
}
public void setS_productSmallType(ProductSmallType s_productSmallType) {
this.s_productSmallType = s_productSmallType;
}
public String getIds() {
return ids;
}
public void setIds(String ids) {
this.ids = ids;
}
/**
* 分页查询商品小类信息
* @return
* @throws Exception
*/
public String list()throws Exception{
PageBean pageBean=new PageBean(Integer.parseInt(page),Integer.parseInt(rows));
List<ProductSmallType> productSmallTypeList=productSmallTypeService.findProductSmallTypeList(s_productSmallType, pageBean);
long total=productSmallTypeService.getProductSmallTypeCount(s_productSmallType);
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setExcludes(new String[]{"productList"});
jsonConfig.registerJsonValueProcessor(ProductBigType.class, new ObjectJsonValueProcessor(new String[]{"id","name"}, ProductBigType.class));
JSONArray rows=JSONArray.fromObject(productSmallTypeList,jsonConfig);
JSONObject result=new JSONObject();
result.put("rows", rows);
result.put("total", total);
ResponseUtil.write(ServletActionContext.getResponse(), result);
return null;
}
/**
* 后台-保存商品小类信息
* @return
* @throws Exception
*/
public String save()throws Exception{
productSmallTypeService.saveProductSmallType(productSmallType);
JSONObject result=new JSONObject();
result.put("success", true);
ResponseUtil.write(ServletActionContext.getResponse(), result);
return null;
}
/**
* 删除商品小类
* @return
* @throws Exception
*/
public String delete()throws Exception{
JSONObject result=new JSONObject();
String []idsStr=ids.split(",");
for(int i=0;i<idsStr.length;i++){
if(productService.existProductWithSmallTypeId(Integer.parseInt(idsStr[i]))){
result.put("exist", "商品小类类包含商品");
}else{
ProductSmallType productSmallType=productSmallTypeService.getProductSmallTypeById(Integer.parseInt(idsStr[i]));
productSmallTypeService.delete(productSmallType);
}
}
result.put("success", true);
ResponseUtil.write(ServletActionContext.getResponse(), result);
return null;
}
如果也想学习本系统,下面领取。关注并回复:038ssh