public class EmployUnitBaseInfo
{???
?
??? private long ID; //用人單位系統(tǒng)編號---邏輯主鍵
??? private String unitCode; //用人單位代號--業(yè)務(wù)主鍵
}
1、??? 使用邏輯主鍵,分頁比較方便
2、??? 有可能unitcode會(huì)改變,用id可以保證當(dāng)unitcode改變時(shí),這個(gè)實(shí)體還存在
在頁面上必須返回workpost + demandid,,
pojo 中的demand類如下:只有以下屬性的setter和getter
??? private String usedNeedNum;
??? private int unitId;
??? private String demandInfo;
private long ID;
??? private String needNum;
??? private String position;
必須再添加一個(gè)屬性demandInfo,
而在另一個(gè)畢業(yè)生申報(bào)中又要如圖上操作,,如何在service層向頁面層傳遞這些信息(測試程序員(剩2需求數(shù)))
public class DemandServiceImpl
??? extends BaseServiceImpl implements DemandService{
??? public List getDemandList(int unitId)
??? {
????????? long demandId;
????????? int needNum;
????????? int usedNeedNum;
????????? int lastNum;
?????????
????????? String demandInfo;
????????? TRealDemandDAOImpl dao = (TRealDemandDAOImpl) this.getBaseDAO();
????????? List list = dao.getSpareDemandByUnitId(unitId);
????????? Iterator it = list.iterator();
????????? while(it.hasNext())
????????? {
????????????? TRealDemand demand = (TRealDemand) it.next();
????????????? demandId = demand.getID();
????????????? needNum =? Integer.parseInt(demand.getNeedNum());?
????????????? usedNeedNum = Integer.parseInt(demand.getUsedNeedNum());
????????????? if(needNum>usedNeedNum)
????????????? {
????????????????? lastNum = usedNeedNum-needNum;
????????????????? demandInfo = demand.getPosition()+" 剩 " + lastNum +" 需求數(shù) ";
????????????? }
?????????????
????????? }
????????? return list;
??? }
}
在action層再通過以下代碼向頁面?zhèn)鬟f數(shù)據(jù):
DemandService demandService = (DemandService) this.getBean("DemandService");
?request.setAttribute("demandList",demandService.findDemandListByUnitId(unitInfo.getID()));
4、注意DemandServiceImpl 是實(shí)現(xiàn)類,DemandService 是interface
DemandService demandService = (DemandService) this.getBean("DemandService");
和DemandServiceImpl demandService = (DemandServiceImpl) this.getBean("DemandService");
雖然兩個(gè)的操作一樣,但是demandService是接口但可以執(zhí)行相應(yīng)的操作,起到黑箱子的作用。
5、記得在action中添加一個(gè)實(shí)體時(shí),要通過idcard取得sex和birthday的屬性加到內(nèi)存中(表相對應(yīng)的pojo)