提交 a070de80 编写于 作者: L laijiaping

修改不同系统编辑器模板类型的同名校验规则

上级 85942030
......@@ -21,7 +21,9 @@ public interface SysEveModelDao {
public List<Map<String, Object>> querySysEveModelList(Map<String, Object> map) throws Exception;
public Map<String, Object> querySysEveModelMationByName(Map<String, Object> map) throws Exception;
public Map<String, Object> querySysEveModelMationByNameAndType(Map<String, Object> map) throws Exception;
public Map<String, Object> querySysEveModelMationByNameAndUser(Map<String, Object> map) throws Exception;
public int insertSysEveModelMation(Map<String, Object> map) throws Exception;
......
......@@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -72,14 +73,20 @@ public class SysEveModelServiceImpl implements SysEveModelService {
@Transactional(value="transactionManager")
public void insertSysEveModelMation(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> bean = sysEveModelDao.querySysEveModelMationByName(map);
map.put("userId", inputObject.getLogParams().get("id"));
Map<String, Object> bean = new HashMap<>();
String type = map.get("type").toString();
if ("1".equals(type)){
bean = sysEveModelDao.querySysEveModelMationByNameAndType(map);
} else if ("2".equals(type)){
bean = sysEveModelDao.querySysEveModelMationByNameAndUser(map);
}
if(bean != null && !bean.isEmpty()){
outputObject.setreturnMessage("该系统编辑器模板已存在,请更换");
}else{
Map<String, Object> user = inputObject.getLogParams();
map.put("id", ToolUtil.getSurFaceId());
map.put("pageNum", ToolUtil.getUniqueKey().substring(10, 20));
map.put("createId", user.get("id"));
map.put("createTime", DateUtil.getTimeAndToString());
sysEveModelDao.insertSysEveModelMation(map);
}
......@@ -134,12 +141,18 @@ public class SysEveModelServiceImpl implements SysEveModelService {
@Transactional(value="transactionManager")
public void editSysEveModelMationById(InputObject inputObject, OutputObject outputObject) throws Exception {
Map<String, Object> map = inputObject.getParams();
Map<String, Object> b = sysEveModelDao.querySysEveModelMationByName(map);
if(b != null && !b.isEmpty()){
map.put("userId", inputObject.getLogParams().get("id"));
Map<String, Object> bean = new HashMap<>();
String type = map.get("type").toString();
if ("1".equals(type)){
bean = sysEveModelDao.querySysEveModelMationByNameAndType(map);
} else if ("2".equals(type)){
bean = sysEveModelDao.querySysEveModelMationByNameAndUser(map);
}
if(bean != null && !bean.isEmpty()){
outputObject.setreturnMessage("该编辑器模板已存在,请更换");
}else{
map.put("lastUpdateTime", DateUtil.getTimeAndToString());
map.put("userId", inputObject.getLogParams().get("id"));
sysEveModelDao.editSysEveModelMationById(map);
}
}
......
......@@ -29,14 +29,28 @@
</if>
ORDER BY a.create_time DESC
</select>
<select id="querySysEveModelMationByName" parameterType="java.util.Map" resultType="java.util.Map">
<select id="querySysEveModelMationByNameAndType" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id
FROM
sys_eve_model a
WHERE
a.title = #{title}
AND a.type = #{type}
<if test="id != '' and id != null">
AND a.id != #{id}
</if>
</select>
<select id="querySysEveModelMationByNameAndUser" parameterType="java.util.Map" resultType="java.util.Map">
SELECT
a.id
FROM
sys_eve_model a
WHERE
a.title = #{title}
AND a.create_id = #{userId}
<if test="id != '' and id != null">
AND a.id != #{id}
</if>
......@@ -45,7 +59,7 @@
<insert id="insertSysEveModelMation" parameterType="java.util.Map">
INSERT INTO sys_eve_model
(id, title, content, type, create_id, create_time, first_type_id, second_type_id, last_update_id, last_update_time)
VALUES(#{id}, #{title}, #{content}, #{type}, #{createId}, #{createTime}, #{firstTypeId}, #{secondTypeId}, #{createId}, #{createTime})
VALUES(#{id}, #{title}, #{content}, #{type}, #{userId}, #{createTime}, #{firstTypeId}, #{secondTypeId}, #{userId}, #{createTime})
</insert>
<delete id="deleteSysEveModelById" parameterType="java.util.Map">
......
......@@ -104,7 +104,7 @@
</url>
<url id="sysevemodel002" path="/post/SysEveModelController/insertSysEveModelMation" val="新增系统编辑器模板" method="POST" allUse="1" groupName="系统编辑器模板">
<property id="title" name="title" ref="required" var="标题" />
<property id="content" name="content" ref="" var="模板内容"/>
<property id="content" name="content" ref="required" var="模板内容"/>
<property id="type" name="type" ref="required,num" var="模板类型"/>
<property id="firstTypeId" name="firstTypeId" ref="required" var="所属一级分类" />
<property id="secondTypeId" name="secondTypeId" ref="required" var="所属二级分类" />
......@@ -117,8 +117,8 @@
</url>
<url id="sysevemodel005" path="/post/SysEveModelController/editSysEveModelMationById" val="通过id编辑对应的系统编辑器模板" method="PUT" allUse="1" groupName="系统编辑器模板">
<property id="id" name="id" ref="required" var="模板id" />
<property id="title" name="title" ref="" var="标题" />
<property id="content" name="content" ref="" var="模板内容" />
<property id="title" name="title" ref="required" var="标题" />
<property id="content" name="content" ref="required" var="模板内容" />
<property id="type" name="type" ref="required,num" var="模板类型"/>
<property id="firstTypeId" name="firstTypeId" ref="required" var="所属一级分类" />
<property id="secondTypeId" name="secondTypeId" ref="required" var="所属二级分类" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册