InformationController.java 3.45 KB
package com.server.web.controller;

import com.server.web.common.model.TKzyUser;
import com.server.web.common.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * Created by weiwenfu@163.com on 2020/3/12 下午 4:53.
 */
@RestController
@RequestMapping(value = BaseController.WX_NAMESPACE + "/information", produces = "application/json")
public class InformationController extends BaseController {
    @Autowired
    private InformationService informationService;

    /**
     * 二级分类
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/secondClassList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
    public Map<String, Object> secondClassList(HttpServletRequest request, @RequestParam(value = "firstId") Long firstId) {
        return informationService.secondClassList(firstId);
    }

    /**
     * 二级分类详情
     *
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/secondClassDetail", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
    public Map<String, Object> secondClassDetail(HttpServletRequest request, @RequestParam(value = "secondId") Long secondId,
                                                 @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) {
        return informationService.secondClassDetail(secondId, pageNo, pageSize);
    }

    /**
     * 资讯详情
     *
     * @param request
     * @param informationId
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/informationDetail", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
    public Map<String, Object> informationDetail(HttpServletRequest request, @RequestParam(value = "informationId") Long informationId) {
        return informationService.informationDetail(informationId);
    }

    /**
     * 资讯评论列表
     *
     * @param request
     * @param informationId
     * @param pageNo
     * @param pageSize
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/informationCommentList", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
    public Map<String, Object> informationCommentList(HttpServletRequest request, @RequestParam(value = "informationId") Long informationId,
                                                      @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize") Integer pageSize) {
        return informationService.informationCommentList(informationId, pageNo, pageSize);
    }

    /**
     * 资讯提交评论
     *
     * @param informationId
     * @param comment
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/informationComment", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json")
    public Map<String, Object> informationComment(HttpServletRequest request, @RequestParam(value = "informationId") Long informationId, @RequestParam(value = "comment") String comment) {
        TKzyUser tKzyUser = getLoginUser(request);
        Long userId = null;
        if (tKzyUser != null) {
            userId = tKzyUser.getId();
        }
        return informationService.informationComment(informationId, userId, comment);
    }

}