特定服务(APP)功能修改,增加特定服务码字段

This commit is contained in:
zhangwei
2018-06-21 09:12:25 +08:00
parent 5f401d6f1f
commit 0866888337
6 changed files with 46 additions and 44 deletions

View File

@@ -17,7 +17,7 @@ public class SpecificServiceCfg extends BaseEntity<SpecificServiceCfg>{
private static final long serialVersionUID = -1133644323636425766L;
private Integer specServiceId; //spec_service_id 协议ID int N 主键,初始化
//private Integer specServiceCode; //协议编码 int N 暂定,以后可扩展 1000微信 , 1001QQ
private Integer specServiceCode; //协议编码 int N 暂定,以后可扩展 1000微信 , 1001QQ
private String specServiceName; //spec_service_name 协议名称 varchar(64) N
private String specServiceDesc; //spec_service_desc 协议描述 varchar2(64) N
private Integer isValid; //is_valid 有效标志 int N 1-有效 0-无效
@@ -36,6 +36,12 @@ public class SpecificServiceCfg extends BaseEntity<SpecificServiceCfg>{
public void setSpecServiceId(Integer specServiceId) {
this.specServiceId = specServiceId;
}
public Integer getSpecServiceCode() {
return specServiceCode;
}
public void setSpecServiceCode(Integer specServiceCode) {
this.specServiceCode = specServiceCode;
}
public String getSpecServiceName() {
return specServiceName;
}

View File

@@ -147,9 +147,9 @@ public class SpecificServiceCfgController extends BaseController {
@RequiresPermissions(value= {"specific:service:add","specific:service:edit"},logical=Logical.OR)
@RequestMapping(value="saveOrUpdate")
public String saveOrUpdate(SpecificServiceCfg specificServiceCfg, Model model,
RedirectAttributes redirectAttributes,Integer oldId) {
RedirectAttributes redirectAttributes) {
try {
specificServiceCfgService.saveOrUpdate(specificServiceCfg,oldId);
specificServiceCfgService.saveOrUpdate(specificServiceCfg);
addMessage(redirectAttributes, "save_success");
} catch (Exception e) {
e.printStackTrace();

View File

@@ -4,6 +4,7 @@
<resultMap id="CFGResultMap" type="com.nis.domain.specific.SpecificServiceCfg" >
<id column="spec_service_id" property="specServiceId" jdbcType="INTEGER" />
<result column="spec_service_code" property="specServiceCode" jdbcType="INTEGER" />
<result column="spec_service_name" property="specServiceName" jdbcType="VARCHAR" />
<result column="spec_service_desc" property="specServiceDesc" jdbcType="VARCHAR" />
<result column="is_valid" property="isValid" jdbcType="INTEGER" />
@@ -18,6 +19,7 @@
<sql id="specificServiceCfgColumns">
s.spec_service_id AS specServiceId,
s.spec_service_code AS specServiceCode,
s.spec_service_name AS specServiceName,
s.spec_service_desc AS specServiceDesc,
s.is_valid AS isValid,
@@ -62,6 +64,9 @@
<if test="specServiceId != null">
AND s2.spec_service_id like '%${specServiceId}%'
</if>
<if test="specServiceCode != null">
AND spec_service_code = #{specServiceCode}
</if>
<if test="specServiceName != null and specServiceName != '' ">
AND s2.spec_service_name like '%${specServiceName}%'
</if>
@@ -93,7 +98,10 @@
<select id="findAllSpecificServiceCfg" resultMap="CFGResultMap" >
SELECT * from specific_service_cfg where is_valid = 1
<if test="specificServiceCfg.specServiceId != null">
AND spec_service_id like '%${specificServiceCfg.specServiceId}%'
AND spec_service_id =#{specificServiceCfg.specServiceId}
</if>
<if test="specificServiceCfg.specServiceCode != null">
AND spec_service_id =#{specificServiceCfg.specServiceCode}
</if>
<if test="specificServiceCfg.specServiceName != null and specificServiceCfg.specServiceName != '' ">
AND spec_service_name like '%${specificServiceCfg.specServiceName}%'
@@ -122,22 +130,22 @@
<!-- 新增 -->
<insert id="insert" parameterType="com.nis.domain.specific.SpecificServiceCfg" useGeneratedKeys="true">
insert into specific_service_cfg (spec_service_id,spec_service_name,spec_service_desc,is_valid, op_time, parent_id,is_leaf,group_id)
values(#{specServiceId},#{specServiceName},#{specServiceDesc},#{isValid},#{opTime},#{parent.specServiceId},#{isLeaf},#{groupId})
insert into specific_service_cfg (spec_service_code,spec_service_name,spec_service_desc,is_valid, op_time, parent_id,is_leaf,group_id)
values(#{specServiceCode},#{specServiceName},#{specServiceDesc},#{isValid},#{opTime},#{parent.specServiceId},#{isLeaf},#{groupId})
</insert>
<!-- 修改 -->
<update id="update" parameterType="com.nis.domain.specific.SpecificServiceCfg">
UPDATE specific_service_cfg s SET
s.spec_service_id = #{specificServiceCfg.specServiceId},
s.spec_service_name = #{specificServiceCfg.specServiceName},
s.spec_service_desc = #{specificServiceCfg.specServiceDesc},
s.is_valid = #{specificServiceCfg.isValid},
s.op_time = #{specificServiceCfg.opTime},
s.parent_id = #{specificServiceCfg.parent.specServiceId},
s.is_leaf = #{specificServiceCfg.isLeaf},
s.group_id = #{specificServiceCfg.groupId}
WHERE s.spec_service_id = #{oldId}
s.spec_service_code = #{specServiceCode},
s.spec_service_name = #{specServiceName},
s.spec_service_desc = #{specServiceDesc},
s.is_valid = #{isValid},
s.op_time = #{opTime},
s.parent_id = #{parent.specServiceId},
s.is_leaf = #{isLeaf},
s.group_id = #{groupId}
WHERE s.spec_service_id = #{specServiceId}
</update>
<!-- 删除 -->

View File

@@ -4,6 +4,7 @@ import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -13,6 +14,7 @@ import com.nis.domain.Page;
import com.nis.domain.specific.ConfigGroupInfo;
import com.nis.domain.specific.SpecificServiceCfg;
import com.nis.main.ConvertTool;
import com.nis.util.ConfigServiceUtil;
import com.nis.util.StringUtil;
import com.nis.web.dao.specific.SpecificServiceCfgDao;
import com.nis.web.service.BaseService;
@@ -65,9 +67,10 @@ public class SpecificServiceCfgService extends BaseService{
* @throws Exception
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveOrUpdate(SpecificServiceCfg specificServiceCfg, Integer oldId) throws Exception {
public void saveOrUpdate(SpecificServiceCfg specificServiceCfg) throws Exception {
if(specificServiceCfg.getGroupId()==null || specificServiceCfg.getGroupId()==0){
specificServiceCfg.setGroupId(new ConvertTool().getGroupId());
Integer groupId = ConfigServiceUtil.getId(2, 1).get(0);
specificServiceCfg.setGroupId(groupId);
}
//新增协议分组
ConfigGroupInfo group = specificServiceCfgDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId());
@@ -79,26 +82,13 @@ public class SpecificServiceCfgService extends BaseService{
group.setGroupType(1);
specificServiceCfgDao.insertConfigGroupInfo(group);
}
if(oldId==null){//新增
if(specificServiceCfg.getSpecServiceId()==null){//新增
specificServiceCfg.setIsValid(1);
specificServiceCfg.setOpTime(new Date());
specificServiceCfgDao.insert(specificServiceCfg);
}else{//修改
specificServiceCfg.setOpTime(new Date());
//修改id则将其子类的parent_id一并修改
if(oldId!=specificServiceCfg.getSpecServiceId()){
//找出所有子类
List<SpecificServiceCfg> list = specificServiceCfgDao.getChildrenById(oldId);
SpecificServiceCfg se =new SpecificServiceCfg();
se.setSpecServiceId(specificServiceCfg.getSpecServiceId());
for(SpecificServiceCfg ss:list){
if(ss!=null){
ss.setParent(se);
specificServiceCfgDao.update(ss,ss.getSpecServiceId());
}
}
}
specificServiceCfgDao.update(specificServiceCfg,oldId);
specificServiceCfgDao.update(specificServiceCfg);
}
}
/**