ZhuDongming
2019-10-18 a73c63037e6a5276ce6442873afc627e8cb2c9b0
update
5 files added
16 files modified
510 ■■■■■ changed files
src/main/java/com/moral/controller/AccountRoleController.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/MenuController.java 12 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/RoleController.java 22 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/RoleMenuController.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/Channel.java 30 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/Menu.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/Role.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/ChannelMapper.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/MenuMapper.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/RoleMapper.java 9 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/ChannelService.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/MenuService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/RoleService.java 10 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/AccountRoleServiceImpl.java 4 ●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/ChannelServiceImpl.java 25 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/MenuServiceImpl.java 34 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/RoleMenuServiceImpl.java 4 ●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/RoleServiceImpl.java 51 ●●●● patch | view | raw | blame | history
src/main/resources/mapper/ChannelMapper.xml 33 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/MenuMapper.xml 36 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/RoleMapper.xml 195 ●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/AccountRoleController.java
@@ -39,7 +39,7 @@
    @GetMapping("role-list")
    public ResultBean getRoleList(String roleName) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        resultBean.setData(roleService.getRoleList(roleName));
        resultBean.setData(roleService.getRoleListByName(roleName));
        return resultBean;
    }
src/main/java/com/moral/controller/MenuController.java
@@ -12,6 +12,7 @@
import com.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.Menu;
import com.moral.service.ChannelService;
import com.moral.service.MenuService;
@RestController
@@ -20,6 +21,9 @@
public class MenuController {
    @Resource
    MenuService menuService;
    @Resource
    ChannelService channelService;
    @GetMapping("count-by-example")
    public ResultBean<Integer> countByExample(PageBean pageBean) {
@@ -33,9 +37,11 @@
        return resultBean;
    }
    @GetMapping("page-list")
    public PageBean pageList(PageBean pageBean) {
        return menuService.queryByPageBean(pageBean);
    @GetMapping("channel-list")
    public ResultBean getChannelList(String channelName) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        resultBean.setData(channelService.getChannelList(channelName));
        return resultBean;
    }
    @GetMapping("page-allList")
src/main/java/com/moral/controller/RoleController.java
@@ -1,7 +1,5 @@
package com.moral.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
@@ -13,6 +11,7 @@
import com.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.Role;
import com.moral.service.ChannelService;
import com.moral.service.RoleService;
@RestController
@@ -23,14 +22,24 @@
    @Autowired
    RoleService roleService;
    @Autowired
    ChannelService channelService;
    @GetMapping("count-by-example")
    public ResultBean<Integer> countByExample(PageBean pageBean){
        return  new ResultBean<Integer>(roleService.countByExample(pageBean));
    }
    @GetMapping("page-list")
    public PageBean pageList(PageBean pageBean) {
        return roleService.queryByPageBean(pageBean);
    @GetMapping("role-list")
    public PageBean getRoleList(PageBean pageBean) {
        return roleService.getRoleList(pageBean);
    }
    @GetMapping("channel-list")
    public ResultBean getChannelList(String channelName) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        resultBean.setData(channelService.getChannelList(channelName));
        return resultBean;
    }
    @PostMapping("add-or-modify")
@@ -41,9 +50,10 @@
    }
    @PostMapping("delete-by-ids")
    public ResultBean deleteByIds(@RequestBody List<Integer> ids){
    public ResultBean deleteByIds(@RequestBody Integer [] ids){
        roleService.deleteByIds(ids);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
}
src/main/java/com/moral/controller/RoleMenuController.java
@@ -33,7 +33,7 @@
    @GetMapping("role-list")
    public ResultBean getRoleList(String roleName) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        resultBean.setData(roleService.getRoleList(roleName));
        resultBean.setData(roleService.getRoleListByName(roleName));
        return resultBean;
    }
src/main/java/com/moral/entity/Channel.java
New file
@@ -0,0 +1,30 @@
package com.moral.entity;
import java.util.Date;
import lombok.Data;
@Data
public class Channel {
    private Integer id;
    private String channelCode;
    private String channelName;
    private String channelRemark;
    private String channelIsDelete;
    private Date createTime;
    private String createUser;
    private Date updateTime;
    private String updateUser;
    private String extI;
    private String extII;
}
src/main/java/com/moral/entity/Menu.java
@@ -3,6 +3,7 @@
import java.util.Date;
import javax.persistence.Id;
import javax.persistence.Transient;
import lombok.Data;
@@ -14,6 +15,8 @@
    private String menuCode;
    private String menuName;
    private Integer channelId;
    private String menuIcon;
