[springboot]综合测评系统-(四)天哪我居然懒惰了

摘要:废话2%,技术0,完成进度99%

贴下最新的进展

一。记住我功能

if ($.cookie('bit') == 'true') {
            $('#remember_me').attr('checked', 'checked');
            $('#stuid').val($.cookie('username'));
            $('#pwd').val($.cookie('password'));
        }
if ($('#remember_me').is(':checked')) {     //检查cookies
                        $.cookie('username', id, {
                            expires: 30
                        });
                        $.cookie('password', pwd, {
                            expires: 30
                        });
                        $.cookie('bit', 'true', {
                            expires: 30
                        });
                    } else {
                        $.removeCookie('username');
                        $.removeCookie('password');
                        $.removeCookie('bit');
                    }

/**学生专用*/
@Controller
@RequestMapping("/api")
public class ApiController {


    private static final Logger log= LoggerFactory.getLogger(ApiController.class);

    @Autowired
    FractionDao fractionDao;
    @Autowired
    StudentServiceImpl studentServiceImpl;
    @Autowired
    TableServiceImpl tableServiceImpl;

    /**
     *
     * 功能描述: 学生添加加分
     *
     * @param:
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 13:28
     */
    @PostMapping("/fraction")
    @ResponseBody
    public Result addfraction(FractionEntity fractionEntity,
                              HttpSession session){
        studentServiceImpl.addfraction(fractionEntity, SessionUtil.SessionGetid(session));
        return ResultUtil.success(fractionEntity);
    }
    /**
     *
     * 功能描述: 学生获取自己的加分列表
     *
     * @param: session
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 13:28
     */
    @GetMapping("/fraction")
    @ResponseBody
    public Result getfraction(HttpSession session){
        return ResultUtil.success(studentServiceImpl.getfraction(SessionUtil.SessionGetid(session)));
    }

    /**
     *
     * 功能描述: 删除某条加分记录
     *
     * @param: id
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 13:27
     */
    @GetMapping("/fraction/{id}")
    @ResponseBody
    public Result deletefraction(@PathVariable("id")long id,
                                 HttpSession session){
        studentServiceImpl.deletefraction(SessionUtil.SessionGetid(session),id);
        return ResultUtil.success();
    }
   /**
    *
    * 功能描述: 获取学生个人信息
    *
    * @param: session
    * @return:
    * @auther: 陆拾壹
    * @date: 2019/3/21 13:26
    */
    @GetMapping("/student")
    @ResponseBody
    public Result getstudent(HttpSession session){
        return ResultUtil.success(studentServiceImpl.getstudent(SessionUtil.SessionGetid(session)));
    }

    /**
     *
     * 功能描述: 修改密码
     *
     * @param: session,pwd
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 13:26
     */
    @PostMapping("/pwd")
    @ResponseBody
    public Result changpwd(HttpSession session,@RequestParam("pwd")String pwd){
        studentServiceImpl.changepwd(SessionUtil.SessionGetid(session),pwd);
        return ResultUtil.success();
    }
   /**
    *
    * 功能描述: 修改手机号码
    *
    * @param: session,phone
    * @return:
    * @auther: 陆拾壹
    * @date: 2019/3/21 13:25
    */
    @PostMapping("/phone")
    @ResponseBody
    public Result changphone(HttpSession session,@RequestParam("phone")String phone){
        studentServiceImpl.changephone(SessionUtil.SessionGetid(session),phone);
        return ResultUtil.success();
    }
    /**
     *
     * 功能描述: 学生获取自己的申诉列表
     *
     * @param:
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 13:30
     */
    @GetMapping("/appeal")
    @ResponseBody
    public Result getappeal(HttpSession session){
        return ResultUtil.success(studentServiceImpl.getappeal(SessionUtil.SessionGetid(session)));
    }
    /**
     *
     * 功能描述: 学生添加申诉记录
     *
     * @param:
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 13:35
     */
    @PostMapping("/appeal")
    @ResponseBody
    public Result addappeal(HttpSession session, AppealEntity appealEntity){
        studentServiceImpl.addappeal(SessionUtil.SessionGetid(session),appealEntity);
        return ResultUtil.success();
    }
    /**
     *
     * 功能描述: 学生删除申诉记录
     *
     * @param:
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 13:39
     */
    @GetMapping("/appeal/{id}")
    @ResponseBody
    public Result deleteappeal(HttpSession session,@PathVariable("id")long fraid){
        studentServiceImpl.deleteappeal(SessionUtil.SessionGetid(session),fraid);
        return ResultUtil.success();
    }
    /**
     *
     * 功能描述: 获取公告信息(不包含删除)
     *
     * @param:
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 19:05
     */
    @GetMapping("/notice")
    @ResponseBody
    public Result getnotice(){
        return ResultUtil.success(studentServiceImpl.getnotice());
    }

