Search in sources :

Example 16 with ProjectExample

use of com.itrus.portal.db.ProjectExample in project portal by ixinportal.

the class AdminController method list.

// 列表所有信息
@RequestMapping(produces = "text/html")
public String list(@Valid Admin admin, @RequestParam(value = "project", required = false) Long project, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    uiModel.addAttribute("project", project);
    uiModel.addAttribute("adminRole", admin.getAdminRole());
    uiModel.addAttribute("status", admin.getStatus());
    uiModel.addAttribute("account", admin.getAccount());
    uiModel.addAttribute("name", admin.getName());
    // page,size
    if (page == null || page < 1)
        page = 1;
    if (size == null || size < 1)
        size = 10;
    AdminExample adminex = new AdminExample();
    AdminExample.Criteria criteria = adminex.or();
    if (project != null && project > 0)
        criteria.andProjectEqualTo(project);
    if (admin.getAdminRole() != null && admin.getAdminRole() > 0) {
        criteria.andAdminRoleEqualTo(admin.getAdminRole());
    }
    if (admin.getStatus() != null && admin.getStatus().length() > 0)
        criteria.andStatusEqualTo(admin.getStatus());
    if (admin.getAccount() != null && admin.getAccount().length() > 0)
        criteria.andAccountLike("%" + admin.getAccount() + "%");
    if (admin.getName() != null && admin.getName().length() > 0)
        criteria.andNameLike("%" + admin.getName() + "%");
    // count,pages
    Integer count = sqlSession.selectOne("com.itrus.portal.db.AdminMapper.countByExample", adminex);
    uiModel.addAttribute("count", count);
    uiModel.addAttribute("pages", (count + size - 1) / size);
    // page, size
    if (page > 1 && size * (page - 1) >= count) {
        page = (count + size - 1) / size;
    }
    uiModel.addAttribute("page", page);
    uiModel.addAttribute("size", size);
    // query data
    Integer offset = size * (page - 1);
    adminex.setOffset(offset);
    adminex.setLimit(size);
    List<Admin> adminall = sqlSession.selectList("com.itrus.portal.db.AdminMapper.selectByExample", adminex);
    List<Admin> adminList = new ArrayList<Admin>();
    boolean flag = false;
    for (Admin admini : adminall) {
        if (admini.getProjects().contains(",")) {
            String[] strs = admini.getProjects().split(",");
            for (String s : strs) {
                if (s.equals("0")) {
                    // 包含所有项目
                    flag = true;
                    break;
                } else {
                    flag = false;
                }
            }
        }
        String projectName = getProjectNameByAdminId(admini.getId());
        admini.setProjects(projectName);
        if (flag)
            admini.setProjects("所有项目");
        adminList.add(admini);
        flag = false;
    }
    uiModel.addAttribute("admins", adminList);
    // itemcount
    uiModel.addAttribute("itemcount", adminall.size());
    Map<Long, Admin> adminmap = sqlSession.selectMap("com.itrus.portal.db.AdminMapper.selectByExample", adminex, "id");
    for (Long adminid : adminmap.keySet()) adminmap.get(adminid).setPassword(null);
    uiModel.addAttribute("adminmap", adminmap);
    ProjectExample projectex = new ProjectExample();
    Map projectmap = sqlSession.selectMap("com.itrus.portal.db.ProjectMapper.selectByExample", projectex, "id");
    uiModel.addAttribute("projectmap", projectmap);
    List projects = sqlSession.selectList("com.itrus.portal.db.ProjectMapper.selectByExample", projectex);
    uiModel.addAttribute("projects", projects);
    Map adminroles = sqlSession.selectMap("com.itrus.portal.db.AdminRoleMapper.selectByExample", "id");
    uiModel.addAttribute("adminroles", adminroles);
    return "admins/list";
}
Also used : ProjectExample(com.itrus.portal.db.ProjectExample) ArrayList(java.util.ArrayList) Admin(com.itrus.portal.db.Admin) ArrayList(java.util.ArrayList) List(java.util.List) AdminExample(com.itrus.portal.db.AdminExample) Map(java.util.Map) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with ProjectExample

use of com.itrus.portal.db.ProjectExample in project portal by ixinportal.

the class AdminController method createForm.

// 返回新建页面
@RequestMapping(params = "form", produces = "text/html")
public String createForm(@RequestParam(value = "project", required = false) Long project, HttpServletRequest request, Model uiModel) {
    uiModel.addAttribute("project", project);
    ProjectExample projectex = new ProjectExample();
    List projects = sqlSession.selectList("com.itrus.portal.db.ProjectMapper.selectByExample", projectex);
    List adminroles = sqlSession.selectList("com.itrus.portal.db.AdminRoleMapper.selectByExample");
    uiModel.addAttribute("adminroles", adminroles);
    uiModel.addAttribute("projects", projects);
    return "admins/create";
}
Also used : ProjectExample(com.itrus.portal.db.ProjectExample) ArrayList(java.util.ArrayList) List(java.util.List) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 18 with ProjectExample

