首页>代码>SSH+JSP 图书管理系统>/src/com/lhq/prj/bms/action/CompanyAction.java
package com.lhq.prj.bms.action;

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

import com.lhq.prj.bms.core.BaseAction;
import com.lhq.prj.bms.core.MyUtils;
import com.lhq.prj.bms.core.Page;
import com.lhq.prj.bms.po.Company;
import com.lhq.prj.bms.service.ICompanyService;

@SuppressWarnings("serial")
public class CompanyAction extends BaseAction {

	private ICompanyService companyService;

	private boolean success;

	private Company company;

	private Page page;

	private Integer companyId;

	/**
	 * 添加分公司
	 * 
	 * @return
	 */
	public String saveCompany() {
		companyId = (Integer) companyService.saveCompany(company);
		if (companyId != null) {
			success = true;
		}
		return SUCCESS;
	}
	
	/**
	 * 查找所有公司
	 * 
	 * @return
	 */
	public String findAll(){
		page = new Page();
		page.setRoot(companyService.findAll());
		return SUCCESS;
	}

	/**
	 * 根据条件分页查找公司
	 * 
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public String findAllCompany() {
		String strCondition = getRequest().getParameter("conditions");	//获得传递过来的参数,多个参数用空格隔开
		List conditions = new ArrayList();
		MyUtils.addToCollection(conditions, MyUtils.split(strCondition, " ,"));
		page = new Page(); // 实例化分页对象
		page.setConditions(conditions);// 设置查询条件
		int start = Integer.valueOf(getRequest().getParameter("start"));
		int limit = Integer.valueOf(getRequest().getParameter("limit"));
		page.setStart(++start);
		page.setLimit(limit = limit == 0 ? 20 : limit);
		page = companyService.findByPage(page);
		if (null != page.getRoot()) {
			page.setSuccess(true);
		}
		return SUCCESS;
	}

	/**
	 * 删除公司
	 * 
	 * @return
	 */
	public String deleteCompany() {
		String strCompanyId = getRequest().getParameter("companyId");
		if (strCompanyId != null && !"".equals(strCompanyId)) {
			success = companyService.deleteCompany(Integer.valueOf(strCompanyId));
		}
		return SUCCESS;
	}

	/**
	 * 修改公司指定字段的值
	 * 
	 * @return
	 * @throws Exception
	 */
	public String updateCompany() throws Exception {
		String fieldName = getRequest().getParameter("fieldName");
		String fieldValue = getRequest().getParameter("fieldValue");
		String strCompanyId = getRequest().getParameter("companyId");
		if (strCompanyId != null && !"".equals(strCompanyId)) {
			Company c = new Company();
			c.setCompanyId(Integer.valueOf(strCompanyId));
			MyUtils.invokeSetMethod(fieldName, c, new Object[] { fieldValue });
			success = companyService.updateCompany(c);
		}
		return SUCCESS;
	}
	

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public Company getCompany() {
		return company;
	}

	public void setCompany(Company company) {
		this.company = company;
	}

	public void setCompanyService(ICompanyService companyService) {
		this.companyService = companyService;
	}

	public Integer getCompanyId() {
		return companyId;
	}

	public void setCompanyId(Integer companyId) {
		this.companyId = companyId;
	}

	public Page getPage() {
		return page;
	}

	public void setPage(Page page) {
		this.page = page;
	}

}
最近下载更多
wxy1995  LV2 2023年4月27日
齐吊大神  LV6 2022年12月19日
ken8lee  LV3 2022年5月24日
郭海亮  LV1 2022年5月9日
孙有才  LV1 2022年5月3日
缪亦豪  LV1 2022年4月27日
微信网友_5934495911317504  LV1 2022年4月27日
qwertyuiopwyd  LV3 2022年3月29日
林祎凯马群耀  LV1 2021年12月2日
2209367302  LV1 2021年11月26日
最近浏览更多
momomo228  LV2 2024年11月22日
LoveSummer  LV6 2024年10月31日
040313  LV1 2024年10月26日
微信网友_7005760998215680  LV6 2024年8月31日
quartz  LV8 2024年6月18日
gaowang  LV1 2024年5月29日
wj3679  LV13 2024年2月28日
jhyan127 2024年2月18日
暂无贡献等级
duoduo1234  LV2 2024年1月16日
1587039373  LV3 2024年1月4日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友