package com.basic.x01.securityCheck.controller;
|
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.annotation.Resource;
|
|
import org.apache.ibatis.annotations.Param;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import com.basic.x01.base.BaseController;
|
import com.basic.x01.securityCheck.SecurityCheckUtil;
|
import com.basic.x01.securityCheck.mapper.SecurityCheckMapper;
|
import com.basic.x01.securityCheck.model.TbSecurityCheckItem;
|
import com.basic.x01.securityCheck.model.TbSecurityType;
|
import com.basic.x01.system.model.TSysUser;
|
|
/**
|
* 非学校组织的安全检查模块
|
*
|
* @company 北京贝思科技术有限公司
|
* @author liuyajun, 8384503@qq.com
|
* @date 2016年2月16日
|
* @time 下午12:17:02
|
*/
|
@Controller
|
@Transactional(rollbackFor=Throwable.class)
|
public class SecurityCheckOrg extends BaseController {
|
|
public final static String ACTION_ID = "securityCheckItem";
|
public final static String EDIT_TYPE = "securityCheckEditType";
|
public final static String CREATE_ITEM = "securityCheckCreateItem";
|
public final static String EDIT_ITEM = "securityCheckEditItem";
|
public final static String DELETE_ITEM = "securityCheckDeleteItem";
|
|
@Resource
|
SecurityCheckMapper checkMapper;
|
|
@RequestMapping(value={CREATE_ITEM, EDIT_ITEM, DELETE_ITEM})
|
public String securityCheckCreateItem(
|
TbSecurityCheckItem item,
|
@Param("itemId") String itemId
|
) throws Throwable {
|
TSysUser user = this.getLoingedUser();
|
|
if(CREATE_ITEM.equals(this.getCurrentActionId())
|
&& item!=null && !this.isEmpty(item.getTypeId())){
|
item.setOrgId(user.getOrgId());
|
|
if(checkMapper.checkSameTbSecurityCheckItem(item)>0){
|
throw this.exception("该分类下存在相同检查项目");
|
}
|
|
//新建
|
item.setCreateUserId(user.getUserId());
|
checkMapper.insertTbSecurityCheckItem(item);
|
|
return this.ajax("ok");
|
}
|
if(EDIT_ITEM.equals(this.getCurrentActionId())
|
&& item!=null && !this.isEmpty(item.getTypeId())
|
&& !this.isEmpty(item.getItemId())){
|
item.setOrgId(user.getOrgId());
|
|
if(checkMapper.checkSameTbSecurityCheckItem(item)>0){
|
throw this.exception("该分类下存在相同检查项目");
|
}
|
//修改
|
checkMapper.updateTbSecurityCheckItem(item);
|
|
return this.ajax("ok");
|
}
|
|
if(DELETE_ITEM.equals(this.getCurrentActionId())
|
&& ! this.isEmpty(itemId)){
|
//TODO: 没有检查是否使用过
|
checkMapper.deleteUnusedTbSecurityCheckItem(user.getOrgId(), itemId);
|
return this.ajax("ok");
|
}
|
|
List<TbSecurityType> typeList = checkMapper.getSecurityType4Edit(user.getOrgId());
|
|
this.setAttribute("typeList", typeList);
|
this.setAttribute("hasType", typeList.size()>0?"y":"n");
|
|
if(EDIT_ITEM.equals(this.getCurrentActionId()) && ! this.isEmpty(itemId)){
|
item = checkMapper.getTbSecurityCheckItem(itemId);
|
this.setAttribute("checkItem", item);
|
}
|
|
this.setAttribute("checkWayInputHtml", SecurityCheckUtil.getCheckWayHtml4Edit(item.getCheckWay()));
|
|
return "security-check/org-check-item-edit";
|
}
|
|
@RequestMapping(value="securityCheckEditTypeUpdate")
|
public String securityCheckEditTypeUpdate(
|
@RequestBody List<TbSecurityType> list) throws Throwable {
|
TSysUser user = this.getLoingedUser();
|
|
if(list==null || list.size()==0){
|
return this.ajax(null);
|
}
|
|
for(TbSecurityType type : list){
|
int sameType = checkMapper.checkSameTbSeucrityType(type);
|
if(sameType>0){
|
throw this.exception("存在相同的分类名称");
|
}
|
checkMapper.updateTbSecurityType(type);
|
}
|
|
checkMapper.deleteUnusedTbSecurityType(list, user.getOrgId());
|
|
return this.ajax("ok");
|
}
|
|
@RequestMapping(value=EDIT_TYPE)
|
public String securityCheckEditType(@Param("typeName") String typeName) throws Throwable {
|
|
TSysUser user = this.getLoingedUser();
|
if(! this.isEmpty(typeName)){
|
TbSecurityType type = new TbSecurityType();
|
type.setOrgId(user.getOrgId());
|
type.setTypeName(typeName.trim());
|
//新增
|
int sameType = checkMapper.checkSameTbSeucrityType(type);
|
if(sameType>0){
|
throw this.exception("存在相同的分类名称");
|
}
|
|
type.setCreateUserId(user.getUserId());
|
checkMapper.insertTbSecurityType(type);
|
return this.ajax("ok");
|
}
|
|
List<TbSecurityType> typeList = checkMapper.getSecurityType4Edit(user.getOrgId());
|
|
this.setAttribute("typeList", typeList);
|
this.setAttribute("hasType", typeList.size()>0?"y":"n");
|
|
return "security-check/org-edit-type";
|
}
|
|
@RequestMapping(value=ACTION_ID)
|
public String securityCheckItem(
|
@Param("searchTypeId") String searchTypeId,
|
@Param("searchItemName") String searchItemName
|
) throws Throwable {
|
TSysUser user = this.getLoingedUser();
|
|
List<TbSecurityType> typeList = checkMapper.getSecurityType(user.getOrgId());
|
|
this.getRequest().setAttribute("typeList", typeList);
|
this.getRequest().setAttribute("hasType", typeList.size()>0?"y":"n");
|
|
Map<String,Object> param = new HashMap<String,Object>();
|
param.put("orgId", user.getOrgId());
|
|
if(! this.isEmpty(searchTypeId)){
|
this.setAttribute("searchTypeId", searchTypeId);
|
param.put("typeId", searchTypeId);
|
}
|
|
if(! this.isEmpty(searchItemName)){
|
this.setAttribute("searchItemName", searchItemName);
|
param.put("itemContent", searchItemName);
|
}
|
|
List<TbSecurityCheckItem> itemList = checkMapper.getSecurityCheckItemList(
|
this.wrapPageSearchParam(param));
|
|
this.setAttribute("itemList", itemList);
|
this.setAttribute("hasItem", itemList.size()>0?"y":"n");
|
|
this.setAttribute(EDIT_ITEM, this.checkAccess(EDIT_ITEM)?"y":"n");
|
this.setAttribute(DELETE_ITEM, this.checkAccess(DELETE_ITEM)?"y":"n");
|
|
return "security-check/org-check-item";
|
}
|
}
|