基于javaweb+springboot的OA办公自动化系统(springboot+freemarker+mysql+maven+mybatis+jpa)
java springbootOA办公自动化系统:
主要功能模块:系统、用户、角色、考勤、流程、公告、邮件、任务、日程、计划、文件、笔记、通讯录、讨论区等多个模块管理
使用Maven进行项目管理,基于springboot框架开发的项目,mysql底层数据库,前端采用freemarker模板引擎,Bootstrap作为前端UI框架,集成了jpa、mybatis等框架。
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
model.addAttribute("deptid",deptid);
return "/readdept";
}
}
状态表格业务控制器:
@Controller
@RequestMapping("/")
public class StatusSysController {
Logger log=LoggerFactory.getLogger(getClass());
@Autowired
private StatusDao statusDao;
@Autowired
private StatusService statusService;
/**
* 状态表格界面
* @param req
}
return "systemcontrol/statustable";
}
/**
* 状态编辑界面
* @param req
* @return
*/
@RequestMapping("statusedit")
public String typeEdit(HttpServletRequest req){
if(!StringUtils.isEmpty(req.getParameter("statusid"))){
Long statusid=Long.parseLong(req.getParameter("statusid"));
SystemStatusList statusList=statusDao.findOne(statusid);
* @return
*/
@RequestMapping("statustable")
public String statusTable(HttpServletRequest req){
if(!StringUtils.isEmpty(req.getParameter("name"))){
String name="%"+req.getParameter("name")+"%";
req.setAttribute("statusList",statusDao.findByStatusNameLikeOrStatusModelLike(name, name));
}
else{
Iterable<SystemStatusList> statusList=statusDao.findAll();
req.setAttribute("statusList", statusList);
}
return "systemcontrol/statustable";
}
Long statusid=Long.parseLong(req.getParameter("statusid"));
SystemStatusList statusList=statusDao.findOne(statusid);
req.setAttribute("status", statusList);
HttpSession session=req.getSession();
session.setAttribute("statusid", statusid);
}
return "systemcontrol/statusedit";
}
/**
model.addAttribute("positions",positions);
return "user/positionmanage";
}
@RequestMapping(value = "positionedit" ,method = RequestMethod.GET)
public String positioneditget(@RequestParam(value = "positionid",required=false) Long positionid,Model model){
if(positionid!=null){
Position position = pdao.findOne(positionid);
System.out.println(position);
Dept dept = ddao.findOne(position.getDeptid());
model.addAttribute("positiondept",dept);
model.addAttribute("position",position);
}
List<Dept> depts = (List<Dept>) ddao.findAll();
model.addAttribute("depts", depts);
@Controller
@RequestMapping("/")
public class StatusSysController {
Logger log=LoggerFactory.getLogger(getClass());
@Autowired
private StatusDao statusDao;
@Autowired
private StatusService statusService;
/**
* 状态表格界面
* @param req
@RequestParam(value="changedeptid",required=false) Long changedeptid,
@RequestParam(value="oldmanageid",required=false) Long oldmanageid,
@RequestParam(value="newmanageid",required=false) Long newmanageid,
@RequestParam("deptid") Long deptid,
Model model){
System.out.println("oldmanageid:"+oldmanageid);
System.out.println("newmanageid:"+newmanageid);
Dept deptnow = deptdao.findOne(deptid);
if(oldmanageid!=null){
User oldmanage = udao.findOne(oldmanageid);
Position namage = oldmanage.getPosition();
Dept changedept = deptdao.findOne(changedeptid);
Position changeposition = pdao.findOne(positionid);
oldmanage.setDept(changedept);
oldmanage.setPosition(changeposition);
@RequestMapping("/")
public class StatusSysController {
Logger log=LoggerFactory.getLogger(getClass());
@Autowired
private StatusDao statusDao;
@Autowired
private StatusService statusService;
/**
* 状态表格界面
* @param req
* @return
*/
@RequestMapping("testsysstatus")
public String positioneditpost(Position position,Model model){
System.out.println(position);
Position psition2 = pdao.save(position);
if(psition2!=null){
model.addAttribute("success",1);
return "/positionmanage";
}
model.addAttribute("errormess","数据插入失败");
return "user/positionedit";
}
model.addAttribute("success",1);
return "/positionmanage";
}
model.addAttribute("errormess","数据插入失败");
return "user/positionedit";
}
@RequestMapping("removeposition")
public String removeposition(@RequestParam("positionid") Long positionid,Model model){
pdao.delete(positionid);
model.addAttribute("success",1);
return "/positionmanage";
}
}
部门管理控制器:
@Controller
@RequestMapping("/")
System.out.println("list错误详情:" + list);
System.out.println("list错误第一条:" + list.get(0));
System.out.println("啊啊啊错误的信息——:" + list.get(0).toString());
// 下面的info信息是打印出详细的信息
log.info("getData:{}", res.getData());
log.info("getCode:{}", res.getCode());
log.info("getMsg:{}", res.getMsg());
}
// 校验通过,下面写自己的逻辑业务
else {
HttpSession session = req.getSession();
// 判断是否从编辑界面进来的,前面有"session.setAttribute("getId",getId);",在这里获取,并remove掉;
if (!StringUtils.isEmpty(session.getAttribute("statusid"))) {
Long menuId = (Long) session.getAttribute("statusid"); // 获取进入编辑界面的menuID值
menu.setStatusId(menuId);
session.removeAttribute("statusid");
}
// 执行业务代码
statusService.save(menu);
System.out.println("此操作是正确的");
req.setAttribute("success", "后台验证成功");
}
System.out.println("是否进入最后的实体类信息:" + menu);
}
@RequestMapping("removeposition")
public String removeposition(@RequestParam("positionid") Long positionid,Model model){
pdao.delete(positionid);
model.addAttribute("success",1);
return "/positionmanage";
}
}
部门管理控制器:
@Controller
@RequestMapping("/")
public class DeptController {
req.setAttribute("statusList", statusList);
}
return "systemcontrol/statustable";
}
/**
* 状态编辑界面
* @param req
* @return
*/
@RequestMapping("statusedit")
public String typeEdit(HttpServletRequest req){
if(!StringUtils.isEmpty(req.getParameter("statusid"))){
Long statusid=Long.parseLong(req.getParameter("statusid"));
SystemStatusList statusList=statusDao.findOne(statusid);
req.setAttribute("status", statusList);
HttpSession session=req.getSession();
// 这里返回ResultVO对象,如果校验通过,ResultEnum.SUCCESS.getCode()返回的值为200;否则就是没有通过;
ResultVO res = BindingResultVOUtil.hasErrors(br);
// 校验失败
if (!ResultEnum.SUCCESS.getCode().equals(res.getCode())) {
List<Object> list = new MapToList<>().mapToList(res.getData());
req.setAttribute("errormess", list.get(0).toString());
// 代码调试阶段,下面是错误的相关信息;
System.out.println("list错误的实体类信息:" + menu);
System.out.println("list错误详情:" + list);
System.out.println("list错误第一条:" + list.get(0));
System.out.println("啊啊啊错误的信息——:" + list.get(0).toString());
// 下面的info信息是打印出详细的信息
log.info("getData:{}", res.getData());
log.info("getCode:{}", res.getCode());
log.info("getMsg:{}", res.getMsg());
}
// 校验通过,下面写自己的逻辑业务
model.addAttribute("depts",depts);
model.addAttribute("deptuser",formaluser);
model.addAttribute("dept",dept);
model.addAttribute("isread",1);
return "user/deptread";
}
@RequestMapping("deptandpositionchange")
public String deptandpositionchange(@RequestParam("positionid") Long positionid,
@RequestParam("changedeptid") Long changedeptid,
@RequestParam("userid") Long userid,
@RequestParam("deptid") Long deptid,
Model model){
User user = udao.findOne(userid);
Dept changedept = deptdao.findOne(changedeptid);
@RequestMapping("removeposition")
public String removeposition(@RequestParam("positionid") Long positionid,Model model){
pdao.delete(positionid);
model.addAttribute("success",1);
return "/positionmanage";
}
}
部门管理控制器:
@Controller
@RequestMapping("/")
public class DeptController {
@Autowired
PositionDao pdao;
@Autowired
DeptDao ddao;
@RequestMapping("positionmanage")
public String positionmanage(Model model) {
List<Position> positions = (List<Position>) pdao.findAll();
return "systemcontrol/statusmanage";
}
/**
* 查找状态表格
* @param req
* @return
*/
@RequestMapping("statustable")
public String statusTable(HttpServletRequest req){
if(!StringUtils.isEmpty(req.getParameter("name"))){
String name="%"+req.getParameter("name")+"%";
req.setAttribute("statusList",statusDao.findByStatusNameLikeOrStatusModelLike(name, name));
}
else{
Iterable<SystemStatusList> statusList=statusDao.findAll();
req.setAttribute("statusList", statusList);
}
return "systemcontrol/statustable";
}
/**
}
model.addAttribute("deptid",deptid);
return "/readdept";
}
}
状态表格业务控制器:
@Controller
@RequestMapping("/")
public class StatusSysController {
Logger log=LoggerFactory.getLogger(getClass());
@Autowired
private StatusDao statusDao;
model.addAttribute("dept",dept);
model.addAttribute("isread",1);
return "user/deptread";
}
@RequestMapping("deptandpositionchange")
public String deptandpositionchange(@RequestParam("positionid") Long positionid,
@RequestParam("changedeptid") Long changedeptid,
@RequestParam("userid") Long userid,
@RequestParam("deptid") Long deptid,
Model model){
User deptmanage = null;
if(dept.getDeptmanager()!=null){
deptmanage = udao.findOne(dept.getDeptmanager());
model.addAttribute("deptmanage",deptmanage);
}
List<Dept> depts = (List<Dept>) deptdao.findAll();
List<Position> positions = pdao.findByDeptidAndNameNotLike(1L, "%经理");
System.out.println(deptmanage);
List<User> formaluser = new ArrayList<>();
List<User> deptusers = udao.findByDept(dept);
for (User deptuser : deptusers) {
Position position = deptuser.getPosition();
System.out.println(deptuser.getRealName()+":"+position.getName());
if(!position.getName().endsWith("经理")){
formaluser.add(deptuser);
udao.save(user);
System.out.println(deptid);
model.addAttribute("deptid",deptid);
return "/readdept";
}
@RequestMapping("deletdept")
public String deletdept(@RequestParam("deletedeptid") Long deletedeptid){
Dept dept = deptdao.findOne(deletedeptid);
List<Position> ps = pdao.findByDeptid(deletedeptid);
for (Position position : ps) {
System.out.println(position);
pdao.delete(position);
}
deptdao.delete(dept);
return "/deptmanage";
}
@RequestMapping("deptmanagerchange")
public String deptmanagerchange(@RequestParam(value="positionid",required=false) Long positionid,
@RequestParam(value="changedeptid",required=false) Long changedeptid,
@RequestParam(value="oldmanageid",required=false) Long oldmanageid,
Model model){
User user = udao.findOne(userid);
Dept changedept = deptdao.findOne(changedeptid);
Position position = pdao.findOne(positionid);
user.setDept(changedept);
user.setPosition(position);
udao.save(user);
System.out.println(deptid);
model.addAttribute("deptid",deptid);
return "/readdept";
}
@RequestMapping("deletdept")
HttpSession session = req.getSession();
// 判断是否从编辑界面进来的,前面有"session.setAttribute("getId",getId);",在这里获取,并remove掉;
if (!StringUtils.isEmpty(session.getAttribute("statusid"))) {
Long menuId = (Long) session.getAttribute("statusid"); // 获取进入编辑界面的menuID值
menu.setStatusId(menuId);
session.removeAttribute("statusid");
}
// 执行业务代码
statusService.save(menu);
System.out.println("此操作是正确的");
req.setAttribute("success", "后台验证成功");
}
System.out.println("是否进入最后的实体类信息:" + menu);
return "systemcontrol/statusedit";
}
/**
* 删除方法
*/
@RequestMapping("deletestatus")
}
/**
* 状态编辑界面
* @param req
* @return
*/
@RequestMapping("statusedit")
public String typeEdit(HttpServletRequest req){
if(!StringUtils.isEmpty(req.getParameter("statusid"))){
Long statusid=Long.parseLong(req.getParameter("statusid"));
* @return
*/
@RequestMapping("deptmanage")
public String deptmanage(Model model) {
List<Dept> depts = (List<Dept>) deptdao.findAll();
System.out.println(depts);
model.addAttribute("depts",depts);
return "user/deptmanage";
}
@RequestMapping(value = "deptedit" ,method = RequestMethod.POST)
public String adddept(@Valid Dept dept,@RequestParam("xg") String xg,BindingResult br,Model model){
System.out.println(br.hasErrors());
System.out.println(br.getFieldError());
if(!br.hasErrors()){
System.out.println("没有错误");
}
return "user/deptedit";
}
@RequestMapping("readdept")
public String readdept(@RequestParam(value = "deptid") Long deptId,Model model){
Dept dept = deptdao.findOne(deptId);
User deptmanage = null;
if(dept.getDeptmanager()!=null){
deptmanage = udao.findOne(dept.getDeptmanager());
model.addAttribute("deptmanage",deptmanage);
}
List<Dept> depts = (List<Dept>) deptdao.findAll();
List<Position> positions = pdao.findByDeptidAndNameNotLike(1L, "%经理");
System.out.println(deptmanage);
List<User> formaluser = new ArrayList<>();
List<User> deptusers = udao.findByDept(dept);
for (User deptuser : deptusers) {
Position position = deptuser.getPosition();