Java tutorial
/* * Project: guahao-portal-web-home * * File Created at 2014-5-4 * * Copyright 2012 Greenline.com Corporation Limited. * All rights reserved. * * This software is the confidential and proprietary information of * Greenline Company. ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered into * with Greenline.com. */ package com.greenline.guahao.web.module.home.controllers.kandian; import javax.annotation.Resource; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import com.greenline.guahao.biz.manager.hrs.DepartmentManager; import com.greenline.guahao.biz.manager.hrs.HospitalManager; import com.greenline.guahao.biz.manager.hrs.NewsManager; import com.greenline.guahao.biz.manager.hrs.dataobject.HospitalDO; import com.greenline.guahao.biz.manager.hrs.dataobject.HospitalDepartmentDO; import com.greenline.guahao.biz.manager.hrs.dataobject.NewsDetailDO; import com.greenline.guahao.biz.util.BizCommonUtils; import com.greenline.guahao.biz.util.HtmlUtils; import com.greenline.guahao.web.module.common.annotation.MethodRemark; import com.greenline.guahao.web.module.common.constants.DepartmentConstants; import com.greenline.guahao.web.module.common.constants.GlobalConstants; import com.greenline.guahao.web.module.common.constants.HospitalConstants; /** * @Type KanDianController * @Desc * @author alex * @date 2014-5-4 * @Version V1.0 */ @RequestMapping("/kandian") @Controller public class KanDianController { private static final Log log = LogFactory.getLog(KanDianController.class); @Resource private NewsManager newsManager; @Resource private HospitalManager hospitalManager; @Resource private DepartmentManager departmentManager; /** * * * @param model * @param id ? * @return */ @RequestMapping("/{id}") @MethodRemark("remark=") public String detail(ModelMap model, @PathVariable("id") String id) { if (StringUtils.isBlank(id) || !StringUtils.isNumeric(id)) { log.error(String.format("???%s", id)); } else { NewsDetailDO kanDian = newsManager.getNews(Long.valueOf(id)); if (null == kanDian) { log.error(String.format("??%s", id)); } else { String scope = kanDian.getScope(); model.put("description", HtmlUtils.deleteHtmlS(kanDian.getNewsContent())); model.put("newsDO", kanDian); if ("1".equals(scope)) { // if (hospitalDetail(model, kanDian.getHospitalId())) { return HospitalConstants.VIEW_HOSPITAL_NEWS_DETAIL; } } else if ("2".equals(scope)) { // if (hospDeptDetail(model, kanDian.getHospDeptId())) { return DepartmentConstants.VIEW_DEPARTMENT_NEWS_DETAIL; } } else { log.error(String.format("%s", scope)); } } } model.put("error_message", "?"); return GlobalConstants.ERROR_PAGE; } /** * ? * * @param model * @param hospitalId * @return */ private boolean hospitalDetail(ModelMap model, String hospitalId) { boolean suc = false; HospitalDO hospital = null; // ???? if (!BizCommonUtils.isUUID(hospitalId) || null == (hospital = hospitalManager.getHospital(hospitalId))) { log.error(String.format( "??????%s", hospitalId)); } else { suc = true; hospital.setShortdesc(HtmlUtils.deleteHtml(hospital.getShortdesc())); hospital.setAddr(HtmlUtils.deleteHtml(hospital.getAddr())); model.put("hospital", hospital); } return suc; } /** * ?(??) * * @param model * @param hospDeptId * @return */ private boolean hospDeptDetail(ModelMap model, String hospDeptId) { boolean suc = false; // ?? HospitalDepartmentDO hospDept = departmentManager.getHospitalDept(hospDeptId); if (null == hospDept) { log.error(String.format("??%s", hospDept)); } else { model.put("hospDept", hospDept); suc = hospitalDetail(model, hospDept.getHospitalId()); } return suc; } }