/*
 * Copyright 2002-2016 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.zuoxiaolong.blog.api.controller;

import com.zuoxiaolong.blog.model.dto.MessageBoxDto;
import com.zuoxiaolong.blog.model.persistent.MessageBox;
import com.zuoxiaolong.blog.model.persistent.WebUser;
import com.zuoxiaolong.blog.service.MessageBoxService;
import org.aspectj.bridge.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestBody;
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.servlet.ModelAndView;

import java.util.ArrayList;
import java.util.List;

/**
 * @author iCodingStar
 * @date 2016/6/25 13:20
 * @since 1.0.0
 */
@RequestMapping("/Message")
@Controller
public class MessageBoxController extends AbstractApiController{
    @Autowired
    private MessageBoxService messageBoxService;

    /***
     * 查看信息箱消息内容
     *
     * @param model
     * @param id
     * @return
     */
    @RequestMapping(value = "/Content", method = RequestMethod.GET)
    public MessageBoxDto getMessageContent(Model model, @RequestParam("id") Integer id) {
        return messageBoxService.getMessageContentById(id);
    }

    /***
     * 分页参看消息列表
     *
     * @param currentPageNumber
     * @param pageSize
     * @param messageBox
     * @return
     */
    @RequestMapping(value = "/List", method = RequestMethod.GET)
    public List<MessageBoxDto> getMessageList(@RequestParam(required = false) Integer currentPageNumber,
                                              @RequestParam(required = false) Integer pageSize,
                                              MessageBox messageBox) {
        messageBox.setSender(getWebUserId());
        return messageBoxService.getMessagesByPage(currentPageNumber, pageSize, messageBox);
    }

    /***
     * 发送短消息
     *
     * @param messageBoxDto
     * @return
     */
    @RequestMapping(value = "/Send", method = RequestMethod.POST)
    public Integer sendMessage(MessageBoxDto messageBoxDto) {

        return messageBoxService.sendMessage(messageBoxDto);
    }

    /***
     * 修改短消息状态
     * 1:已读
     * 2:未读
     * 3:接收者已删除
     * 4:发送者已删除
     * 5:已删除
     *
     * @param messageBox
     * @return
     */
    @RequestMapping(value = "/Update", method = RequestMethod.DELETE)
    public Integer updateMessageStatus(MessageBox messageBox) {
        return messageBoxService.updateMessageStatus(messageBox);
    }
}

@@ -802,121 +802,32 @@
 log.
-model.persistent.WebUser;%0Aimport com.zuoxiaolong.blog.service.MessageBoxService;%0Aimport org.aspectj.bridge.Messag
+service.MessageBoxServic
 e;%0Ai
@@ -942,105 +942,8 @@
 er;%0A
-import org.springframework.ui.Model;%0Aimport org.springframework.web.bind.annotation.RequestBody;%0A
 impo
@@ -1128,89 +1128,8 @@
 am;%0A
-import org.springframework.web.servlet.ModelAndView;%0A%0Aimport java.util.ArrayList;
 %0Aimp
@@ -1324,16 +1324,17 @@
 ntroller
+ 
 %7B%0A    @A
@@ -1429,28 +1429,8 @@
   *%0A
-     * @param model%0A
     
@@ -1580,21 +1580,8 @@
 ent(
-Model model, 
 @Req
@@ -2413,32 +2413,33 @@
 Send%22, method = 
+%7B
 RequestMethod.PO
@@ -2440,16 +2440,36 @@
 hod.POST
+, RequestMethod.GET%7D
 )%0A    pu
@@ -2524,17 +2524,16 @@
 xDto) %7B%0A
-%0A
         
@@ -2780,32 +2780,33 @@
 date%22, method = 
+%7B
 RequestMethod.DE
@@ -2807,14 +2807,32 @@
 hod.
-DELETE
+POST, RequestMethod.GET%7D
 )%0A  

修正MessageBox api