Java项目:SSM高校教职工差旅报销管理系统

作者主页:夜未央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版本;

技术栈

1. 后端:Spring+SpringMVC+Mybatis

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/ 登录

运行截图

相关代码

主控制器

package com.jubilantz.controller;

import com.jubilantz.entity.EasNotice;
import com.jubilantz.entity.EasUser;
import com.jubilantz.services.EasNoticeService;
import com.jubilantz.services.EasUserService;
import com.jubilantz.utils.PageUtil;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author JubilantZ
 * @Date: 2021/4/28 20:25
 */
@RequestMapping("/main")
@Controller
public class EasMainController {
    @Autowired
    private EasNoticeService easNoticeService;

    @Autowired
    private EasUserService easUserService;

    @RequestMapping("/homePage")
    public String homePage() throws Exception{
        return "system/home/homePage";
    }

//    @RequestMapping(value="/getNotice",method = RequestMethod.GET)
//    @ResponseBody
//    public Map<String,Object> getNotice(@RequestParam(defaultValue = "1") Integer page,
//                                        @RequestParam(defaultValue = "2") Integer limit,
//                                        EasNotice easNotice) throws Exception {
//        Map<String,Object> map = new HashMap<>();
//
        System.out.println("模糊查询的内容为:"+easNotice.getContent());
//
//        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
//
//        //判断用户有没有 角色 有就返回角色id 没有就返回1000
//
//        Integer roleId = easUserService.findRoleIdByUserId(easUser.getId());
//
//
//        String strRoleId =roleId +"";
        System.out.println("roleId:"+roleId);
        System.out.println("strRoleId:"+strRoleId);
//        PageUtil pageUtil = new  PageUtil(page,limit);
//
//        //没有角色
//        if(roleId == null || !(strRoleId.length() >0 || roleId == 2)){//全体可见的部分公告,没要求
//            //type = 1 全员可见 type = 2 教师可见  type = 3 草稿  管理员可见
//            int type = 1;
//            int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
//            pageUtil.setTotal(count);
//            pageUtil.setCount(limit);
//            int totalPage = pageUtil.getTotalPage();
            System.out.println("总页数为"+totalPage);
//
//            List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);
//
//            map.put("totalPage",totalPage);
//            map.put("count",count);
//            map.put("data",list);
//            map.put("code",0);
//            map.put("msg","");
//        }else if(roleId == 3){//增加教师公告可见
//            int type = 2;
//            int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
//            List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);
//            pageUtil.setTotal(count);
//            pageUtil.setCount(limit);
//            int totalPage = pageUtil.getTotalPage();
            System.out.println("总页数为"+totalPage);
//
//            map.put("totalPage",totalPage);
//            map.put("count",count);
//            map.put("data",list);
//            map.put("code",0);
//            map.put("msg","");
//        }else{//管理员可见全部
//            int type = 3;
//            int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
//            List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);
//
//            pageUtil.setTotal(count);
//            pageUtil.setCount(limit);
//            int totalPage = pageUtil.getTotalPage();
//
//            map.put("totalPage",totalPage);
//
//            map.put("count",count);
//            map.put("data",list);
//            map.put("code",0);
//            map.put("msg","");
//        }
//
//        return map;
//    }

    @RequestMapping(value="/getNotice",method = RequestMethod.GET)
    @ResponseBody
    public Map<String,Object> getNotice(@RequestParam(defaultValue = "1") Integer page,
                                        @RequestParam(defaultValue = "2") Integer limit,
                                        EasNotice easNotice) throws Exception {
        Map<String,Object> map = new HashMap<>();
//        System.out.println("模糊查询的内容为:"+easNotice.getContent());
        EasUser easUser = (EasUser) SecurityUtils.getSubject().getPrincipal();//获取EasUser对象
        //判断用户有没有 角色 有就返回角色id 没有就返回1000

        List<Integer> rolelist = easUserService.findRoleIdByUserId2(easUser.getId());


        PageUtil pageUtil = new  PageUtil(page,limit);
        if(rolelist.size() >= 2){
            int type = 3;
            int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
            List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);

            pageUtil.setTotal(count);
            pageUtil.setCount(limit);
            int totalPage = pageUtil.getTotalPage();

            map.put("totalPage",totalPage);

            map.put("count",count);
            map.put("data",list);
            map.put("code",0);
            map.put("msg","");
        }else {
            if(rolelist.size() == 0 || rolelist.get(0) == 2){
                //type = 1 全员可见 type = 2 教师可见  type = 3 草稿  管理员可见
                int type = 1;
                int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
                pageUtil.setTotal(count);
                pageUtil.setCount(limit);
                int totalPage = pageUtil.getTotalPage();
//            System.out.println("总页数为"+totalPage);

                List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);

                map.put("totalPage",totalPage);
                map.put("count",count);
                map.put("data",list);
                map.put("code",0);
                map.put("msg","");
            }else if(rolelist.get(0) == 3) {
                int type = 2;
                int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
                List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);
                pageUtil.setTotal(count);
                pageUtil.setCount(limit);
                int totalPage = pageUtil.getTotalPage();
//            System.out.println("总页数为"+totalPage);

