Search in sources :

Example 1 with RaCaPassCode

use of com.itrus.portal.entity.RaCaPassCode in project portal by ixinportal.

the class PasscodeController method list.

// 2.统计passcode情况
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    if (page == null || page < 1) {
        page = 1;
    }
    if (size == null || size < 1) {
        size = 10;
    }
    RaAccountInfoExample raiExample = new RaAccountInfoExample();
    // RaAccountInfoExample.Criteria raiCriteria = raiExample.or();
    Integer count = sqlSession.selectOne("com.itrus.portal.db.RaAccountInfoMapper.countByExample", raiExample);
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    Integer offset = size * (page - 1);
    raiExample.setOffset(offset);
    raiExample.setLimit(size);
    raiExample.setOrderByClause("create_time desc");
    List<RaAccountInfo> raAccountInfos = sqlSession.selectList("com.itrus.portal.db.RaAccountInfoMapper.selectByExample", raiExample);
    List<RaCaPassCode> racaPassCodes = new ArrayList<RaCaPassCode>();
    for (RaAccountInfo rai : raAccountInfos) {
        RaCaPassCode raca = new RaCaPassCode();
        // 设置部门
        raca.setOrganization(rai.getOrganization());
        // 设置单位
        raca.setOrgUnit(rai.getOrgUnit());
        // 设置ra部门id
        raca.setRaAccountInfoId(rai.getId());
        CaPasscodeExample cpExample = new CaPasscodeExample();
        CaPasscodeExample.Criteria caCriteria = cpExample.or();
        caCriteria.andRaAccountInfoEqualTo(rai.getId());
        Integer caPasscodeNum = sqlSession.selectOne("com.itrus.portal.db.CaPasscodeMapper.countByExample", cpExample);
        // 设置总数量
        raca.setCaPasscodeNum(caPasscodeNum);
        // 2表示已使用的passcode
        caCriteria.andStatusEqualTo(2);
        Integer usedCodeNum = sqlSession.selectOne("com.itrus.portal.db.CaPasscodeMapper.countByExample", cpExample);
        // 设置已使用的数量
        raca.setUsedCodeNum(usedCodeNum);
        // if (caPasscodeNum != 0)// 显示passcode总数不为0的记录
        racaPassCodes.add(raca);
    }
    uiModel.addAttribute("racaPassCodes", racaPassCodes);
    uiModel.addAttribute("itemcount", racaPassCodes.size());
    return "passcode/list";
}
Also used : RaAccountInfo(com.itrus.portal.db.RaAccountInfo) RaAccountInfoExample(com.itrus.portal.db.RaAccountInfoExample) ArrayList(java.util.ArrayList) CaPasscodeExample(com.itrus.portal.db.CaPasscodeExample) RaCaPassCode(com.itrus.portal.entity.RaCaPassCode) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

CaPasscodeExample (com.itrus.portal.db.CaPasscodeExample)1 RaAccountInfo (com.itrus.portal.db.RaAccountInfo)1 RaAccountInfoExample (com.itrus.portal.db.RaAccountInfoExample)1 RaCaPassCode (com.itrus.portal.entity.RaCaPassCode)1 ArrayList (java.util.ArrayList)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1