山东大学软件学院创新实训——飞讯(十一)

目录

一.目标概述

二.数据库设计

三.功能代码

1.工作日志的查询和展示

2.工作日志的添加

3.工作日志的修改

4.工作日志的删除

三.前后端联调后界面展示

 四.总结


一.目标概述

本次项目实施的目的是完成工作日志功能。对于工作日志,我和另外一位同学进行分工,我负责后端接口功能和数据库的设计和编写,他负责前端界面的编写,最后一起前后端交互,从而实现工作日志功能。

二.数据库设计

工作日志设计增删改查,但是是因为是个人的工作记录,因此采用单表进行操作。

三.功能代码

1.工作日志的查询和展示

@RequestMapping("/findLogTime")
    public JsonResult<Object> findLogTime(@RequestBody Map<String,String> map){
        String userid = map.get("userid");
        List<WorkLogTime> workLogTimeList = workLogService.findLogTime(userid);
        JsonResult<Object> jsonResult = new JsonResult<Object>("200", (Object) workLogTimeList,"获取工作日志成功");
        //System.out.println(jsonResult);
        return jsonResult;
    }

2.工作日志的添加

@RequestMapping("/createLogTime")
    public JsonResult<Object> createLogTime(@RequestBody Map<String,String> map){
        if (!map.containsKey("userid") || map.get("userid").equals("") || map.get("userid") == null){
            return new JsonResult<Object>("400","缺少userid");
        }
        if (!map.containsKey("title") || map.get("title").equals("") || map.get("title") == null){
            return new JsonResult<Object>("400","缺少title");
        }
        if (!map.containsKey("details") || map.get("details").equals("") || map.get("details") == null){
            return new JsonResult<Object>("400","缺少details");
        }
        String userid = map.get("userid");
        String title = map.get("title");
        String details = map.get("details");

        Date date = new Date(System.currentTimeMillis());
        WorkLogTime workLogTime = new WorkLogTime(userid,title,details,date);


        int res = workLogService.createLogTime(workLogTime);
        if (res == ResCondition.workLog_success){
            JsonResult<Object> jsonResult = new JsonResult<Object>("200",(Object) workLogTime,"创建日志成功");
            return jsonResult;
        }
        else {
            JsonResult<Object> jsonResult = new JsonResult<Object>("400",(Object) workLogTime,"创建日志失败");
            return jsonResult;
        }
    }

3.工作日志的修改

@RequestMapping("/updateLogTime")
    public JsonResult<Object> updateLogTime(@RequestBody Map<String,String> map){
        if (!map.containsKey("id") || map.get("id").equals("") || map.get("id") == null){
            return new JsonResult<Object>("400","缺少id");
        }
        if (!map.containsKey("title") || map.get("title").equals("") || map.get("title") == null){
            return new JsonResult<Object>("400","缺少title");
        }
        if (!map.containsKey("details") || map.get("details").equals("") || map.get("details") == null){
            return new JsonResult<Object>("400","缺少details");
        }
        int workLogTimeId = Integer.parseInt(map.get("id"));
        String title = map.get("title");
        String details = map.get("details");
        WorkLogTime workLogTime = new WorkLogTime(workLogTimeId,title,details);


        int res = workLogService.updateLogTime(workLogTime);
        if (res == ResCondition.workLog_success){
            JsonResult<Object> jsonResult = new JsonResult<Object>("200",(Object) workLogTime,"修改日志成功");
            return jsonResult;
        }
        else {
            JsonResult<Object> jsonResult = new JsonResult<Object>("400",(Object) workLogTime,"修改日志失败");
            return jsonResult;
        }
    }

4.工作日志的删除

@RequestMapping("/deleteLogTime")
    public JsonResult<Object> deleteLogTime(@RequestBody Map<String,String> map){
        if (!map.containsKey("id") || map.get("id").equals("") || map.get("id") == null){
            return new JsonResult<Object>("400","缺少id");
        }
        int workLogTimeId = Integer.parseInt(map.get("id"));


        int res = workLogService.deleteLogTime(workLogTimeId);
        if (res == ResCondition.workLog_success){
            JsonResult<Object> jsonResult = new JsonResult<Object>("200",(Object) workLogTimeId,"删除日志成功");
            return jsonResult;
        }
        else {
            JsonResult<Object> jsonResult = new JsonResult<Object>("400",(Object) workLogTimeId,"删除日志失败");
            return jsonResult;
        }
    }

三.前后端联调后界面展示

 

 四.总结

    通过本次对工作日志的编写,我们完成了工作日志的基本功能,知道了前后端成员之间协作的过程和方法,后续,我们继续进行问卷功能的编写。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值