com.dlshouwen.tdjs.content.controller.TdjsArtCheckController.java Source code

Java tutorial

Introduction

Here is the source code for com.dlshouwen.tdjs.content.controller.TdjsArtCheckController.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.dlshouwen.tdjs.content.controller;

import com.dlshouwen.core.base.config.CONFIG;
import com.dlshouwen.core.base.extra.grid.model.Pager;
import com.dlshouwen.core.base.extra.grid.utils.PagerPropertyUtils;
import com.dlshouwen.core.base.model.AjaxResponse;
import com.dlshouwen.core.base.model.OperationType;
import com.dlshouwen.core.base.model.SessionUser;
import com.dlshouwen.core.base.utils.AttributeUtils;
import com.dlshouwen.core.base.utils.LogUtils;
import com.dlshouwen.core.system.dao.UserDao;
import com.dlshouwen.core.system.model.User;
import com.dlshouwen.core.team.dao.TeamDao;
import com.dlshouwen.core.team.model.Team;
import com.dlshouwen.tdjs.channel.dao.ChannelDao;
import com.dlshouwen.tdjs.channel.model.Channel;
import com.dlshouwen.tdjs.content.dao.ArticleDao;
import com.dlshouwen.tdjs.content.model.Article;
import com.dlshouwen.tdjs.picture.dao.PictureDao;
import com.dlshouwen.tdjs.picture.model.Picture;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author admin
 */
@Controller
@RequestMapping("/tdjs/tdjsArticle/articleCheck")
public class TdjsArtCheckController {

    /**
     * 
     */
    private String basePath = "tdjs/article/";

    private ArticleDao dao;

    @Resource(name = "tdjsArticleDao")
    public void setDao(ArticleDao dao) {
        this.dao = dao;
    }

    private PictureDao pictureDao;

    @Resource(name = "TdjsPictureDao")
    public void setPictureDao(PictureDao pictureDao) {
        this.pictureDao = pictureDao;
    }

    private ChannelDao channelDao;

    /**
     * ??
     */
    @Resource(name = "TdjsChannelDao")
    public void setChannelDao(ChannelDao channelDao) {
        this.channelDao = channelDao;
    }

    private TeamDao teamDao;

    @Resource(name = "teamDao")
    public void setTeamDao(TeamDao teamDao) {
        this.teamDao = teamDao;
    }

    private UserDao userDao;

    @Resource(name = "userDao")
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    /**
     * ?
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "", method = RequestMethod.GET)
    public String goArticlePage(HttpServletRequest request) throws Exception {

        //       ?
        LogUtils.updateOperationLog(request, OperationType.VISIT, "??");
        return basePath + "artCheckList";
    }

    /**
     * ??
     *
     * @param gridPager ?
     * @param request 
     * @param response ?
     * @throws Exception 
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public void getArticleList(String gridPager, HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        //          ??
        SessionUser sessionUser = (SessionUser) request.getSession().getAttribute(CONFIG.SESSION_USER);
        User user = userDao.getUserById(sessionUser.getUser_id());
        //          Pager
        Pager pager = PagerPropertyUtils.copy(JSONObject.fromObject(gridPager));
        //          ??(?)
        if (StringUtils.isNotEmpty(user.getIdentity()) && user.getIdentity().equals("1")) {
            if (StringUtils.isEmpty(user.getTeam_id())) {//?
                dao.getCheckArticleList(pager, request, response);
            } else {//?
                dao.getCheckArticleList(pager, request, response, true, user.getTeam_id(), user.getUser_id());
            }
        } else if (StringUtils.isNotEmpty(user.getIdentity()) && user.getIdentity().equals("0")
                && StringUtils.isNotEmpty(user.getTeam_id())) {//
            dao.getCheckArticleList(pager, request, response, false, user.getTeam_id(), user.getUser_id());
        }

        //          ?
        LogUtils.updateOperationLog(request, OperationType.SEARCH,
                "????");
    }

    /**
     * ?
     *
     * @param articleId ?
     * @param request 
     * @return base + 'editAnnouncement'
     * @throws Exception 
     */
    @RequestMapping(value = "/{articleId}/check", method = RequestMethod.GET)
    public ModelAndView checkArticle(@PathVariable String articleId, HttpServletRequest request,
            HttpServletResponse response) throws Exception {
        ModelAndView view = new ModelAndView("/tdjs/content/articleDetail.btl");
        String sourcePath = AttributeUtils.getAttributeContent(request.getServletContext(),
                "source_webapp_file_postion");
        //   ??
        Article article = dao.getArticleById(articleId);

        String channel_id = article.getChannel_id();
        Channel channelNow = channelDao.getChannelById(channel_id);

        String teamId = article.getTeam_id();
        Team teamNow = teamDao.getTeamById(teamId);

        List<Map<String, Object>> allChannel = channelDao.getChannelListByTeamId(teamId);
        List<Picture> pictureList = pictureDao.getPictureByAlbumId(articleId);
        if (null == pictureList || pictureList.size() == 0) {
            pictureList = null;
        }
        view.addObject("teamNow", teamNow);
        view.addObject("allChannel", allChannel);
        view.addObject("article", article);
        view.addObject("channelNow", channelNow);
        view.addObject("pictureList", pictureList);
        view.addObject("SOURCEPATH", sourcePath);

        //      ?
        LogUtils.updateOperationLog(request, OperationType.VISIT, "?");
        return view;
    }

    /**
     * 
     */
    @RequestMapping(value = "/{articleId}/pass", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResponse checkArticlePass(@PathVariable String articleId, HttpServletRequest request)
            throws Exception {
        //      AJAX?
        AjaxResponse ajaxResponse = new AjaxResponse();
        //??
        SessionUser sessionUser = (SessionUser) request.getSession().getAttribute(CONFIG.SESSION_USER);
        String user_name = sessionUser.getUser_name();
        Date date = new Date();
        String check_comment = request.getParameter("check_comment");

        String aid[] = articleId.split(",");
        for (String atcId : aid) {
            dao.ArtTypePass(user_name, date, atcId, check_comment);
        }
        //      ????
        ajaxResponse.setSuccess(true);
        ajaxResponse.setSuccessMessage("?");

        //      ?
        LogUtils.updateOperationLog(request, OperationType.VISIT, "?");
        return ajaxResponse;
    }

    /**
     * 
     *
     */
    @RequestMapping(value = "/{articleId}/refuse", method = RequestMethod.POST)
    @ResponseBody
    public AjaxResponse checkArticleRefuse(@PathVariable String articleId, HttpServletRequest request)
            throws Exception {
        AjaxResponse ajaxResponse = new AjaxResponse();
        SessionUser sessionUser = (SessionUser) request.getSession().getAttribute(CONFIG.SESSION_USER);
        String user_name = sessionUser.getUser_name();
        Date date = new Date();
        String check_comment = request.getParameter("check_comment");
        String aid[] = articleId.split(",");
        for (String atcId : aid) {
            dao.ArtTypereRefuse(user_name, date, atcId, check_comment);
        }

        ajaxResponse.setSuccess(true);
        ajaxResponse.setSuccessMessage("?");

        //      ?
        LogUtils.updateOperationLog(request, OperationType.VISIT, "?");
        return ajaxResponse;
    }

    //???
    @RequestMapping(value = "/note", method = RequestMethod.GET)
    public String openNotePage(HttpServletRequest request) throws Exception {
        LogUtils.updateOperationLog(request, OperationType.UPDATE, "?");
        return basePath + "note";
    }

}