    /**
     * 获取个人头像
     */
    @RequestMapping(value = "/getpic",produces = MediaType.IMAGE_JPEG_VALUE)
    @ResponseBody
    public BufferedImage getImage(HttpSession session) throws IOException {
        UserEntity userEntity=(UserEntity)session.getAttribute("UserId");
        /**判断头像是否存在*/
        return ImageIO.read(new FileInputStream(new File("e:/005CmNjegy1fw48i46d6dj30u01401kx.jpg")));
    }

    /**
     * 上传个人头像
     */
    @RequestMapping(value = "/sendpic")
    @ResponseBody
    public Result sendImage(HttpServletRequest req,
                            HttpSession session,
                            @RequestParam("file") MultipartFile file){
        //accept="image/*"
        //1. 接受上传的文件  @RequestParam("file") MultipartFile file
        //2.根据时间戳创建新的文件名,这样即便是第二次上传相同名称的文件,也不会把第一次的文件覆盖了
        //3.通过req.getServletContext().getRealPath("") 获取当前项目的真实路径,然后拼接前面的文件名
        UserEntity userEntity=(UserEntity)session.getAttribute("UserId");
        String fileName = userEntity.getId()+"-"+System.currentTimeMillis();
        String destFileName = req.getServletContext().getRealPath("") + "uploaded" + File.separator + fileName;
        return ResultUtil.success();
    }

    /**获取班级总表*/
    @GetMapping("/table")
    @ResponseBody
    public Result table(HttpSession session){
        return ResultUtil.success(tableServiceImpl.gettable(SessionUtil.SessionGetgroupid(session)));
    }
    /**新增加分页面的获取加分记录数量的api*/
    @GetMapping("/add_record_panel")
    @ResponseBody
    public Result addRecordPanel(HttpSession session){
        return ResultUtil.success(studentServiceImpl.addRecordPannel(SessionUtil.SessionGetid(session)));
    }
}
/**管理员和审核员专用*/
@Controller
@RequestMapping("/mapi")

public class ApiForManagerController {

