日期:2014-05-16 浏览次数:20498 次
package com.lvmama.back.sweb.knowledge;
import java.io.IOException;
import java.util.List;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import com.lvmama.back.service.InfoService;
import com.lvmama.back.sweb.BaseAction;
import com.lvmama.common.info.po.InfoNormalQues;
import com.lvmama.common.info.po.InfoQuesType;
@ParentPackage("json-default")
@Results({
@Result(name = "list", location = "/WEB-INF/pages/back/knowledge/faq/list.jsp")
})
public class FAQAction extends BaseAction{
/**
*
*/
private static final long serialVersionUID = -5531045656847240119L;
private InfoService infoService;
private List<InfoNormalQues> rows;
private List<InfoQuesType> typeList;
private String title;
private Long type;
private InfoNormalQues faq;
private String result;
private String userName;
//private String rows;
//private JSONArray jsonArray;
@Action("/faq/toFaqList")
public String toFaqList(){
if (this.getSessionUser()!=null) {
this.userName = this.getSessionUser().getLoginName();
}
this.typeList = infoService.selectByObjectType("INFO_QUES_NORMAL");
return "list";
}
@Action("/faq/queryFaqList")
public String queryFaqList(){
//this.normalList = infoService.selectByTitleAndType(title, type);
this.typeList = infoService.selectByObjectType("INFO_QUES_NORMAL");
return "list";
}
@Action(value="/faq/queryjsonList",results=@Result(type="json",name="jsonlist",params={"includeProperties","rows.*"}))
public String queryjsonList(){
this.rows = infoService.selectByTitleAndTypeForNormal(title, type);
return "jsonlist";
}
@Action("/faq/saveFAQInfo")
public void saveOrUpdateFAQInfo() throws IOException{
try{
if (this.faq.getId()!=null&&!"".equals(this.faq.getId())) {
infoService.updateFAQ(faq);
} else {
infoService.insertFAQ(this.faq);
}
this.getResponse().getWriter().write("{result:true}");
}catch(Exception ex){
ex.printStackTrace();
this.getResponse().getWriter().write("{result:false}");
}
}
@Action("/faq/remove")
public void removeFAQ() throws IOException{
try{
infoService.removeFAQ(faq.getId());
this.getResponse().getWriter().write("{result:true}");
}catch(Exception ex){
this.getResponse().getWriter().write("{result:false}");
}
}
@Action(value="/faq/edit",results=@Result(type="json",name="edit",params={"includeProperties","faq.*"}))
public String findFAQByPK(){
this.faq = infoService.getFAQByPk(faq.getId());
return "edit";
}
public void setInfoService(InfoService infoService) {
this.infoService = infoService;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public Long getType() {
return type;
}
public void setType(Long type) {
this.type = type;
}
public List<InfoQuesType> getTypeList() {
return typeList;
}
public void setTypeList(List<InfoQuesType> typeList) {
this.typeList = typeList;
}
public List<InfoNormalQues> getRows() {
return rows;
}
public void setRows(List<InfoNormalQues> rows) {
this.rows = rows;
}
public InfoNormalQues getFaq() {
return faq;
}
public void setFaq(InfoNormalQues faq) {
this.faq = faq;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
?