                map.put("totalPage",totalPage);
                map.put("count",count);
                map.put("data",list);
                map.put("code",0);
                map.put("msg","");
            }else{
                int type = 3;
                int count = easNoticeService.getCountByTypeAndEasNotice(type,easNotice);
                List<EasNotice> list = easNoticeService.getNoticeListByTypeAndEasNotice(type,easNotice,pageUtil);

                pageUtil.setTotal(count);
                pageUtil.setCount(limit);
                int totalPage = pageUtil.getTotalPage();

                map.put("totalPage",totalPage);

                map.put("count",count);
                map.put("data",list);
                map.put("code",0);
                map.put("msg","");
            }
        }

        return map;
    }


    //点击查看具体通知
    @RequestMapping(value="/lookNotice")
    public ModelAndView look(Integer id){
        ModelAndView modelAndView = new ModelAndView();
//        System.out.println("我是通知id:"+id);

        List<EasNotice> list = easNoticeService.getNoticeById(id);
        modelAndView.addObject("noticeList",list);
        modelAndView.setViewName("system/notice/homeNotice");

        return modelAndView;
    }


}

通知控制器

package com.jubilantz.controller;

import com.jubilantz.entity.EasNotice;
import com.jubilantz.services.EasNoticeService;
import com.jubilantz.utils.PageUtil;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author JubilantZ
 * @Date: 2021/4/27 11:35
 */
@RequestMapping("/easNotice")
@Controller
public class EasNoticeController {
    @Autowired
    private EasNoticeService easNoticeService;

    @RequestMapping("/index")
    @RequiresPermissions("notice:query")
    public String index() throws Exception{
        return "system/notice/adminNoticeList";
    }

    @ResponseBody
    @RequestMapping("/list")
    public Map<String, Object> getNoticeList(
                                @RequestParam(defaultValue = "1") Integer page,
                                @RequestParam(defaultValue = "10") Integer limit,
                                @RequestParam(defaultValue="")String searchKey) throws Exception {
        Map<String,Object> map = new HashMap<>();
        //一共三个权限 获取全部的行数
        int type = 3;
        int count = easNoticeService.getCountByType(type,searchKey);

        PageUtil pageUtil = new  PageUtil(page,limit);
        List<EasNotice> list = easNoticeService.getNoticeListByType(type,searchKey,pageUtil);


        map.put("count",count);
        map.put("data",list);
        map.put("code",0);
        map.put("msg","");

        return map;
    }

    @RequestMapping("/look")
    public ModelAndView showNotice(){
        return new ModelAndView("system/notice/notice");
    }

    @RequestMapping("/addPage")
    public ModelAndView toAddPage() {
        return new ModelAndView("system/notice/noticeAdd");
    }


    @RequestMapping("/addNotice")
    @ResponseBody
    public Map<String, Object> addNotice(@RequestParam(defaultValue="2")Integer opType, EasNotice easNotice) throws Exception {
        Map<String, Object> map = new HashMap<>();
//        System.out.println("通知id:"+easNotice.getId());
//        System.out.println("opType为:"+opType);
//        System.out.println("content为:"+easNotice.getContent());

        int res = 0;
        //opType等于0是添加 1是更新
        if (opType == 0) {
            try {
                res = easNoticeService.addNotice(easNotice);
            } catch (Exception e) {
//                System.out.println("添加失败!");
                map.put("result",false);
            }
            if (res > 0){
                map.put("result",true);
            }else{
                map.put("result",false);
            }

        } else if (opType == 1) {
            res = easNoticeService.updateNotice(easNotice);
            if (res > 0) {
                map.put("result",true);
            }else{
                map.put("result",false);
            }

        };

        return map;
    }

    @ResponseBody
    @RequestMapping("/deleteNotice")
    public Map<String, Object> deleteNotice(EasNotice easNotice) {
        Map<String, Object> map = new HashMap<>();
        if (easNoticeService.deleteNotice(easNotice) > 0) {
            map.put("result",true);
            map.put("msg","删除成功");
        }else {
            map.put("result",false);
            map.put("msg","删除失败");
        }
        return map;
    }