use of com.itrus.portal.db.ProjectExample in project portal by ixinportal.

the class ExtraBillServiceImpl method getProjectMapByEnterpriseId.

/**
 * 根据企业id查询增值订单表中对应的projectMap
 *
 * @param enterprise
 * @return
 */
public Map<Long, Project> getProjectMapByEnterpriseId(Long enterprise) {
    Map<Long, Project> projectMap = new HashMap<Long, Project>();
    List<Long> projectIds = sqlSession.selectList("com.itrus.portal.db.ExtraBillMapper.selectProjectsByEnterprise", enterprise);
    if (null != projectIds && !projectIds.isEmpty()) {
        ProjectExample projectExample = new ProjectExample();
        ProjectExample.Criteria criteria = projectExample.or();
        criteria.andIdIn(projectIds);
        projectMap = sqlSession.selectMap("com.itrus.portal.db.ProjectMapper.selectByExample", projectExample, "id");
    }
    return projectMap;
}
Also used : Project(com.itrus.portal.db.Project) HashMap(java.util.HashMap) ProjectExample(com.itrus.portal.db.ProjectExample)

Example 19 with ProjectExample

use of com.itrus.portal.db.ProjectExample in project portal by ixinportal.

the class BillServiceImpl method getProjectMapByBills.

/**
 * 根据订单list查找出对应的projectMap
 *
 * @param bills
 * @return
 */
public Map<Long, Project> getProjectMapByBills(List<Bill> bills) {
    Map<Long, Project> projectMap = new HashMap<Long, Project>();
    List<Long> projectIds = new ArrayList<Long>();
    for (Bill bill : bills) {
        projectIds.add(bill.getProject());
    }
    if (!projectIds.isEmpty()) {
        ProjectExample projectExample = new ProjectExample();
        ProjectExample.Criteria criteria = projectExample.or();
        criteria.andIdIn(projectIds);
        projectMap = sqlSession.selectMap("com.itrus.portal.db.ProjectMapper.selectByExample", projectExample, "id");
    }
    return projectMap;
}
Also used : Project(com.itrus.portal.db.Project) HashMap(java.util.HashMap) ProjectExample(com.itrus.portal.db.ProjectExample) ArrayList(java.util.ArrayList) Bill(com.itrus.portal.db.Bill)

Example 20 with ProjectExample

use of com.itrus.portal.db.ProjectExample in project portal by ixinportal.

the class BillServiceImpl method getProjectMapByUserInfoId.

/**
 * 根据用户id查找订单表中对应的projectMap
 *
 * @param userInfo
 * @return
 */
public Map<Long, Project> getProjectMapByUserInfoId(Long userInfo) {
    Map<Long, Project> projectMap = new HashMap<Long, Project>();
    List<Long> projectIds = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectProjectsByUserInfo", userInfo);
    if (null != projectIds && !projectIds.isEmpty()) {
        ProjectExample projectExample = new ProjectExample();
        ProjectExample.Criteria criteria = projectExample.or();
        criteria.andIdIn(projectIds);
        projectMap = sqlSession.selectMap("com.itrus.portal.db.ProjectMapper.selectByExample", projectExample, "id");
    }
    return projectMap;
}
Also used : Project(com.itrus.portal.db.Project) HashMap(java.util.HashMap) ProjectExample(com.itrus.portal.db.ProjectExample)

Aggregations

ProjectExample (com.itrus.portal.db.ProjectExample)24 Project (com.itrus.portal.db.Project)16 HashMap (java.util.HashMap)13 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 ArrayList (java.util.ArrayList)11 List (java.util.List)8 Map (java.util.Map)7 Admin (com.itrus.portal.db.Admin)4 CustomerService (com.itrus.portal.db.CustomerService)3 CustomerServiceExample (com.itrus.portal.db.CustomerServiceExample)3 EnterpriseQq (com.itrus.portal.db.EnterpriseQq)3 EnterpriseQqExample (com.itrus.portal.db.EnterpriseQqExample)3 JSONObject (com.alibaba.fastjson.JSONObject)2 AdminExample (com.itrus.portal.db.AdminExample)2 FileConfig (com.itrus.portal.db.FileConfig)2 FileConfigExample (com.itrus.portal.db.FileConfigExample)2 Calendar (java.util.Calendar)2 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)2 Bill (com.itrus.portal.db.Bill)1 ProjectKeyInfo (com.itrus.portal.db.ProjectKeyInfo)1