(1)增强字符串多选修改

(2)增强字符串权限增加
This commit is contained in:
wangxin
2018-04-11 18:47:02 +08:00
parent a7b4b1edfb
commit 7118b82d6d
8 changed files with 214 additions and 126 deletions

View File

@@ -1,4 +1,5 @@
package com.nis.web.controller.configuration;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@@ -6,6 +7,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
@@ -14,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import com.nis.domain.Page;
import com.nis.domain.ServiceConfigInfo;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.main.ConvertTool;
import com.nis.util.Constants;
@@ -29,6 +33,7 @@ import com.nis.web.controller.BaseController;
public class ComplexStringCfgController extends BaseController{
@RequestMapping(value = {"list"})
@RequiresPermissions(value={"cfg:complex:view"})
public String cfgList(Model model,Integer audit,String cfgName,@ModelAttribute("cfg")ComplexkeywordCfg cfg,HttpServletRequest request,HttpServletResponse response) {
model.addAttribute("cfgName", cfgName);
model.addAttribute("audit", audit);
@@ -43,7 +48,21 @@ public class ComplexStringCfgController extends BaseController{
if(!StringUtils.isBlank(tableName)){
logger.info("table name is "+tableName);
cfg.setTableName(tableName);
Page<ComplexkeywordCfg> page = complexStringCfgService.findPage(new Page<ComplexkeywordCfg>(request, response,"r"), cfg);
Page<ComplexkeywordCfg> searchPage=new Page<ComplexkeywordCfg>(request,response,"r");
String addWhrere=null;
if(audit==Constants.CFG_PAGE){//
addWhrere="r.is_audit in ("+Constants.AUDIT_NOT_YET+","+Constants.AUDIT_NO+")";
}else if(audit==Constants.AUDIT_PAGE){
addWhrere="r.is_audit in ("+Constants.AUDIT_NOT_YET+","+Constants.AUDIT_YES+")";
}
if(addWhrere!=null){
if(StringUtils.isNotBlank(searchPage.getWhere())){
searchPage.setWhere(searchPage.getWhere()+" AND "+addWhrere);
}else{
searchPage.setWhere(addWhrere);
}
}
Page<ComplexkeywordCfg> page = complexStringCfgService.findPage(searchPage, cfg);
model.addAttribute("page", page);
model.addAttribute("action", cfg.getAction());
model.addAttribute("tableName", tableName);
@@ -60,7 +79,8 @@ public class ComplexStringCfgController extends BaseController{
@RequestMapping(value = {"form"})
public String cfgForm(int action,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response) {
@RequiresPermissions(value={"cfg:complex:add"})
public String cfgForm(int action,String cfgName,Integer serviceId,Model model) {
model.addAttribute("cfgName", cfgName);
model.addAttribute("action", action);
model.addAttribute("serviceId", serviceId);
@@ -99,7 +119,8 @@ public class ComplexStringCfgController extends BaseController{
return "/cfg/complexCfgForm";
}
@RequestMapping(value = {"updateForm"})
public String updateStringCfgForm(String tableName,int action,long cfgId,String cfgName,Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response) {
@RequiresPermissions(value={"cfg:complex:edit"})
public String updateStringCfgForm(String tableName,int action,int compileId,String cfgName,Integer serviceId,Model model) {
model.addAttribute("cfgName", cfgName);
model.addAttribute("serviceId", serviceId);
model.addAttribute("action", action);
@@ -114,9 +135,9 @@ public class ComplexStringCfgController extends BaseController{
}
logger.info("table name is "+tableName);
ComplexkeywordCfg searchBean=new ComplexkeywordCfg();
searchBean.setCfgId(cfgId);
searchBean.setCompileId(compileId);
searchBean.setTableName(tableName);
ComplexkeywordCfg cfg=complexStringCfgService.getStringCfgById(searchBean);
ComplexkeywordCfg cfg=complexStringCfgService.get(searchBean);
model.addAttribute("_cfg", cfg);
model.addAttribute("tableName", tableName);
initUpdateFormCondition(model,cfg);
@@ -136,6 +157,7 @@ public class ComplexStringCfgController extends BaseController{
* @since 1.0.0
*/
@RequestMapping(value = {"saveOrUpdateCfg"})
@RequiresPermissions(value={"cfg:complex:add","cfg:complex:edit"},logical=Logical.OR)
public String saveOrUpdateStringCfg(String cfgName,Model model, ComplexkeywordCfg cfg,String areaCfgIds) {
model.addAttribute("cfgName",cfgName);
model.addAttribute("cfgType","complex");
@@ -162,50 +184,68 @@ public class ComplexStringCfgController extends BaseController{
* @exception
* @since 1.0.0
*/
@RequestMapping(value = {"auditCfg"})
public String auditStringCfg(String cfgName,ComplexkeywordCfg cfg,Model model) {
@RequestMapping(value = {"audit"})
@RequiresPermissions(value={"cfg:complex:audit"})
public String auditStringCfg(String cfgName,int serviceId,int isAudit,int action,String tableName,String ids,Model model) {
model.addAttribute("cfgName", cfgName);
model.addAttribute("audit", Constants.AUDIT_PAGE);
model.addAttribute("cfgType", "complex");
model.addAttribute("serviceId", cfg.getServiceId());
model.addAttribute("action", cfg.getAction());
model.addAttribute("serviceId", serviceId);
model.addAttribute("action", action);
try{
String tableName=cfg.getTableName();
String maatTable=null;
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(cfg.getServiceId());
ServiceConfigInfo serviceConfigInfo=serviceConfigInfoService.findSysServiceConfigInfo(serviceId);
if(serviceConfigInfo!=null){
if(StringUtils.isBlank(tableName)){
tableName=serviceConfigInfo.getTableName();
cfg.setTableName(tableName);
}
maatTable=serviceConfigInfo.getMaatTable();
}
ComplexkeywordCfg bean=complexStringCfgService.getStringCfgById(cfg);
bean.setTableName(tableName);
int audit=bean.getIsAudit().intValue();
if(audit==Constants.AUDIT_YES&&cfg.getIsAudit()!=Constants.AUDIT_NOT_YES){
logger.error("审核通过的配置只能取消审核通过!");
}else{
cfg.setAuditorId(cfg.getCurrentUser().getId());
cfg.setAuditTime(new Date());
bean.setIsAudit(cfg.getIsAudit());
if(cfg.getIsAudit()==Constants.AUDIT_NOT_YES){//取消审核通过设置有效标志为0
cfg.setIsValid(Constants.VALID_NO);
bean.setIsValid(Constants.VALID_NO);
bean.setMaatTable(maatTable);
}else if(cfg.getIsAudit()==Constants.AUDIT_YES){//审核通过设置有效标志为1
cfg.setIsValid(Constants.VALID_YES);
bean.setIsValid(Constants.VALID_YES);
bean.setMaatTable(maatTable);
if(StringUtils.isNotBlank(ids)){
List<ComplexkeywordCfg> beans=complexStringCfgService.getList(tableName,ids);
List<ComplexkeywordCfg> auditBeans=new ArrayList<>();
List<AreaIpCfg> auditAreaBeans=new ArrayList<>();
Date date=new Date();
for(ComplexkeywordCfg bean:beans){
ComplexkeywordCfg auditBean=new ComplexkeywordCfg();
auditBean.setTableName(tableName);
auditBean.setCfgId(bean.getCfgId());
bean.setTableName(tableName);
int audit=bean.getIsAudit().intValue();
if(audit==Constants.AUDIT_YES&&isAudit!=Constants.AUDIT_NOT_YES){
logger.error("审核通过的配置只能取消审核通过!");
addMessage(model, "audit_failed");
return "/cfg/resultPage";
}else{
auditBean.setAuditorId(bean.getCurrentUser().getId());
auditBean.setAuditTime(date);
auditBean.setIsAudit(isAudit);
bean.setAuditorId(bean.getCurrentUser().getId());
bean.setAuditTime(date);
bean.setIsAudit(isAudit);
if(isAudit==Constants.AUDIT_NOT_YES){//取消审核通过设置有效标志为0
auditBean.setIsValid(Constants.VALID_NO);
auditBean.setMaatTable(maatTable);
bean.setIsValid(Constants.VALID_NO);
bean.setMaatTable(maatTable);
}else if(isAudit==Constants.AUDIT_YES){//审核通过设置有效标志为1
auditBean.setIsValid(Constants.VALID_YES);
auditBean.setMaatTable(maatTable);
bean.setIsValid(Constants.VALID_YES);
bean.setMaatTable(maatTable);
}
List<AreaIpCfg> areaCfg=ipCfgService.getAreaCfgByCompileId(bean.getCompileId());
for(AreaIpCfg c:areaCfg){
c.setTableName(AreaIpCfg.getTablename());
}
bean.setAreaCfg(areaCfg);
auditAreaBeans.addAll(areaCfg);
}
auditBeans.add(auditBean);
}
int result=complexStringCfgService.auditStringCfg(bean,cfg);
if(result!=0){
addMessage(model,"audit_success");
}else{
addMessage(model,"audit_failed");
}
complexStringCfgService.auditStringCfg(isAudit,auditBeans,auditAreaBeans,beans);
}
addMessage(model,"audit_success");
}catch(Exception e){
logger.error("发生异常",e);
addMessage(model,"audit_failed");
@@ -221,8 +261,9 @@ public class ComplexStringCfgController extends BaseController{
* @exception
* @since 1.0.0
*/
@RequestMapping(value = {"deleteCfg"})
public String deleteStringCfg(String tableName,int action,long cfgId,int compileId,String cfgName,Integer serviceId,Model model) {
@RequestMapping(value = {"delete"})
@RequiresPermissions(value={"cfg:complex:delete"})
public String deleteStringCfg(String tableName,int action,String ids,String cfgName,Integer serviceId,Model model) {
model.addAttribute("serviceId", serviceId);
model.addAttribute("cfgName", cfgName);
model.addAttribute("action", action);
@@ -235,32 +276,33 @@ public class ComplexStringCfgController extends BaseController{
tableName=serviceConfigInfo.getTableName();
}
}
List<AreaIpCfg> areaCfg=ipCfgService.getAreaCfgByCompileId(compileId);
if(areaCfg!=null&&areaCfg.size()>0){
for(AreaIpCfg c:areaCfg){
c.setTableName(AreaIpCfg.getTablename());
List<ComplexkeywordCfg> complexCfgs=new ArrayList<ComplexkeywordCfg>();
List<AreaIpCfg> areaCfgs=new ArrayList<AreaIpCfg>();
Date date =new Date();
if(StringUtils.isNotBlank(ids)){
for(String compileIdStr:ids.split(",")){
if(StringUtils.isNotBlank(compileIdStr)){
List<AreaIpCfg> areaCfg=ipCfgService.getAreaCfgByCompileId(Integer.parseInt(compileIdStr));
if(areaCfg!=null&&areaCfg.size()>0){
for(AreaIpCfg c:areaCfg){
c.setTableName(AreaIpCfg.getTablename());
c.setEditorId(c.getCurrentUser().getId());
c.setEditTime(date);
}
}
areaCfgs.addAll(areaCfg);
ComplexkeywordCfg complexCfg=new ComplexkeywordCfg();
complexCfg.setCompileId(Integer.parseInt(compileIdStr));
complexCfg.setTableName(tableName);
complexCfg.setEditorId(complexCfg.getCurrentUser().getId());
complexCfg.setEditTime(date);
complexCfg.setIsValid(Constants.VALID_DEL);
complexCfgs.add(complexCfg);
}
}
}
int audit=complexStringCfgService.getIsAudit(tableName,cfgId);
//未审核时可删除
if(audit!=Constants.AUDIT_YES&&audit!=Constants.AUDIT_NOT_YES){
ComplexkeywordCfg cfg=new ComplexkeywordCfg();
cfg.setCfgId(cfgId);
cfg.setTableName(tableName);
cfg.setEditorId(cfg.getCurrentUser().getId());
cfg.setEditTime(new Date());
cfg.setIsValid(Constants.VALID_DEL);
int result=complexStringCfgService.deleteStringCfg(cfg,areaCfg);
if(result==0){
addMessage(model,"delete_failed");
}else{
addMessage(model,"delete_success");
}
}else{
logger.error("通过审核/取消审核通过的配置不能删除!");
addMessage(model,"delete_failed");
}
complexStringCfgService.deleteStringCfg(complexCfgs,areaCfgs);
addMessage(model,"delete_success");
}catch(Exception e){
logger.error("删除失败", e);
addMessage(model,"delete_failed");

View File

@@ -310,6 +310,9 @@ public class IpCfgController extends BaseController{
bean.setMaatTable(maatTable);
}
List<AreaIpCfg> areaCfg=ipCfgService.getAreaCfgByCompileId(bean.getCompileId());
for(AreaIpCfg c:areaCfg){
c.setTableName(AreaIpCfg.getTablename());
}
bean.setAreaCfg(areaCfg);
auditAreaBeans.addAll(areaCfg);
}
@@ -374,31 +377,6 @@ public class IpCfgController extends BaseController{
ipCfgs.add(ipCfg);
}
}
// int audit=ipCfgService.getIsAudit(tableName,cfgId);
// List<AreaIpCfg> areaCfg=ipCfgService.getAreaCfgByCompileId(compileId);
// if(areaCfg!=null&&areaCfg.size()>0){
// for(AreaIpCfg c:areaCfg){
// c.setTableName(AreaIpCfg.getTablename());
// }
// }
//未审核时可删除
// if(audit!=Constants.AUDIT_YES&&audit!=Constants.AUDIT_NOT_YES){
// BaseIpCfg ipCfg=new BaseIpCfg();
// ipCfg.setCfgId(cfgId);
// ipCfg.setTableName(tableName);
// ipCfg.setEditorId(ipCfg.getCurrentUser().getId());
// ipCfg.setEditTime(new Date());
// ipCfg.setIsValid(Constants.VALID_DEL);
// int result=ipCfgService.deleteIpCfg(ipCfg,areaCfg);
// if(result==0){
// addMessage(model,"delete_failed");
// }else{
// addMessage(model,"delete_success");
// }
// }else{
// logger.error("通过审核/取消审核通过的配置不能删除!");
// addMessage(model,"delete_failed");
// }
}
ipCfgService.deleteIpCfg(ipCfgs,areaCfgs);
addMessage(model,"delete_success");

View File

@@ -17,7 +17,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
import com.nis.domain.Page;
import com.nis.domain.ServiceConfigInfo;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.BaseStringCfg;
import com.nis.util.Constants;
import com.nis.web.controller.BaseController;
@@ -253,6 +252,9 @@ public class StringCfgController extends BaseController{
bean.setMaatTable(maatTable);
}
List<AreaIpCfg> areaCfg=ipCfgService.getAreaCfgByCompileId(bean.getCompileId());
for(AreaIpCfg c:areaCfg){
c.setTableName(AreaIpCfg.getTablename());
}
bean.setAreaCfg(areaCfg);
auditAreaBeans.addAll(areaCfg);
}

View File

@@ -9,7 +9,7 @@ import com.nis.web.dao.CrudDao;
import com.nis.web.dao.MyBatisDao;
/**
* IP相关配置数据处理类
* 增强字符串相关配置数据处理类
* @author dell
*
*/
@@ -17,6 +17,7 @@ import com.nis.web.dao.MyBatisDao;
public interface ComplexStringCfgDao extends CrudDao<ComplexkeywordCfg>{
public ComplexkeywordCfg getById(@Param("tableName")String tableName,@Param("cfgId")Long id) ;
public ComplexkeywordCfg get(ComplexkeywordCfg entity) ;
public List<ComplexkeywordCfg> getList(@Param("tableName")String tableName,@Param("ids")String ids) ;
public List<ComplexkeywordCfg> findList(ComplexkeywordCfg entity) ;
public int insert(ComplexkeywordCfg entity) ;
public int updateByPrimaryKeySelective(ComplexkeywordCfg entity) ;
@@ -27,4 +28,5 @@ public interface ComplexStringCfgDao extends CrudDao<ComplexkeywordCfg>{
public int getIsAudit(@Param("tableName")String tableName,@Param("cfgId")Long id);
public int getIsAudit(ComplexkeywordCfg entity);
public int deleteByCompileId(ComplexkeywordCfg entity);
public int delete(@Param("tableName")String tableName,@Param("ids")String ids);
}

View File

@@ -100,6 +100,11 @@
AND IS_VALID!=-1
</trim>
</select>
<select id="getList" resultMap="ComplexStringMap">
SELECT
<include refid="ComplexkeywordCfg_Column_List_with_id" />
FROM ${tableName} WHERE IS_VALID!=-1 AND COMPILE_ID in (${ids})
</select>
<select id="findList" resultMap="ComplexStringMapWithUser">
select
<include refid="ComplexkeywordCfg_Column_List_with_id_alias"/>
@@ -419,4 +424,15 @@
<update id="deleteByCompileId" parameterType="com.nis.domain.configuration.ComplexkeywordCfg" >
update ${tableName} set is_valid = -1, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER}
</update>
<update id="delete" >
update ${tableName} set is_valid = -1, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP}
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="cfgId !=null ">
AND cfg_id = #{cfgId,jdbcType=BIGINT}
</if>
<if test="compileId !=null ">
AND compile_id = #{compileId,jdbcType=INTEGER}
</if>
</trim>
</update>
</mapper>

View File

@@ -437,7 +437,7 @@
<update id="deleteByCompileId" parameterType="com.nis.domain.configuration.BaseStringCfg" >
update ${tableName} set is_valid = -1, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP} where compile_id = #{compileId,jdbcType=INTEGER}
</update>
<update id="delete" parameterType="com.nis.domain.configuration.BaseStringCfg" >
<update id="delete" >
update ${tableName} set is_valid = -1, editor_id = #{editorId,jdbcType=INTEGER} , edit_time = #{editTime,jdbcType=TIMESTAMP}
<trim prefix="WHERE" prefixOverrides="AND |OR ">
<if test="cfgId !=null ">

View File

@@ -1,5 +1,6 @@
package com.nis.web.service.configuration;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
@@ -7,9 +8,12 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.nis.domain.configuration.AreaIpCfg;
import com.nis.domain.configuration.BaseCfg;
import com.nis.domain.configuration.BaseIpCfg;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.util.Constants;
import com.nis.web.dao.configuration.ComplexStringCfgDao;
import com.nis.web.dao.configuration.IpCfgDao;
import com.nis.web.service.CrudService;
/**
@@ -73,16 +77,27 @@ public class ComplexStringCfgService extends CrudService<ComplexStringCfgDao,Com
* @since 1.0.0
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int auditStringCfg(ComplexkeywordCfg sendCfg,ComplexkeywordCfg cfg) throws Exception{
if(Constants.AUDIT_NOT_YES==cfg.getIsAudit().intValue()||
Constants.AUDIT_YES==cfg.getIsAudit().intValue()){//审核通过,取消审核通过需要发到maat
if(sendToMaatConvertor(cfg.getIsAudit(),null,sendCfg)){
return complexStringCfgDao.audit(cfg);
public void auditStringCfg(int isAduit,List<ComplexkeywordCfg> auditCfg,List<AreaIpCfg> areaCfg,List<ComplexkeywordCfg> sendCfg) throws Exception{
List<BaseCfg[]> sendCfgs=new ArrayList<BaseCfg[]>();
for(ComplexkeywordCfg c:sendCfg){
BaseCfg[] cArr=new BaseCfg[1];
cArr[0]=c;
sendCfgs.add(cArr);
}
if(Constants.AUDIT_NOT_YES==isAduit||
Constants.AUDIT_YES==isAduit){//审核通过,取消审核通过需要发到maat
if(sendToMaatConvertorBatch(isAduit,sendCfgs)){
if(areaCfg!=null&&areaCfg.size()>0){
this.auditIpBatch(areaCfg);
}
this.auditBatch(auditCfg, IpCfgDao.class);
}
}else{
return complexStringCfgDao.audit(cfg);
if(areaCfg!=null&&areaCfg.size()>0){
this.auditIpBatch(areaCfg);
}
this.auditBatch(auditCfg, ComplexStringCfgDao.class);
}
return 0;
}
/**
*
@@ -95,11 +110,11 @@ public class ComplexStringCfgService extends CrudService<ComplexStringCfgDao,Com
* @since 1.0.0
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public int deleteStringCfg(ComplexkeywordCfg cfg,List<AreaIpCfg> areaCfg){
public void deleteStringCfg(List<ComplexkeywordCfg> cfgs,List<AreaIpCfg> areaCfg){
if(areaCfg!=null&&areaCfg.size()>0){
this.deleteIpBatch(areaCfg);
}
return complexStringCfgDao.updateValid(cfg);
this.deleteBatch(cfgs, ComplexStringCfgDao.class);
}
/**
*
@@ -127,4 +142,18 @@ public class ComplexStringCfgService extends CrudService<ComplexStringCfgDao,Com
public Integer getIsAudit(String tableName, long id){
return complexStringCfgDao.getIsAudit(tableName,id);
}
/**
* getList(这里用一句话描述这个方法的作用)
* (这里描述这个方法适用条件 可选)
* @param tableName
* @param ids
* @return
*List<BaseIpCfg>
* @exception
* @since 1.0.0
*/
public List<ComplexkeywordCfg> getList(String tableName, String ids) {
// TODO Auto-generated method stub
return complexStringCfgDao.getList(tableName, ids);
}
}