    /**
     * 批量删除通知
     * @param nIds
     * @return
     */
    @ResponseBody
    @RequestMapping("/deleteList")
    public Map<String, Object> deleteNoticeList(String nIds) {
        Map<String, Object> map = new HashMap<>();
        List<Integer> list = new ArrayList<Integer>();
        try {
            String[] ids = nIds.split(",");
            for (String id: ids) {
                list.add(Integer.parseInt(id));
            }
            if (easNoticeService.deleteNoticeList(list) > 0) {
                map.put("result",true);
                map.put("msg","批量删除成功");
            }else {
                map.put("result",false);
                map.put("msg","批量删除失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
            map.put("result",false);
            map.put("msg","批量删除失败");
        }
        return map;
    }

    @ResponseBody
    @RequestMapping(value="/uploadImg")
    public String uploadImg(MultipartFile file, HttpServletRequest request) throws IOException {
        System.out.println("comming!");
        String path = request.getSession().getServletContext().getRealPath("/images");
        System.out.println("path>>"+path);
        //获取上传图片的名称
        String fileName = file.getOriginalFilename();
        System.out.println("fileName>>"+fileName);
//        //获取图片的后缀 例:.jpg
//        fileName = fileName.substring(fileName.lastIndexOf("."), fileName.length());
//        System.out.println("fileName1>>"+fileName);
//        //生成图片名称
//        fileName = System.currentTimeMillis() + fileName; //System.currentTimeMillis()产生一个当前的毫秒 +文件后缀 例.jpg
        System.out.println("fileName2>>"+fileName);
        File dir = new File(path, fileName);
        System.out.println("File>>"+dir);
        if(!dir.exists()){
            dir.mkdirs();
        }
//      MultipartFile自带的解析方法
        file.transferTo(dir);

        String jsonStr = "{\"code\":0,\"msg\":\"\",\"count\":" + null + ",\"data\":" + "{\"src\":\"" + "/images/" + fileName + "\"}" + "}";

        return jsonStr;
    }
}

权限控制器

package com.jubilantz.controller;

import com.jubilantz.entity.EasPermission;
import com.jubilantz.mappers.EasPermissionMapper;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/easPermission")
public class EasPermissionController {
    @Autowired
    private EasPermissionMapper easPermissionMapper;

    @RequestMapping("/index")
    @RequiresPermissions("permission:query")
    public String index() throws Exception{
        return "system/permission/index";
    }

    @RequestMapping("/parentList")
    @ResponseBody
    public List<EasPermission> parentList() {
        return easPermissionMapper.getParentPers();
    }

    @RequestMapping("/list")
    @ResponseBody
    public Map<String,Object> list() throws Exception {
        Map<String,Object> map = new HashMap<>();

        map.put("code",0);
        map.put("msg",null);
        map.put("data",easPermissionMapper.getAll());

        return map;
    }
}

PropertyValueController

package com.smzy.controller;

import com.smzy.pojo.Product;
import com.smzy.pojo.Property;
import com.smzy.pojo.PropertyValue;
import com.smzy.service.ProductService;
import com.smzy.service.PropertyService;
import com.smzy.service.PropertyValueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Controller
@RequestMapping("/admin")
public class PropertyValueController {

    @Autowired
    private PropertyValueService propertyValueService;

    @Autowired
    private PropertyService propertyService;

    @Autowired
    private ProductService productService;


    @RequestMapping("/listPropertyValue")
    public String findAll(Model model ,Integer product_id ,Integer category_id) {
        List<PropertyValue> propertyValues = propertyValueService.findByProductId(product_id);
        model.addAttribute("propertyValues",propertyValues);
        Product product = productService.get(product_id);
        model.addAttribute("product",product);
        List<Property> properties = propertyService.findAll(category_id);
        model.addAttribute("properties",properties);
        return "admin/listPropertyValue";
    }

    @RequestMapping("/addPropertyValueView")
    public String addPropertyValueView(Model model ,Integer product_id,Integer category_id) {
        List<PropertyValue> propertyValues = propertyValueService.findByProductId(product_id);
        model.addAttribute("propertiesValue",propertyValues);
        List<Property> properties = propertyService.findAll(category_id);
        model.addAttribute("properties",properties);
        Product product = productService.get(product_id);
        model.addAttribute("product",product);
        return "admin/addPropertyValueView";
    }

    @RequestMapping("/addPropertyValue")
    public String add(PropertyValue propertyValue ){
        int product_id = propertyValue.getProduct_id();
        int category_id = productService.get(product_id).getCategory_id();
        propertyValueService.add(propertyValue);
        return "redirect:listPropertyValue?product_id=" + product_id + "&category_id=" + category_id;
    }

    @RequestMapping("/deletePropertyValue")
    public String delete(Integer id)  {
        int product_id = propertyValueService.get(id).getProduct_id();
        int category_id = productService.get(product_id).getCategory_id();
        propertyValueService.delete(id);
        return "redirect:listPropertyValue?product_id=" + product_id + "&category_id=" + category_id;
    }

    @RequestMapping("/editPropertyValue")
    public String edit(Integer id ,Model model) {
        PropertyValue propertyValue = propertyValueService.get(id);
        model.addAttribute("propertyValue",propertyValue);
        Product product = productService.get(propertyValue.getProperty_id());
        model.addAttribute("product",product);
        return "admin/editPropertyValue";
    }

    @RequestMapping("/updatePropertyValue")
    public String update(PropertyValue propertyValue) {
        Integer product_id = propertyValue.getProduct_id();
        Integer category_id = productService.get(product_id).getCategory_id();
        propertyValueService.update(propertyValue);
        return "redirect:listPropertyValue?product_id=" + product_id + "&category_id=" + category_id;
    }
}

如果也想学习本系统,下面领取。关注并回复:148ssm  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜未央5788

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值