Commit 1063038f by zhengxj

finish service及其实现层 on 20190104 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@16311 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent c156f5be
...@@ -29,4 +29,9 @@ public interface SysMenuMapper { ...@@ -29,4 +29,9 @@ public interface SysMenuMapper {
int updateByPrimaryKeySelective(SysMenu record); int updateByPrimaryKeySelective(SysMenu record);
int updateByPrimaryKey(SysMenu record); int updateByPrimaryKey(SysMenu record);
} }
\ No newline at end of file \ No newline at end of file
package com.glsx.manager.pojo.menu; package com.glsx.manager.pojo.menu;
import java.beans.Transient;
import java.util.Date; import java.util.Date;
import java.util.List;
public class SysMenu { public class SysMenu {
private Integer id; private Integer id;
...@@ -33,8 +36,21 @@ public class SysMenu { ...@@ -33,8 +36,21 @@ public class SysMenu {
private String createBy; private String createBy;
private Byte label; private Byte label;
private List<SysMenu> children;
@Transient
public List<SysMenu> getChildren() {
return children;
}
public void setChildren(List<SysMenu> children) {
this.children = children;
}
public Integer getId() { public Integer getId() {
return id; return id;
} }
......
/**
*
*/
package com.glsx.manager.service;
import java.util.List;
import com.glsx.manager.pojo.menu.SysMenu;
import com.glsx.manager.pojo.menu.SysMenuExample;
/**
* @ClassName: SysMenuService
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月2日
*
*/
public interface ISysMenuService {
long countByExample(SysMenuExample example);
int deleteByExample(SysMenuExample example);
int deleteByPrimaryKey(Integer id);
int insertSelective(SysMenu sysMenu);
List<SysMenu> selectByExample(SysMenuExample example);
SysMenu selectByPrimaryKey(Integer id);
int updateByExampleSelective(SysMenu record, SysMenuExample example);
int updateByPrimaryKeySelective(SysMenu sysMenu);
int updateByPrimaryKey(SysMenu sysMenu);
}
/**
*
*/
package com.glsx.manager.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.glsx.common.constants.Constants;
import com.glsx.manager.mapper.SysMenuMapper;
import com.glsx.manager.pojo.menu.SysMenu;
import com.glsx.manager.pojo.menu.SysMenuExample;
import com.glsx.manager.service.ISysMenuService;
/**
* @ClassName: SysMenuServiceImpl
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年1月2日
*
*/
@Service
public class SysMenuServiceImpl implements ISysMenuService{
@Autowired
private SysMenuMapper menuDao;
@Override
public long countByExample(SysMenuExample example) {
return menuDao.countByExample(example);
}
@Override
public int deleteByExample(SysMenuExample example) {
long i = menuDao.countByExample(example);
return (int) (i > 0 ? 0 : i);
}
@Override
public int deleteByPrimaryKey(Integer id) {
return menuDao.deleteByPrimaryKey(id);
}
@Override
public int insertSelective(SysMenu sysMenu) {
SysMenuExample example = new SysMenuExample();
example.createCriteria().andParentIdEqualTo(sysMenu.getParentId());
List<SysMenu> list = menuDao.selectByExample(example);
if (list != null && list.size() > 0) {
for (SysMenu menu : list) {
if (menu.getSort() == sysMenu.getSort()) {
return 0;
}
}
}
return menuDao.insertSelective(sysMenu);
}
@Override
public List<SysMenu> selectByExample(SysMenuExample example) {
return menuDao.selectByExample(example);
}
@Override
public SysMenu selectByPrimaryKey(Integer id) {
return menuDao.selectByPrimaryKey(id);
}
@Override
public int updateByExampleSelective(SysMenu record, SysMenuExample example) {
return menuDao.updateByExample(record, example);
}
@Override
public int updateByPrimaryKeySelective(SysMenu sysMenu) {
return menuDao.updateByPrimaryKeySelective(sysMenu);
}
@Override
public int updateByPrimaryKey(SysMenu sysMenu) {
return updateByPrimaryKeySelective(sysMenu);
}
public void reSort(int parentId, int oldSort,int newSort, int operationType) {
SysMenuExample example = new SysMenuExample();
List<SysMenu> list = menuDao.selectByExample(example);
if (Constants.OPERATION_INSERT == operationType) {
example.createCriteria().andParentIdEqualTo(parentId).andSortGreaterThanOrEqualTo(newSort);
for (SysMenu sysMenu : list) {
sysMenu.setSort(sysMenu.getSort() + 1);
menuDao.updateByPrimaryKeySelective(sysMenu);
}
}
if (Constants.OPERATION_UPDATE == operationType) {
for (SysMenu sysMenu : list) {
sysMenu.setSort(sysMenu.getSort() + 1);
menuDao.updateByPrimaryKeySelective(sysMenu);
}
}
}
}
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<result column="menu_status" jdbcType="TINYINT" property="menuStatus" /> <result column="menu_status" jdbcType="TINYINT" property="menuStatus" />
<result column="menu_type" jdbcType="TINYINT" property="menuType" /> <result column="menu_type" jdbcType="TINYINT" property="menuType" />
<result column="menu_icon" jdbcType="VARCHAR" property="menuIcon" /> <result column="menu_icon" jdbcType="VARCHAR" property="menuIcon" />
<result column="is_ show" jdbcType="TINYINT" property="isShow" /> <result column="is_show" jdbcType="TINYINT" property="isShow" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="remark" jdbcType="VARCHAR" property="remark" /> <result column="remark" jdbcType="VARCHAR" property="remark" />
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, name, parent_id, sort, right_des, request_add, menu_status, menu_type, menu_icon, id, name, parent_id, sort, right_des, request_add, menu_status, menu_type, menu_icon,
"is_ show", create_time, update_time, remark, update_by, create_by, label "is_show", create_time, update_time, remark, update_by, create_by, label
</sql> </sql>
<select id="selectByExample" parameterType="com.glsx.manager.pojo.menu.SysMenuExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.glsx.manager.pojo.menu.SysMenuExample" resultMap="BaseResultMap">
select select
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
</selectKey> </selectKey>
insert into sys_menu (name, parent_id, sort, insert into sys_menu (name, parent_id, sort,
right_des, request_add, menu_status, right_des, request_add, menu_status,
menu_type, menu_icon, "is_ show", menu_type, menu_icon, "is_show",
create_time, update_time, remark, create_time, update_time, remark,
update_by, create_by, label update_by, create_by, label
) )
...@@ -161,7 +161,7 @@ ...@@ -161,7 +161,7 @@
menu_icon, menu_icon,
</if> </if>
<if test="isShow != null"> <if test="isShow != null">
"is_ show", "is_show",
</if> </if>
<if test="createTime != null"> <if test="createTime != null">
create_time, create_time,
...@@ -267,7 +267,7 @@ ...@@ -267,7 +267,7 @@
menu_icon = #{record.menuIcon,jdbcType=VARCHAR}, menu_icon = #{record.menuIcon,jdbcType=VARCHAR},
</if> </if>
<if test="record.isShow != null"> <if test="record.isShow != null">
"is_ show" = #{record.isShow,jdbcType=TINYINT}, "is_show" = #{record.isShow,jdbcType=TINYINT},
</if> </if>
<if test="record.createTime != null"> <if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
...@@ -303,7 +303,7 @@ ...@@ -303,7 +303,7 @@
menu_status = #{record.menuStatus,jdbcType=TINYINT}, menu_status = #{record.menuStatus,jdbcType=TINYINT},
menu_type = #{record.menuType,jdbcType=TINYINT}, menu_type = #{record.menuType,jdbcType=TINYINT},
menu_icon = #{record.menuIcon,jdbcType=VARCHAR}, menu_icon = #{record.menuIcon,jdbcType=VARCHAR},
"is_ show" = #{record.isShow,jdbcType=TINYINT}, "is_show" = #{record.isShow,jdbcType=TINYINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}, update_time = #{record.updateTime,jdbcType=TIMESTAMP},
remark = #{record.remark,jdbcType=VARCHAR}, remark = #{record.remark,jdbcType=VARCHAR},
...@@ -342,7 +342,7 @@ ...@@ -342,7 +342,7 @@
menu_icon = #{menuIcon,jdbcType=VARCHAR}, menu_icon = #{menuIcon,jdbcType=VARCHAR},
</if> </if>
<if test="isShow != null"> <if test="isShow != null">
"is_ show" = #{isShow,jdbcType=TINYINT}, "is_show" = #{isShow,jdbcType=TINYINT},
</if> </if>
<if test="createTime != null"> <if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
...@@ -375,7 +375,7 @@ ...@@ -375,7 +375,7 @@
menu_status = #{menuStatus,jdbcType=TINYINT}, menu_status = #{menuStatus,jdbcType=TINYINT},
menu_type = #{menuType,jdbcType=TINYINT}, menu_type = #{menuType,jdbcType=TINYINT},
menu_icon = #{menuIcon,jdbcType=VARCHAR}, menu_icon = #{menuIcon,jdbcType=VARCHAR},
"is_ show" = #{isShow,jdbcType=TINYINT}, "is_show" = #{isShow,jdbcType=TINYINT},
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP}, update_time = #{updateTime,jdbcType=TIMESTAMP},
remark = #{remark,jdbcType=VARCHAR}, remark = #{remark,jdbcType=VARCHAR},
...@@ -384,4 +384,25 @@ ...@@ -384,4 +384,25 @@
label = #{label,jdbcType=TINYINT} label = #{label,jdbcType=TINYINT}
where id = #{id,jdbcType=INTEGER} where id = #{id,jdbcType=INTEGER}
</update> </update>
<resultMap type="com.glsx.manager.pojo.menu.SysMenu" id="recursionMenuMap" extends="BaseResultMap">
<collection property="children" ofType="com.glsx.manager.pojo.menu.SysMenu"
column="id" select="findMenuByParentId" />
</resultMap>
<select id="findAllRecursion" resultMap="recursionMenuMap">
SELECT
<include refid="Base_Column_List" />
FROM sys_menu WHERE parent_id ='' or parent_id is
NULL ORDER BY `order` ASC
</select>
<select id="findMenuByParentId" resultType="com.glsx.manager.pojo.menu.SysMenu">
SELECT
id,`name`,parent_id,url FROM menu WHERE parent_id = #{id} ORDER BY
`order` ASC
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!