提交分组地理信息管理.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package com.nis.domain.configuration;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 分组地理信息
|
||||
*/
|
||||
public class GroupAreaInfo extends BaseCfg<GroupAreaInfo> implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 3312689200711339511L;
|
||||
|
||||
private Long id;
|
||||
private Integer groupId;
|
||||
private Integer areaCode;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
public Integer getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
public void setGroupId(Integer groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
public Integer getAreaCode() {
|
||||
return areaCode;
|
||||
}
|
||||
public void setAreaCode(Integer areaCode) {
|
||||
this.areaCode = areaCode;
|
||||
}
|
||||
public Date getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
public void setCreateTime(Date createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
public Date getEditTime() {
|
||||
return editTime;
|
||||
}
|
||||
public void setEditTime(Date editTime) {
|
||||
this.editTime = editTime;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.nis.web.controller.configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.PolicyGroupInfo;
|
||||
import com.nis.domain.configuration.GroupAreaInfo;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.service.configuration.GroupAreaService;
|
||||
|
||||
/**
|
||||
* 分组地理信息管理
|
||||
*
|
||||
*/
|
||||
@Controller
|
||||
@RequestMapping(value = "${adminPath}/cfg/groupArea")
|
||||
public class GroupAreaController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private GroupAreaService groupAreaService;
|
||||
|
||||
@RequestMapping(value = { "/groupAreaList", "" })
|
||||
public String policyGroupList(GroupAreaInfo cfg, HttpServletRequest request, HttpServletResponse response,
|
||||
Model model) {
|
||||
if (cfg == null)cfg = new GroupAreaInfo();
|
||||
Page<GroupAreaInfo> pageCondition = new Page<GroupAreaInfo>(request, response, "r");
|
||||
Page page = groupAreaService.findGroupAreaInfoList(pageCondition, cfg);
|
||||
// 获取策略分组信息
|
||||
List<PolicyGroupInfo> policyGroups = policyGroupInfoService.findNatPolicyGroups();
|
||||
// 获取区域信息
|
||||
initFormCondition(model);
|
||||
model.addAttribute("cfg", cfg);
|
||||
model.addAttribute("page", page);
|
||||
model.addAttribute("policyGroups", policyGroups);
|
||||
return "/cfg/manipulation/ipmulitiplex/groupAreaList";
|
||||
}
|
||||
|
||||
@RequestMapping(value={"/groupAreaForm"})
|
||||
public String form(String ids,Model model,String doAction,RedirectAttributes redirectAttributes) {
|
||||
GroupAreaInfo groupArea=new GroupAreaInfo();
|
||||
// 获取未使用的策略分组
|
||||
List<PolicyGroupInfo> groups = policyGroupInfoService.findNatPolicyGroups();
|
||||
groups = groupAreaService.getNotUsedPolicyGroups(groups);
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
groupArea=groupAreaService.getInfoById(Integer.parseInt(ids));
|
||||
groups.add(policyGroupInfoService.getById(groupArea.getGroupId()));
|
||||
}
|
||||
// 获取区域信息
|
||||
initFormCondition(model);
|
||||
model.addAttribute("_cfg", groupArea);
|
||||
model.addAttribute("policyGroups", groups);
|
||||
return "/cfg/manipulation/ipmulitiplex/groupAreaForm";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "saveOrUpdate")
|
||||
public String saveOrUpdate(GroupAreaInfo cfg,Model model,RedirectAttributes redirectAttributes) {
|
||||
try {
|
||||
groupAreaService.saveOrUpdate(cfg);
|
||||
addMessage(redirectAttributes, "save_success");
|
||||
} catch (Exception e) {
|
||||
logger.error("新增失败",e);
|
||||
addMessage(redirectAttributes, "save_failed");
|
||||
}
|
||||
return "redirect:" + adminPath + "/cfg/groupArea/groupAreaList";
|
||||
}
|
||||
|
||||
@RequestMapping(value={"delete"})
|
||||
public String delete(RedirectAttributes redirectAttributes, String ids,int isValid) {
|
||||
try {
|
||||
groupAreaService.deldete(ids,isValid);
|
||||
addMessage(redirectAttributes, "delete_success");
|
||||
} catch (Exception e) {
|
||||
logger.error("删除失败",e);
|
||||
addMessage(redirectAttributes, "delete_failed");
|
||||
}
|
||||
return "redirect:" + adminPath + "/cfg/groupArea/groupAreaList";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,5 +15,5 @@ public interface PolicyGroupInfoDao extends CrudDao<PolicyGroupInfo> {
|
||||
List<PolicyGroupInfo> findHasIPPolicyGroupInfosByType(int groupType);
|
||||
List<PolicyGroupInfo> findPolicyGroupInfosHasIpRegionByType(int groupType);
|
||||
PolicyGroupInfo getById(int id);
|
||||
|
||||
List<PolicyGroupInfo> findNatPolicyGroups();
|
||||
}
|
||||
@@ -67,6 +67,12 @@
|
||||
FROM policy_group_info r
|
||||
where r.is_valid=1
|
||||
</select>
|
||||
<select id="findNatPolicyGroups" resultMap="PolicyGroupInfoMap">
|
||||
SELECT
|
||||
<include refid="PolicyGroupInfoColumns"/>
|
||||
FROM policy_group_info r
|
||||
where r.is_valid=1 AND r.group_type = 2 OR r.group_type = 3
|
||||
</select>
|
||||
<select id="findPolicyGroupInfosByType" resultMap="PolicyGroupInfoMap">
|
||||
SELECT
|
||||
<include refid="PolicyGroupInfoColumns"/>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.nis.web.dao.configuration;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.nis.domain.configuration.GroupAreaInfo;
|
||||
import com.nis.web.dao.CrudDao;
|
||||
import com.nis.web.dao.MyBatisDao;
|
||||
|
||||
@MyBatisDao
|
||||
public interface GroupAreaDao extends CrudDao<GroupAreaInfo>{
|
||||
|
||||
List<GroupAreaInfo> findGroupAreaInfoList(GroupAreaInfo entity);
|
||||
|
||||
GroupAreaInfo getInfoById(int groupId);
|
||||
|
||||
|
||||
}
|
||||
127
src/main/java/com/nis/web/dao/configuration/GroupAreaDao.xml
Normal file
127
src/main/java/com/nis/web/dao/configuration/GroupAreaDao.xml
Normal file
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.nis.web.dao.configuration.GroupAreaDao">
|
||||
|
||||
<resultMap id="GroupAreaInfoMap" type="com.nis.domain.configuration.GroupAreaInfo" >
|
||||
<id column="id" property="id" jdbcType="INTEGER" />
|
||||
<result column="group_id" property="groupId" jdbcType="INTEGER" />
|
||||
<result column="area_code" property="areaCode" jdbcType="INTEGER" />
|
||||
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
|
||||
<result column="creator_id" property="creatorId" jdbcType="INTEGER" />
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
|
||||
<result column="editor_id" property="editorId" jdbcType="INTEGER" />
|
||||
<result column="edit_time" property="editTime" jdbcType="TIMESTAMP" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="GroupAreaInfoColumns">
|
||||
r.id,
|
||||
r.group_id,
|
||||
r.area_code,
|
||||
r.is_valid,
|
||||
r.creator_id,
|
||||
r.create_time,
|
||||
r.editor_id,
|
||||
r.edit_time
|
||||
</sql>
|
||||
|
||||
<!-- 查出所有 有效数据-->
|
||||
<select id="findGroupAreaInfoList" resultMap="GroupAreaInfoMap">
|
||||
SELECT
|
||||
<include refid="GroupAreaInfoColumns"/>
|
||||
<trim prefix="," prefixOverrides=",">
|
||||
, s.name as creator_name
|
||||
,e.name as editor_name
|
||||
</trim>
|
||||
FROM group_area_info r
|
||||
left join sys_user s on r.creator_id=s.id
|
||||
left join sys_user e on r.editor_id=e.id
|
||||
|
||||
<trim prefix="WHERE" prefixOverrides="AND |OR ">
|
||||
<if test="page !=null and page.where != null and page.where != ''">
|
||||
AND ${page.where}
|
||||
</if>
|
||||
<if test="groupId != null">
|
||||
AND r.group_id =#{groupId }
|
||||
</if>
|
||||
<if test="areaCode != null">
|
||||
AND r.area_code =#{areaCode }
|
||||
</if>
|
||||
AND r.IS_VALID =1
|
||||
<if test="creatorName != null and creatorName != ''">
|
||||
AND CREATOR_NAME like concat(concat('%',#{creatorName,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<if test="editorName != null and editorName != ''">
|
||||
AND r.EDITOR_NAME like concat(concat('%',#{editorName,jdbcType=VARCHAR}),'%')
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
<!-- ${sqlMap.dsf} -->
|
||||
</trim>
|
||||
<choose>
|
||||
<when test="page !=null and page.orderBy != null and page.orderBy != ''">
|
||||
ORDER BY ${page.orderBy}
|
||||
</when>
|
||||
<otherwise>
|
||||
ORDER BY r.id desc
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="getInfoById" resultType="com.nis.domain.configuration.GroupAreaInfo">
|
||||
SELECT
|
||||
<include refid="GroupAreaInfoColumns"/>
|
||||
FROM
|
||||
group_area_info r
|
||||
WHERE
|
||||
r.id = #{Id}
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.nis.domain.configuration.GroupAreaInfo" >
|
||||
insert into group_area_info(
|
||||
ID,
|
||||
GROUP_ID,
|
||||
AREA_CODE,
|
||||
IS_VALID,
|
||||
CREATOR_ID,
|
||||
CREATE_TIME
|
||||
)values (
|
||||
#{id,jdbcType=INTEGER},
|
||||
#{groupId,jdbcType=INTEGER},
|
||||
#{areaCode,jdbcType=INTEGER},
|
||||
#{isValid,jdbcType=INTEGER},
|
||||
#{creatorId,jdbcType=INTEGER},
|
||||
#{createTime,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.nis.domain.configuration.GroupAreaInfo" >
|
||||
update group_area_info
|
||||
<set >
|
||||
<trim suffixOverrides=",">
|
||||
<if test="id != null" >
|
||||
id = #{id,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="groupId != null" >
|
||||
group_Id = #{groupId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="areaCode != null" >
|
||||
area_code = #{areaCode,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="isValid != null" >
|
||||
is_valid = #{isValid,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="editorId != null" >
|
||||
editor_id = #{editorId,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="editTime != null and editTime != ''" >
|
||||
edit_time = #{editTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</trim>
|
||||
</set>
|
||||
<where>
|
||||
<if test="id != null" >
|
||||
and id = #{id,jdbcType=INTEGER}
|
||||
</if>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -45,6 +45,10 @@ public class PolicyGroupInfoService extends BaseService{
|
||||
List<PolicyGroupInfo> list=policyGroupInfoDao.findPolicyGroupInfos();
|
||||
return list;
|
||||
}
|
||||
public List<PolicyGroupInfo> findNatPolicyGroups() {
|
||||
List<PolicyGroupInfo> list=policyGroupInfoDao.findNatPolicyGroups();
|
||||
return list;
|
||||
}
|
||||
public List<PolicyGroupInfo> findPolicyGroupInfosByType(int type) {
|
||||
List<PolicyGroupInfo> list=policyGroupInfoDao.findPolicyGroupInfosByType(type);
|
||||
return list;
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.nis.web.service.configuration;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.basics.PolicyGroupInfo;
|
||||
import com.nis.domain.configuration.GroupAreaInfo;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.configuration.GroupAreaDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.BaseService;
|
||||
|
||||
@Service
|
||||
public class GroupAreaService extends BaseService{
|
||||
|
||||
@Autowired
|
||||
private GroupAreaDao groupAreaDao;
|
||||
|
||||
public Page<GroupAreaInfo> findGroupAreaInfoList(Page<GroupAreaInfo> page, GroupAreaInfo entity) {
|
||||
entity.getSqlMap().put("dsf", configScopeFilter(entity.getCurrentUser(),"r"));
|
||||
entity.setPage(page);
|
||||
List<GroupAreaInfo> list=groupAreaDao.findGroupAreaInfoList(entity);
|
||||
page.setList(list);
|
||||
return page;
|
||||
}
|
||||
|
||||
public GroupAreaInfo getInfoById(int groupId) {
|
||||
GroupAreaInfo GroupAreaInfo=groupAreaDao.getInfoById(groupId);
|
||||
return GroupAreaInfo;
|
||||
}
|
||||
|
||||
public void saveOrUpdate(GroupAreaInfo entity) {
|
||||
entity.setIsValid(1);
|
||||
if(entity.getId()==null){//新增
|
||||
Date createTime=new Date();
|
||||
entity.setCreatorId(UserUtils.getUser().getId());
|
||||
entity.setCreateTime(createTime);
|
||||
groupAreaDao.insert(entity);
|
||||
}else{//修改
|
||||
Date editTime=new Date();
|
||||
entity.setEditorId(UserUtils.getUser().getId());
|
||||
entity.setEditTime(editTime);
|
||||
groupAreaDao.update(entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void deldete(String ids, int isValid) {
|
||||
if(!StringUtil.isEmpty(ids)){
|
||||
GroupAreaInfo entity=new GroupAreaInfo();
|
||||
Date editTime=new Date();
|
||||
entity.setEditorId(UserUtils.getUser().getId());
|
||||
entity.setEditTime(editTime);
|
||||
entity.setIsValid(isValid);
|
||||
for (String id : ids.split(",")) {
|
||||
if(!StringUtil.isEmpty(id)){
|
||||
entity.setId(Long.parseLong(id));
|
||||
groupAreaDao.update(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取未使用的策略分组
|
||||
public List<PolicyGroupInfo> getNotUsedPolicyGroups(List<PolicyGroupInfo> policyGroups) {
|
||||
List<GroupAreaInfo> groupAreas=groupAreaDao.findGroupAreaInfoList(new GroupAreaInfo());
|
||||
for (GroupAreaInfo groupArea : groupAreas) {
|
||||
for (int i = 0; i < policyGroups.size(); i++) {
|
||||
Integer groupId = policyGroups.get(i).getGroupId();
|
||||
if(groupArea.getGroupId().equals(groupId)){
|
||||
policyGroups.remove(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
return policyGroups;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user