package com.yc17.office.action;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionContext;
import com.yc17.office.bean.Addressclass;
import com.yc17.office.bean.Addresslist;
import com.yc17.office.bean.Departmentinfo;
import com.yc17.office.bean.Dutyinfo;
import com.yc17.office.bean.Userinfo;
import com.yc17.office.service.AddressService;
public class AddressAction {
private AddressService addressService;
private Addressclass addressclass;
private List<Addressclass> addressList;
private List<Departmentinfo> departmentList;
private List<Dutyinfo> dutyList;
private String aid;
private Addresslist lists;
private List<Addresslist> adList;
public AddressService getAddressService() {
return addressService;
}
public void setAddressService(AddressService addressService) {
this.addressService = addressService;
}
public Addressclass getAddressclass() {
return addressclass;
}
public void setAddressclass(Addressclass addressclass) {
this.addressclass = addressclass;
}
public List<Addressclass> getAddressList() {
return addressList;
}
public void setAddressList(List<Addressclass> addressList) {
this.addressList = addressList;
}
public List<Departmentinfo> getDepartmentList() {
return departmentList;
}
public void setDepartmentList(List<Departmentinfo> departmentList) {
this.departmentList = departmentList;
}
public List<Dutyinfo> getDutyList() {
return dutyList;
}
public void setDutyList(List<Dutyinfo> dutyList) {
this.dutyList = dutyList;
}
public String getAid() {
return aid;
}
public void setAid(String aid) {
this.aid = aid;
}
public Addresslist getLists() {
return lists;
}
public void setLists(Addresslist lists) {
this.lists = lists;
}
public List<Addresslist> getAdList() {
return adList;
}
public void setAdList(List<Addresslist> adList) {
this.adList = adList;
}
//保存通讯录
public String addresslistSave() {
String classname=addressclass.getClassname();
if(addressService.addresslistSave(classname)){
return "aclass";
}else{
return "errof";
}
}
//分类
public String getAclass(){ //通讯类别
addressList=addressService.getAclass();
return "aclass";
}
public String deleteaddress(){ //删除通讯类别
addressService.deleteaddress(aid);
return "delete";
}
//获得部门
public String getDepartment(){
departmentList=addressService.getDepartment();
return "aclass";
}
//获得职务
public String getDuty(){
dutyList=addressService.getDuty();
return "aclass";
}
//新建联系人
public String addressSave(){
String aname=lists.getAname();
HttpServletRequest request=ServletActionContext.getRequest();
String classid=request.getParameter("classid");
String dutyid=request.getParameter("dutyid");
Addressclass ads=new Addressclass();
ads.setAid(classid);
Dutyinfo dtf=new Dutyinfo();
dtf.setDid(dutyid);
String unit=lists.getUnit();
System.out.println("classid:"+classid);
System.out.println("dutyid:"+dutyid);
System.out.println("unit:"+unit);
String officeaddress=lists.getOfficeaddress();
String hometel=lists.getHometel();
String officetel=lists.getOfficetel();
String mobil=lists.getMobil();
String fax=lists.getFax();
String postcode=lists.getPostcode();
String email=lists.getEmail();
String homeaddress=lists.getHomeaddress();
String note=lists.getNote();
Map session=ActionContext.getContext().getSession();
String userid=(String)session.get("suserId");
Userinfo users=new Userinfo();
users.setUserid(userid);
if(addressService.addressSave(aname, ads, dtf, unit,
officeaddress, hometel, officetel, mobil, fax,
postcode, email, homeaddress, note, users)){
return "address";
}else{
return "erro";
}
}
//获取联系人
public String getlist(){
Map session=ActionContext.getContext().getSession();
String userid=(String)session.get("suserId");
adList=addressService.getlist(userid);
return "list";
}
//删除联系人
public String deleteAds(){
addressService.deleteAds(aid);
return "del";
}
}