java springbootOA办公自动化系统:
主要功能模块:系统、用户、角色、考勤、流程、公告、邮件、任务、日程、计划、文件、笔记、通讯录、讨论区等多个模块管理
使用Maven进行项目管理,基于springboot框架开发的项目,mysql底层数据库,前端采用freemarker模板引擎,Bootstrap作为前端UI框架,集成了jpa、mybatis等框架。
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
}
@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("没有错误");
Dept adddept = deptdao.save(dept);
if("add".equals(xg)){
System.out.println("新增拉");
Position jinli = new Position();
jinli.setDeptid(adddept.getDeptId());
@RequestMapping("testsysstatus")
public String testsysstatus(HttpServletRequest req){
Iterable<SystemStatusList> statusList=statusDao.findAll();
req.setAttribute("statusList", statusList);
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));
}
@Autowired
DeptDao ddao;
@RequestMapping("positionmanage")
public String positionmanage(Model model) {
List<Position> positions = (List<Position>) pdao.findAll();
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){
return "systemcontrol/statusedit";
}
/**
* 系统管理表单验证
*
* @param req
* @param menu
* @param br
* 后台校验表单数据,不通过则回填数据,显示错误信息;通过则直接执行业务,例如新增、编辑等;
* @return
*/
@Autowired
private StatusService statusService;
/**
* 状态表格界面
* @param req
* @return
*/
@RequestMapping("testsysstatus")
public String testsysstatus(HttpServletRequest req){
Iterable<SystemStatusList> statusList=statusDao.findAll();
req.setAttribute("statusList", statusList);
return "systemcontrol/statusmanage";
}
/**
* 查找状态表格
* @param req
* @return
*/
@RequestMapping("statustable")
public String statusTable(HttpServletRequest req){
if(!StringUtils.isEmpty(req.getParameter("name"))){
formaluser.add(deptuser);
}
}
System.out.println(deptusers);
model.addAttribute("positions",positions);
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("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,
@RequestParam(value="newmanageid",required=false) Long newmanageid,
@RequestParam("deptid") Long deptid,
Model model){
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);
}
}
System.out.println(deptusers);
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")
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("positionmanage")
public String positionmanage(Model model) {
List<Position> positions = (List<Position>) pdao.findAll();
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);
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");
DeptDao ddao;
@RequestMapping("positionmanage")
public String positionmanage(Model model) {
List<Position> positions = (List<Position>) pdao.findAll();
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){
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,
@RequestParam(value="newmanageid",required=false) Long newmanageid,
@RequestParam("deptid") Long deptid,
Model model){
public String positionmanage(Model model) {
List<Position> positions = (List<Position>) pdao.findAll();
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);
}
/**
* 删除方法
*/
@RequestMapping("deletestatus")
public String deleteStatus(HttpServletRequest req){
Long statusId=Long.parseLong(req.getParameter("id"));
statusService.deleteStatus(statusId);
return "forward:/testsysstatus";
}
@RequestMapping("testsysstatus")
public String testsysstatus(HttpServletRequest req){
Iterable<SystemStatusList> statusList=statusDao.findAll();
req.setAttribute("statusList", statusList);
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));
}
deptdao.save(deptnow);
udao.save(newmanage);
}
model.addAttribute("deptid",deptid);
return "/readdept";
}
}
状态表格业务控制器:
@Controller
@RequestMapping("/")
public class StatusSysController {
Logger log=LoggerFactory.getLogger(getClass());
@Autowired
private StatusDao statusDao;
@Autowired
private StatusService statusService;
/**
return "/readdept";
}
}
状态表格业务控制器:
@Controller
@RequestMapping("/")
public class StatusSysController {
Logger log=LoggerFactory.getLogger(getClass());
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);
return "systemcontrol/statusedit";
}
/**
* 删除方法
*/
@RequestMapping("deletestatus")
if(!position.getName().endsWith("经理")){
formaluser.add(deptuser);
}
}
System.out.println(deptusers);
model.addAttribute("positions",positions);
model.addAttribute("depts",depts);
model.addAttribute("deptuser",formaluser);
model.addAttribute("dept",dept);
model.addAttribute("isread",1);
@RequestParam("userid") Long userid,
@RequestParam("deptid") Long deptid,
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);
user.setPosition(position);
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";
return "user/positionedit";
}
@RequestMapping(value = "positionedit" ,method = RequestMethod.POST)
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";
}
menu.setStatusId(menuId);
session.removeAttribute("statusid");
}
// 执行业务代码
statusService.save(menu);
System.out.println("此操作是正确的");
req.setAttribute("success", "后台验证成功");
}
System.out.println("是否进入最后的实体类信息:" + menu);
return "systemcontrol/statusedit";
}
/**
* 删除方法
*/
@RequestMapping("deletestatus")
public String deleteStatus(HttpServletRequest req){
Long statusId=Long.parseLong(req.getParameter("id"));
/**
* 删除方法
*/
@RequestMapping("deletestatus")
public String deleteStatus(HttpServletRequest req){
Long statusId=Long.parseLong(req.getParameter("id"));
statusService.deleteStatus(statusId);
return "forward:/testsysstatus";
}
}
员工业务操作:
@Controller
@RequestMapping("/")
public class PossionController {
@Autowired
PositionDao pdao;
@Autowired
DeptDao ddao;
@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
}
/**
* 删除方法
*/
@RequestMapping("deletestatus")
public String deleteStatus(HttpServletRequest req){
Long statusId=Long.parseLong(req.getParameter("id"));
statusService.deleteStatus(statusId);
return "forward:/testsysstatus";
}
}
员工业务操作:
@Controller
@RequestMapping("/")
// 这里返回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("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();
@RequestMapping("/")
public class PossionController {
@Autowired
PositionDao pdao;
@Autowired
DeptDao ddao;
@RequestMapping("positionmanage")
public String positionmanage(Model model) {
List<Position> positions = (List<Position>) pdao.findAll();
model.addAttribute("positions",positions);
return "user/positionmanage";
}