@@ -35,4 +38,7 @@
    private String updateUser;
    @Transient
    private Channel channel;
}
src/main/java/com/moral/entity/Role.java
@@ -3,6 +3,7 @@
import java.util.Date;
import javax.persistence.Id;
import javax.persistence.Transient;
import lombok.Data;
@@ -15,6 +16,8 @@
    private String roleName;
    private Integer channelId;
    private String isDelete;
    private String roleRemark;
@@ -27,4 +30,7 @@
    private String updateUser;
    @Transient
    private Channel channel;
}
src/main/java/com/moral/mapper/ChannelMapper.java
New file
@@ -0,0 +1,15 @@
package com.moral.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.Account;
import com.moral.entity.Channel;
public interface ChannelMapper extends BaseMapper<Account> {
    List<Channel> getChannelList(@Param("channelName") String channelName);
}
src/main/java/com/moral/mapper/MenuMapper.java
@@ -12,6 +12,8 @@
public interface MenuMapper extends BaseMapper<Menu> {
    int countByExample(Example example);
    List<Menu> selectWithMenuNameByExample(Example example);
    List<Menu> getMenuList(Example example);
src/main/java/com/moral/mapper/RoleMapper.java
@@ -7,11 +7,14 @@
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.Role;
import tk.mybatis.mapper.entity.Example;
public interface RoleMapper extends BaseMapper<Role> {
    int insertSelective(Role role);
    int updateByPrimaryKey(Role role);
    int updateByPrimaryKeySelective(Role role);
    List<Role> getRoleListByName(@Param("roleName") String roleName);
    List<Role> getRoleList(@Param("roleName") String roleName);
    List<Role> getRoleList(Example example);
}
src/main/java/com/moral/service/ChannelService.java
New file
@@ -0,0 +1,10 @@
package com.moral.service;
import java.util.List;
import com.moral.entity.Channel;
public interface ChannelService {
    List<Channel> getChannelList(String channelName);
}
src/main/java/com/moral/service/MenuService.java
@@ -8,8 +8,6 @@
public interface MenuService {
    void addOrModify(Menu menu);
    PageBean queryByPageBean(PageBean pageBean);
    PageBean queryByAllPageBean(PageBean pageBean);
    int countByExample(PageBean pageBean);
src/main/java/com/moral/service/RoleService.java
@@ -7,13 +7,13 @@
public interface RoleService {
    PageBean<Role> queryByPageBean(PageBean pageBean);
    void addOrModify(Role role);
    int deleteByIds(List<Integer> ids);
    int countByExample(PageBean pageBean);
    List<Role> getRoleList(String roleName);
    List<Role> getRoleListByName(String roleName);
    PageBean getRoleList(PageBean pageBean);
    void deleteByIds(Integer... ids);
}
src/main/java/com/moral/service/impl/AccountRoleServiceImpl.java
@@ -6,6 +6,7 @@
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.PageHelper;
import com.moral.common.bean.PageBean;
@@ -25,6 +26,7 @@
    private AccountRoleMapper accountRoleMapper;
    @Override
    @Transactional
    public void addOrModify(AccountRole accountRole) {
        try {
            if (accountRole.getId() != null) {
@@ -60,6 +62,7 @@
    }
    @Override
    @Transactional
    public void deleteByIds(Integer... ids) {
        if (ids != null && ids.length > 0) {
            if (ids.length == 1) {
@@ -69,7 +72,6 @@
                example.or().andIn("id", Arrays.asList(ids));
                accountRoleMapper.deleteByExample(example);
            }
        }
    }
src/main/java/com/moral/service/impl/ChannelServiceImpl.java
New file
@@ -0,0 +1,25 @@
package com.moral.service.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.moral.entity.Channel;
import com.moral.mapper.ChannelMapper;
import com.moral.service.ChannelService;
@Service
public class ChannelServiceImpl implements ChannelService {
    @Resource
    private ChannelMapper channelMapper;
    @Override
    public List<Channel> getChannelList(String channelName) {
        List<Channel> channelList = channelMapper.getChannelList(channelName);
        return channelList;
    }
}
src/main/java/com/moral/service/impl/MenuServiceImpl.java
@@ -8,6 +8,7 @@
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.PageHelper;
import com.moral.common.bean.Constants;
@@ -17,6 +18,7 @@
import com.moral.mapper.MenuMapper;
import com.moral.service.MenuService;
import com.moral.util.TkMybatisUtils;
import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import tk.mybatis.mapper.entity.Example;
@@ -29,6 +31,7 @@
    private MenuMapper menuMapper;
    @Override
    @Transactional
    public void addOrModify(Menu menu) {
        try {
            menu.setUpdateTime(new Date());
@@ -44,6 +47,8 @@
                    menu.setId(menuResult.getId());
                    menuMapper.updateByPrimaryKeySelective(menu);
                } else {
                    System.out.println("channelId:"+menu.getChannelId());
                    menu.setChannelId(menu.getChannelId());
                    menu.setIsDelete(Constants.IS_DELETE_FALSE);
                    menu.setCreateTime(new Date());
                    menu.setCreateUser(menu.getCreateUser());
@@ -53,31 +58,6 @@
        } catch (Exception ex) {
            throw ex;
        }
    }
    @Override
    public PageBean queryByPageBean(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
        List<Example.Criteria> criteriaList = example.getOredCriteria();
        if (criteriaList != null && criteriaList.size() > 0) {
            for (Example.Criteria cri : criteriaList) {
                cri.andNotEqualTo("isDelete", Constants.IS_DELETE_TRUE);
            }
        } else {
            example.or().andNotEqualTo("isDelete", Constants.IS_DELETE_TRUE);
        }
        if (example.getOrderByClause() == null || example.getOrderByClause().isEmpty()) {
            example.setOrderByClause("menu_name asc");
        }
        List<Menu> menuList = menuMapper.selectWithMenuNameByExample(example);
        Iterator<Menu> iterator = menuList.iterator();
        while (iterator.hasNext()) {
            Menu menu = iterator.next();
            if (menu.getMenuParentId() == null) {
                iterator.remove();
            }
        }
        return new PageBean(menuList);
    }
    @Override
@@ -103,12 +83,13 @@
    public int countByExample(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
        TkMybatisUtils.addDeletesToExample(example);
        return menuMapper.selectCountByExample(example);
        return menuMapper.countByExample(example);
    }
    @Override
    public PageBean getMenuList(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
        TkMybatisUtils.addDeletesToExample(example);
        if (pageBean.getPageSize() > 0) {
            PageHelper.startPage(pageBean.getPageIndex(), pageBean.getPageSize());
        }
@@ -123,6 +104,7 @@
    }
    @Override
    @Transactional
    public void deleteByIds(Integer[] ids) {
        Menu menu = new Menu();
        menu.setIsDelete(Constants.IS_DELETE_TRUE);
src/main/java/com/moral/service/impl/RoleMenuServiceImpl.java
@@ -6,6 +6,7 @@
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.PageHelper;
import com.moral.common.bean.PageBean;
@@ -25,6 +26,7 @@
    private RoleMenuMapper roleMenuMapper;
    @Override
    @Transactional
    public void addOrModify(RoleMenu roleMenu) {
        try {
            if (roleMenu.getId() != null) {
@@ -60,6 +62,7 @@
    }
    @Override
    @Transactional
    public void deleteByIds(Integer... ids) {
        if (ids != null && ids.length > 0) {
            if (ids.length == 1) {
@@ -69,7 +72,6 @@
                example.or().andIn("id", Arrays.asList(ids));
                roleMenuMapper.deleteByExample(example);
            }
        }
    }
src/main/java/com/moral/service/impl/RoleServiceImpl.java
@@ -1,5 +1,6 @@
package com.moral.service.impl;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@@ -8,10 +9,10 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.github.pagehelper.PageHelper;
import com.moral.common.bean.Constants;
import com.moral.common.bean.PageBean;
import com.moral.common.util.ExampleUtil;
import com.moral.common.util.MyBatisBaseMapUtil;
import com.moral.entity.Role;
import com.moral.mapper.RoleMapper;
import com.moral.service.RoleService;
@@ -28,27 +29,20 @@
    RoleMapper roleMapper;
    @Override
    public PageBean<Role> queryByPageBean(PageBean pageBean) {
        return MyBatisBaseMapUtil.queryPage(roleMapper, pageBean, ENTITY_CLASS);
    }
    @Override
    @Transactional
    public void addOrModify(Role role) {
        try {
            role.setUpdateTime(new Date());
            role.setUpdateUser(role.getUpdateUser());
            if (role.getId() != null) {
                roleMapper.updateByPrimaryKeySelective(role);
                roleMapper.updateByPrimaryKey(role);
            } else {
                Role roleQuery = new Role();
                roleQuery.setRoleCode(role.getRoleCode());
                roleQuery.setIsDelete(Constants.IS_DELETE_FALSE);
                Role roleResult = roleMapper.selectOne(roleQuery);
                if (roleResult != null) {
                    role.setId(roleResult.getId());
                    roleMapper.updateByPrimaryKeySelective(role);
                } else {
                if (roleResult == null) {
                    role.setChannelId(role.getChannelId());
                    role.setIsDelete(Constants.IS_DELETE_FALSE);
                    role.setCreateTime(new Date());
                    role.setCreateUser(role.getCreateUser());
@@ -61,16 +55,6 @@
    }
    @Override
    @Transactional
    public int deleteByIds(List<Integer> ids) {
        Role role = new Role();
        role.setIsDelete(Constants.IS_DELETE_TRUE);
        Example example = new Example(ENTITY_CLASS);
        example.or().andIn("id", ids);
        return roleMapper.updateByExampleSelective(role, example);
    }
    @Override
    public int countByExample(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
        TkMybatisUtils.addDeletesToExample(example);
@@ -78,9 +62,30 @@
    }
    @Override
    public List<Role> getRoleList(String roleName) {
        List<Role> roleList = roleMapper.getRoleList(roleName);
    public List<Role> getRoleListByName(String roleName) {
        List<Role> roleList = roleMapper.getRoleListByName(roleName);
        return roleList;
    }
    @Override
    public PageBean getRoleList(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
        TkMybatisUtils.addDeletesToExample(example);
        if (pageBean.getPageSize() > 0) {
            PageHelper.startPage(pageBean.getPageIndex(), pageBean.getPageSize());
        }
        List<Role> roleList = roleMapper.getRoleList(example);
        return new PageBean(roleList);
    }
    @Override
    @Transactional
    public void deleteByIds(Integer... ids) {
        Role role = new Role();
        role.setIsDelete(Constants.IS_DELETE_TRUE);
        Example example = new Example(ENTITY_CLASS);
        example.or().andIn("id", Arrays.asList(ids));
        roleMapper.updateByExampleSelective(role, example);
    }
}
src/main/resources/mapper/ChannelMapper.xml
New file
@@ -0,0 +1,33 @@
<?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.moral.mapper.ChannelMapper">
    <resultMap id="BaseResultMap" type="com.moral.entity.Channel" >
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="channel_code" property="channelCode" jdbcType="VARCHAR" />
        <result column="channel_name" property="channelName" jdbcType="VARCHAR" />
        <result column="channel_remark" property="channelRemark" jdbcType="VARCHAR" />
        <result column="channel_is_delete" property="channelIsDelete" jdbcType="CHAR" />
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="create_user" property="createUser" jdbcType="VARCHAR" />
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="update_user" property="updateUser" jdbcType="VARCHAR" />
        <result column="ext_I" property="extI" jdbcType="VARCHAR" />
        <result column="ext_II" property="extII" jdbcType="VARCHAR" />
    </resultMap>
    <sql id="Base_Column_List" >
        id, channel_code, channel_name, channel_remark, channel_is_delete, create_time, create_user,
        update_time, update_user, ext_I, ext_II
    </sql>
    <select id="getChannelList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from channel
        where channel_is_delete=1
        <if test="channelName != 'null'">
            and channel_name like concat('%',#{channelName},'%')
        </if>
    </select>
</mapper>
src/main/resources/mapper/MenuMapper.xml
@@ -1,10 +1,11 @@
<?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.moral.mapper.MenuMapper">
    <resultMap id="BaseResultMap" type="com.moral.entity.Menu">
    <resultMap id="ResultMap" type="com.moral.entity.Menu">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="menu_code" property="menuCode" jdbcType="VARCHAR"/>
        <result column="menu_name" property="menuName" jdbcType="VARCHAR"/>
        <result column="channel_id" property="channelId" jdbcType="INTEGER" />
        <result column="menu_icon" property="menuIcon" jdbcType="VARCHAR"/>
        <result column="menu_url" property="menuUrl" jdbcType="VARCHAR"/>
        <result column="menu_order" property="menuOrder" jdbcType="INTEGER"/>
@@ -15,6 +16,13 @@
        <result column="create_user" property="createUser" jdbcType="VARCHAR"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="update_user" property="updateUser" jdbcType="VARCHAR"/>
    </resultMap>
    <resultMap id="BaseResultMap" type="com.moral.entity.Menu" extends="ResultMap">
        <association property="channel" javaType="com.moral.entity.Channel">
            <result column="channel_id" jdbcType="INTEGER" property="id" />
            <result column="channel_name" jdbcType="VARCHAR" property="channelName" />
        </association>
    </resultMap>
    <sql id="Example_Where_Clause">
@@ -48,13 +56,20 @@
        </where>
    </sql>
    <select id="selectWithMenuNameByExample" parameterType="tk.mybatis.mapper.entity.Example" resultMap="BaseResultMap">
    <select id="countByExample" parameterType="tk.mybatis.mapper.entity.Example" resultType="java.lang.Integer" >
        select count(*) from menu m
        <if test="_parameter != null" >
            <include refid="Example_Where_Clause" />
        </if>
    </select>
    <select id="selectWithMenuNameByExample" parameterType="tk.mybatis.mapper.entity.Example" resultMap="ResultMap">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from menu
        from menu m
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
@@ -65,11 +80,10 @@
    <select id="getMenuList" resultMap="BaseResultMap" parameterType="tk.mybatis.mapper.entity.Example">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from menu
        m.*,
        c.channel_name
        from menu m
        left join channel c on m.channel_id = c.id
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
@@ -79,11 +93,11 @@
    </select>
    <sql id="Base_Column_List">
        id, menu_code, menu_name, menu_icon, menu_url, menu_order, menu_parent_id, menu_remark,
        id, menu_code, menu_name, channel_id, menu_icon, menu_url, menu_order, menu_parent_id, menu_remark,
        is_delete, create_time, create_user, update_time, update_user
    </sql>
    <select id="getParentMenuList" resultMap="BaseResultMap">
    <select id="getParentMenuList" resultMap="ResultMap">
        select
        distinct
        <include refid="Base_Column_List"/>
@@ -96,7 +110,7 @@
        </if>
    </select>
    <select id="getMenuListByName" resultMap="BaseResultMap">
    <select id="getMenuListByName" resultMap="ResultMap">
        select
        <include refid="Base_Column_List"/>
        from menu
src/main/resources/mapper/RoleMapper.xml
@@ -2,107 +2,62 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.moral.mapper.RoleMapper">
    <resultMap id="BaseResultMap" type="com.moral.entity.Role">
        <id column="id" property="id" jdbcType="INTEGER"/>
        <result column="role_code" property="roleCode" jdbcType="VARCHAR"/>
        <result column="role_name" property="roleName" jdbcType="VARCHAR"/>
        <result column="is_delete" property="isDelete" jdbcType="CHAR"/>
        <result column="role_remark" property="roleRemark" jdbcType="VARCHAR"/>
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
        <result column="create_user" property="createUser" jdbcType="VARCHAR"/>
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
        <result column="update_user" property="updateUser" jdbcType="VARCHAR"/>
    <resultMap id="ResultMap" type="com.moral.entity.Role">
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="role_code" property="roleCode" jdbcType="VARCHAR" />
        <result column="role_name" property="roleName" jdbcType="VARCHAR" />
        <result column="channel_id" property="channelId" jdbcType="INTEGER" />
        <result column="is_delete" property="isDelete" jdbcType="CHAR" />
        <result column="role_remark" property="roleRemark" jdbcType="VARCHAR" />
        <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
        <result column="create_user" property="createUser" jdbcType="VARCHAR" />
        <result column="update_time" property="updateTime" jdbcType="TIMESTAMP" />
        <result column="update_user" property="updateUser" jdbcType="VARCHAR" />
    </resultMap>
    <sql id="Base_Column_List">
        id, role_code, role_name, is_delete, role_remark, create_time, create_user, update_time,
        update_user
    <resultMap id="BaseResultMap" type="com.moral.entity.Role" extends="ResultMap">
        <association property="channel" javaType="com.moral.entity.Channel">
            <result column="channel_id" jdbcType="INTEGER" property="id" />
            <result column="channel_name" jdbcType="VARCHAR" property="channelName" />
        </association>
    </resultMap>
    <sql id="Base_Column_List" >
        id, role_code, role_name, channel_id, is_delete, role_remark, create_time, create_user,
        update_time, update_user
    </sql>
    <insert id="insertSelective" parameterType="com.moral.entity.Role">
        insert into role
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="roleCode != null">
                role_code,
            </if>
            <if test="roleName != null">
                role_name,
            </if>
            <if test="isDelete != null">
                is_delete,
            </if>
            <if test="roleRemark != null">
                role_remark,
            </if>
            <if test="createTime != null">
                create_time,
            </if>
            <if test="createUser != null">
                create_user,
            </if>
            <if test="updateTime != null">
                update_time,
            </if>
            <if test="updateUser != null">
                update_user,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=INTEGER},
            </if>
            <if test="roleCode != null">
                #{roleCode,jdbcType=VARCHAR},
            </if>
            <if test="roleName != null">
                #{roleName,jdbcType=VARCHAR},
            </if>
            <if test="isDelete != null">
                #{isDelete,jdbcType=CHAR},
            </if>
            <if test="roleRemark != null">
                #{roleRemark,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null">
                #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createUser != null">
                #{createUser,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUser != null">
                #{updateUser,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.moral.entity.Role">
        update role
        <set>
            <if test="roleName != null">
                role_name=#{roleName,jdbcType=VARCHAR},
            </if>
            <if test="roleCode != null">
                role_code=#{roleCode,jdbcType=VARCHAR},
            </if>
            <if test="roleRemark != null">
                role_remark=#{roleRemark,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null">
                update_time=#{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUser != null">
                update_user=#{updateUser,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
    <sql id="Example_Where_Clause" >
        <where >
            <foreach collection="oredCriteria" item="criteria" separator="or" >
                <if test="criteria.valid" >
                    <trim prefix="(" suffix=")" prefixOverrides="and" >
                        <foreach collection="criteria.criteria" item="criterion" >
                            <choose >
                                <when test="criterion.noValue" >
                                    and ${criterion.condition}
                                </when>
                                <when test="criterion.singleValue" >
                                    and ${criterion.condition} #{criterion.value}
                                </when>
                                <when test="criterion.betweenValue" >
                                    and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                                </when>
                                <when test="criterion.listValue" >
                                    and ${criterion.condition}
                                    <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                                        #{listItem}
                                    </foreach>
                                </when>
                            </choose>
                        </foreach>
                    </trim>
                </if>
            </foreach>
        </where>
    </sql>
    <select id="getRoleList" resultMap="BaseResultMap">
    <select id="getRoleListByName" resultMap="ResultMap">
        select
        <include refid="Base_Column_List"/>
        from role
@@ -112,4 +67,52 @@
        </if>
    </select>
    <select id="getRoleList" resultMap="BaseResultMap">
        select
        r.*,
        c.channel_name
        from role r
        left join channel c on r.channel_id = c.id
        <if test="_parameter != null" >
            <include refid="Example_Where_Clause" />
        </if>
        <if test="orderByClause != null" >
            order by ${orderByClause}
        </if>
    </select>
    <update id="updateByPrimaryKey" parameterType="com.moral.entity.Role" >
        update role
        <set >
            <if test="roleCode != null" >
                role_code = #{roleCode,jdbcType=VARCHAR},
            </if>
            <if test="roleName != null" >
                role_name = #{roleName,jdbcType=VARCHAR},
            </if>
            <if test="channelId != null" >
                channel_id = #{channelId,jdbcType=INTEGER},
            </if>
            <if test="isDelete != null" >
                is_delete = #{isDelete,jdbcType=CHAR},
            </if>
            <if test="roleRemark != null" >
                role_remark = #{roleRemark,jdbcType=VARCHAR},
            </if>
            <if test="createTime != null" >
                create_time = #{createTime,jdbcType=TIMESTAMP},
            </if>
            <if test="createUser != null" >
                create_user = #{createUser,jdbcType=VARCHAR},
            </if>
            <if test="updateTime != null" >
                update_time = #{updateTime,jdbcType=TIMESTAMP},
            </if>
            <if test="updateUser != null" >
                update_user = #{updateUser,jdbcType=VARCHAR},
            </if>
        </set>
        where id = #{id,jdbcType=INTEGER}
    </update>
</mapper>