    @Autowired
    FractionDao fractionDao;
    @Autowired
    ManagerServiceImpl managerServiceImpl;
    /**
     *
     * 功能描述: [分页]审核员获取未审核的加分列表(已拒绝和申诉中不在其中)
     *
     * @param:start哪一页,从0开始,size,多大的页数
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 19:18
     */
    @GetMapping("/fraction")
    @ResponseBody
    public Result getfraction(@PageableDefault(page=0,size=10,direction = Sort.Direction.DESC,sort="stuid")Pageable pageable){
        return ResultUtil.success(managerServiceImpl.selectfraction(pageable));
    }
    /**
     *
     * 功能描述: 审核员拒绝或通过某条记录,传过来三个参数,id(指的是加分记录的id),remark,state
     *
     * @param:
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 19:40c
     */
    @PostMapping("/fraction")
    @ResponseBody
    public Result detailfraction(FractionEntity fractionEntity){
        managerServiceImpl.detailfraction(fractionEntity);
        return ResultUtil.success();
    }
    /**
     *
     * 功能描述: 审核通过或拒绝某个学生的申诉,传过来三个参数,id,deal(拒绝2,通过0),reply-回复理由
     *
     * @param:
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 13:58
     */
    @PostMapping("/appeal")
    @ResponseBody
    public Result setappeal(AppealEntity appealEntity){
        managerServiceImpl.setappeal(appealEntity);
        return ResultUtil.success();
    }
    /**
     *
     * 功能描述: 管理员获取所有未处理的申诉列表
     *
     * @param:start哪一页,从0开始,size,多大的页数
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 14:01
     */
    @GetMapping("/appeal")
    @ResponseBody
    public Result getappeal(@RequestParam(value="start",defaultValue="0")int start,@RequestParam(value = "size", defaultValue = "5") int size){
        return ResultUtil.success(managerServiceImpl.getappeal(start,size));
    }

    /**
     *
     * 功能描述: 获取所有公告列表(包含删除)
     *
     * @param:
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 19:14
     */
    @GetMapping("/notice")
    @ResponseBody
    public Result getnotice(){
        return ResultUtil.success(managerServiceImpl.getnotice());
    }

    /**
     *
     * 功能描述: 添加公告
     *
     * @param:
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 19:08
     */
    @PostMapping("/notice")
    @ResponseBody
    public Result addnotice(NoticeEntity noticeEntity){
        managerServiceImpl.addnotice(noticeEntity);
        return ResultUtil.success();
    }

    /**
     *
     * 功能描述: 删除公告
     *
     * @param:
     * @return:
     * @auther: 陆拾壹
     * @date: 2019/3/21 19:10
     */
    @GetMapping("/notice/{id}")
    @ResponseBody
    public Result deletenotice(@PathVariable("/id")long id){
        managerServiceImpl.deletenotice(id);
        return ResultUtil.success();
    }

    @PostMapping("/file")
    @ResponseBody
    public Result postfile(@RequestParam("file") MultipartFile file)throws IllegalStateException, IOException{
        if (file.isEmpty()) {
            return ResultUtil.error(ResultEnum.FILE_ERROR);
        }
        String fileName = file.getOriginalFilename();
        String filePath = "e:/";
        File dest = new File(filePath + fileName);
        try {
            file.transferTo(dest);
            return ResultUtil.success();
        } catch (IOException e) {
            System.out.println(e.getMessage());
            throw new MyException(ResultEnum.FILE_ERROR);
        }
    }

    /**测试分页*/
    @GetMapping("/list")
    @ResponseBody
    public Result list(@PageableDefault(page=0,size=5,direction = Sort.Direction.DESC,sort="stuid")Pageable pageable) {
        //Pageable pageable = new PageRequest(currentPage, pagesize, Sort.Direction.DESC, "stuid");
        Page<FractionEntity> listPage=fractionDao.findAll(pageable);
        Page<FractionEntity> listPage2=fractionDao.findByStateGreaterThan(0,pageable);
        return ResultUtil.success(listPage2);
    }

    /**随机添加数据*/
    @GetMapping("/random")
    @ResponseBody
    public Result random(){
        Random rnd = new Random();
        for(int i=0;i<=1000;i++){
            FractionEntity fractionEntity=new FractionEntity();
            fractionEntity.setState(1);
            fractionEntity.setStuid(123);
            fractionEntity.setDegree("省级");
            fractionEntity.setFractionnum(rnd.nextInt(50));
            fractionEntity.setProof(0);
            fractionEntity.setUnit("加分单位");
            fractionEntity.setDetail("这是加分内容"+rnd.nextInt(5000));
            fractionDao.save(fractionEntity);
        }
        return  ResultUtil.success();
    }


}

 

posted @ 2019-03-31 20:19  学习记录2019  阅读(216)  评论(0编辑  收藏  举报