ZhuDongming
2019-10-09 578e49d67183d8d12a6af7e8244a9d152cb366d4
大屏后台管理代码update
24 files added
9 files modified
1392 ■■■■■ changed files
src/main/java/com/moral/controller/AccountRoleController.java 69 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/MenuController.java 64 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/RoleController.java 49 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/RoleMenuController.java 70 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/Account.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/AccountRole.java 21 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/Menu.java 38 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/Role.java 24 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/entity/RoleMenu.java 21 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/AccountMapper.java 8 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/AccountRoleMapper.java 18 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/MenuMapper.java 23 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/RoleMapper.java 17 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/mapper/RoleMenuMapper.java 18 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/security/auth/login/LoginAuthenticationProvider.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/moral/security/endpoint/RefreshTokenEndpoint.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/moral/service/AccountRoleService.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/AccountService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/MenuService.java 24 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/RoleMenuService.java 15 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/RoleService.java 19 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/AccountRoleServiceImpl.java 76 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/AccountServiceImpl.java 6 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/DeviceServiceImpl.java 70 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/MenuServiceImpl.java 139 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/RoleMenuServiceImpl.java 76 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/service/impl/RoleServiceImpl.java 86 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/util/TkMybatisUtils.java 25 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/AccountMapper.xml 10 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/AccountRoleMapper.xml 80 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/MenuMapper.xml 108 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/RoleMapper.xml 115 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/RoleMenuMapper.xml 80 ●●●●● patch | view | raw | blame | history
src/main/java/com/moral/controller/AccountRoleController.java
New file
@@ -0,0 +1,69 @@
package com.moral.controller;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.AccountRole;
import com.moral.service.AccountRoleService;
import com.moral.service.AccountService;
import com.moral.service.RoleService;
@RestController
@RequestMapping("account-role")
@CrossOrigin(origins = "*", maxAge = 3600)
public class AccountRoleController {
    @Resource
    AccountService accountService;
    @Resource
    RoleService roleService;
    @Resource
    AccountRoleService accountRoleService;
    @GetMapping("account-list")
    public ResultBean getAccountList(String accountName) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        resultBean.setData(accountService.getAccountList(accountName));
        return resultBean;
    }
    @GetMapping("role-list")
    public ResultBean getRoleList(String roleName) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        resultBean.setData(roleService.getRoleList(roleName));
        return resultBean;
    }
    @PostMapping("add-or-modify")
    public ResultBean saveOrUpdate(@RequestBody AccountRole accountRole) {
        accountRoleService.addOrModify(accountRole);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
    @GetMapping("count-by-example")
    public ResultBean<Integer> countByExample(PageBean pageBean) {
        return new ResultBean<Integer>(accountRoleService.countByExample(pageBean));
    }
    @GetMapping("accountRole-list")
    public PageBean getAccountRoleList(PageBean pageBean) {
        return accountRoleService.getAccountRoleList(pageBean);
    }
    @PostMapping("delete-by-ids")
    public ResultBean deleteByIds(@RequestBody Integer [] ids){
        accountRoleService.deleteByIds(ids);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
}
src/main/java/com/moral/controller/MenuController.java
New file
@@ -0,0 +1,64 @@
package com.moral.controller;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.Menu;
import com.moral.service.MenuService;
@RestController
@RequestMapping("menu")
@CrossOrigin(origins = "*", maxAge = 3600)
public class MenuController {
    @Resource
    MenuService menuService;
    @GetMapping("count-by-example")
    public ResultBean<Integer> countByExample(PageBean pageBean) {
        return new ResultBean<Integer>(menuService.countByExample(pageBean));
    }
    @PostMapping("add-or-modify")
    public ResultBean saveOrUpdate(@RequestBody Menu menu) {
        menuService.addOrModify(menu);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
    @GetMapping("page-list")
    public PageBean pageList(PageBean pageBean) {
        return menuService.queryByPageBean(pageBean);
    }
    @GetMapping("page-allList")
    public PageBean pageAllList(PageBean pageBean) {
        return menuService.queryByAllPageBean(pageBean);
    }
    @GetMapping("menu-list")
    public PageBean getMenuList(PageBean pageBean) {
        return menuService.getMenuList(pageBean);
    }
    @GetMapping("menuParent-list")
    public ResultBean getMenuParentList(String menuName) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        resultBean.setData(menuService.getMenuParentList(menuName));
        return resultBean;
    }
    @PostMapping("delete-by-ids")
    public ResultBean deleteByIds(@RequestBody Integer [] ids){
        menuService.deleteByIds(ids);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
}
src/main/java/com/moral/controller/RoleController.java
New file
@@ -0,0 +1,49 @@
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;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.Role;
import com.moral.service.RoleService;
@RestController
@RequestMapping("role")
@CrossOrigin(origins = "*", maxAge = 3600)
public class RoleController {
    @Autowired
    RoleService roleService;
    @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);
    }
    @PostMapping("add-or-modify")
    public ResultBean addOrModify(@RequestBody Role role) {
        roleService.addOrModify(role);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
    @PostMapping("delete-by-ids")
    public ResultBean deleteByIds(@RequestBody List<Integer> ids){
        roleService.deleteByIds(ids);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
}
src/main/java/com/moral/controller/RoleMenuController.java
New file
@@ -0,0 +1,70 @@
package com.moral.controller;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.moral.common.bean.PageBean;
import com.moral.common.bean.ResultBean;
import com.moral.entity.RoleMenu;
import com.moral.service.MenuService;
import com.moral.service.RoleMenuService;
import com.moral.service.RoleService;
@RestController
@RequestMapping("role-menu")
@CrossOrigin(origins = "*", maxAge = 3600)
public class RoleMenuController {
    @Resource
    RoleService roleService;
    @Resource
    MenuService menuService;
    @Resource
    RoleMenuService roleMenuService;
    @GetMapping("role-list")
    public ResultBean getRoleList(String roleName) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        resultBean.setData(roleService.getRoleList(roleName));
        return resultBean;
    }
    @GetMapping("menu-list")
    public ResultBean getMenuList(String menuName) {
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        resultBean.setData(menuService.getMenuListByName(menuName));
        return resultBean;
    }
    @PostMapping("add-or-modify")
    public ResultBean saveOrUpdate(@RequestBody RoleMenu roleMenu) {
        roleMenuService.addOrModify(roleMenu);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
    @GetMapping("count-by-example")
    public ResultBean<Integer> countByExample(PageBean pageBean) {
        return new ResultBean<Integer>(roleMenuService.countByExample(pageBean));
    }
    @GetMapping("roleMenu-list")
    public PageBean getRoleMenuList(PageBean pageBean) {
        return roleMenuService.getRoleMenuList(pageBean);
    }
    @PostMapping("delete-by-ids")
    public ResultBean deleteByIds(@RequestBody Integer [] ids){
        roleMenuService.deleteByIds(ids);
        ResultBean resultBean = new ResultBean(ResultBean.SUCCESS);
        return resultBean;
    }
}
src/main/java/com/moral/entity/Account.java
@@ -80,7 +80,7 @@
    // TODO 临时角色
    public List<Role> getRoles(){
        Role role = new Role();
        role.setName("temp");
        role.setRoleName("temp");
        return Arrays.asList(role);
    }
    @Transient
src/main/java/com/moral/entity/AccountRole.java
New file
@@ -0,0 +1,21 @@
package com.moral.entity;
import javax.persistence.Transient;
import lombok.Data;
@Data
public class AccountRole {
    private Integer id;
    private Integer accountId;
    private Integer roleId;
    @Transient
    private Account account;
    @Transient
    private Role role;
}
src/main/java/com/moral/entity/Menu.java
New file
@@ -0,0 +1,38 @@
package com.moral.entity;
import java.util.Date;
import javax.persistence.Id;
import lombok.Data;
@Data
public class Menu {
    @Id
    private Integer id;
    private String menuCode;
    private String menuName;
    private String menuIcon;
    private String menuUrl;
    private Integer menuOrder;
    private Integer menuParentId;
    private String menuRemark;
    private String isDelete;
    private Date createTime;
    private String createUser;
    private Date updateTime;
    private String updateUser;
}
src/main/java/com/moral/entity/Role.java
@@ -1,8 +1,30 @@
package com.moral.entity;
import java.util.Date;
import javax.persistence.Id;
import lombok.Data;
@Data
public class Role {
   private String name;
    @Id
    private Integer id;
    private String roleCode;
    private String roleName;
    private String isDelete;
    private String roleRemark;
    private Date createTime;
    private String createUser;
    private Date updateTime;
    private String updateUser;
}
src/main/java/com/moral/entity/RoleMenu.java
New file
@@ -0,0 +1,21 @@
package com.moral.entity;
import javax.persistence.Transient;
import lombok.Data;
@Data
public class RoleMenu {
    private Integer id;
    private Integer roleId;
    private Integer menuId;
    @Transient
    private Role role;
    @Transient
    private Menu menu;
}
src/main/java/com/moral/mapper/AccountMapper.java
@@ -3,11 +3,19 @@
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Param;
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.Account;
public interface AccountMapper extends BaseMapper<Account> {
    List<Map<String, Object>> getRoleNameByAccountId(Integer accountId);
    Account getByAccountName(String name);
    Map<String, Object> getOrganizationIdByAccountId(Integer accountId);
    List<Account> getAccountList(@Param("accountName") String accountName);
}
src/main/java/com/moral/mapper/AccountRoleMapper.java
New file
@@ -0,0 +1,18 @@
package com.moral.mapper;
import java.util.List;
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.AccountRole;
import tk.mybatis.mapper.entity.Example;
public interface AccountRoleMapper extends BaseMapper<AccountRole> {
    List<AccountRole> getAccountRoleList(Example example);
    int updateByPrimaryKey(AccountRole accountRole);
    int deleteByPrimaryKeyOwn(Integer id);
}
src/main/java/com/moral/mapper/MenuMapper.java
New file
@@ -0,0 +1,23 @@
package com.moral.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.Menu;
import tk.mybatis.mapper.entity.Example;
public interface MenuMapper extends BaseMapper<Menu> {
    List<Menu> selectWithMenuNameByExample(Example example);
    List<Menu> getMenuList(Example example);
    List<Menu> getParentMenuList(@Param("menuName") String menuName);
    List<Menu> getMenuListByName(@Param("menuName") String menuName);
}
src/main/java/com/moral/mapper/RoleMapper.java
New file
@@ -0,0 +1,17 @@
package com.moral.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.Role;
public interface RoleMapper extends BaseMapper<Role> {
    int insertSelective(Role role);
    int updateByPrimaryKeySelective(Role role);
    List<Role> getRoleList(@Param("roleName") String roleName);
}
src/main/java/com/moral/mapper/RoleMenuMapper.java
New file
@@ -0,0 +1,18 @@
package com.moral.mapper;
import java.util.List;
import com.moral.common.mapper.BaseMapper;
import com.moral.entity.RoleMenu;
import tk.mybatis.mapper.entity.Example;
public interface RoleMenuMapper extends BaseMapper<RoleMenu> {
    List<RoleMenu> getRoleMenuList(Example example);
    int deleteByPrimaryKeyOwn(Integer id);
    int updateByPrimaryKey(RoleMenu roleMenu);
}
src/main/java/com/moral/security/auth/login/LoginAuthenticationProvider.java
@@ -70,7 +70,7 @@
            throw new InsufficientAuthenticationException("User has no roles assigned");
        }
        List<GrantedAuthority> authorities = account.getRoles().stream()
                .map(authority -> new SimpleGrantedAuthority(authority.getName()))
                .map(authority -> new SimpleGrantedAuthority(authority.getRoleName()))
                .collect(Collectors.toList());
        UserContext userContext = UserContext.create(account.getAccountName(),mode,account.getOrganizationId(),authorities);
src/main/java/com/moral/security/endpoint/RefreshTokenEndpoint.java
@@ -72,7 +72,7 @@
        if (account.getRoles() == null) throw new InsufficientAuthenticationException("User has no roles assigned");
        List<GrantedAuthority> authorities = account.getRoles().stream()
                .map(authority -> new SimpleGrantedAuthority(authority.getName()))
                .map(authority -> new SimpleGrantedAuthority(authority.getRoleName()))
                .collect(Collectors.toList());
        UserContext userContext = UserContext.create(account.getAccountName(),mode,account.getOrganizationId(),authorities);
src/main/java/com/moral/service/AccountRoleService.java
New file
@@ -0,0 +1,15 @@
package com.moral.service;
import com.moral.common.bean.PageBean;
import com.moral.entity.AccountRole;
public interface AccountRoleService {
    void addOrModify(AccountRole accountRole);
    int countByExample(PageBean pageBean);
    PageBean getAccountRoleList(PageBean pageBean);
    void deleteByIds(Integer... ids);
}
src/main/java/com/moral/service/AccountService.java
@@ -30,4 +30,6 @@
    Account companyLogin(Map<String, Object> parameters);
    
    Map<String, Object> getOrganizationIdByAccountId(String id);
    List<Account> getAccountList(String accountName);
}
src/main/java/com/moral/service/MenuService.java
New file
@@ -0,0 +1,24 @@
package com.moral.service;
import java.util.List;
import com.moral.common.bean.PageBean;
import com.moral.entity.Menu;
public interface MenuService {
    void addOrModify(Menu menu);
    PageBean queryByPageBean(PageBean pageBean);
    PageBean queryByAllPageBean(PageBean pageBean);
    int countByExample(PageBean pageBean);
    PageBean getMenuList(PageBean pageBean);
    List<Menu> getMenuParentList(String menuName);
    void deleteByIds(Integer[] ids);
    List<Menu> getMenuListByName(String menuName);
}
src/main/java/com/moral/service/RoleMenuService.java
New file
@@ -0,0 +1,15 @@
package com.moral.service;
import com.moral.common.bean.PageBean;
import com.moral.entity.RoleMenu;
public interface RoleMenuService {
    void addOrModify(RoleMenu roleMenu);
    int countByExample(PageBean pageBean);
    PageBean getRoleMenuList(PageBean pageBean);
    void deleteByIds(Integer... ids);
}
src/main/java/com/moral/service/RoleService.java
New file
@@ -0,0 +1,19 @@
package com.moral.service;
import java.util.List;
import com.moral.common.bean.PageBean;
import com.moral.entity.Role;
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);
}
src/main/java/com/moral/service/impl/AccountRoleServiceImpl.java
New file
@@ -0,0 +1,76 @@
package com.moral.service.impl;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.moral.common.bean.PageBean;
import com.moral.common.util.ExampleUtil;
import com.moral.entity.AccountRole;
import com.moral.mapper.AccountRoleMapper;
import com.moral.service.AccountRoleService;
import tk.mybatis.mapper.entity.Example;
@Service
public class AccountRoleServiceImpl implements AccountRoleService {
    private static Class ENTITY_CLASS = AccountRole.class;
    @Resource
    private AccountRoleMapper accountRoleMapper;
    @Override
    public void addOrModify(AccountRole accountRole) {
        try {
            if (accountRole.getId() != null) {
                accountRoleMapper.updateByPrimaryKey(accountRole);
            } else {
                AccountRole accountRoleQuery = new AccountRole();
                accountRoleQuery.setAccountId(accountRole.getAccountId());
                accountRoleQuery.setRoleId(accountRole.getRoleId());
                AccountRole accountRoleResult = accountRoleMapper.selectOne(accountRoleQuery);
                if (accountRoleResult == null) {
                    accountRoleMapper.insertSelective(accountRole);
                }
            }
        } catch (Exception ex) {
            throw ex;
        }
    }
    @Override
    public int countByExample(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
        return accountRoleMapper.selectCountByExample(example);
    }
    @Override
    public PageBean getAccountRoleList(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
        if (pageBean.getPageSize() > 0) {
            PageHelper.startPage(pageBean.getPageIndex(), pageBean.getPageSize());
        }
        List<AccountRole> accountRoleList = accountRoleMapper.getAccountRoleList(example);
        return new PageBean(accountRoleList);
    }
    @Override
    public void deleteByIds(Integer... ids) {
        if (ids != null && ids.length > 0) {
            if (ids.length == 1) {
                accountRoleMapper.deleteByPrimaryKeyOwn(ids[0]);
            } else {
                Example example = new Example(ENTITY_CLASS);
                example.or().andIn("id", Arrays.asList(ids));
                accountRoleMapper.deleteByExample(example);
            }
        }
    }
}
src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -206,4 +206,10 @@
        Map<String, Object> map = accountMapper.getOrganizationIdByAccountId(accountId);
        return map;
    }
    @Override
    public List<Account> getAccountList(String accountName) {
        List<Account> accountList = accountMapper.getAccountList(accountName);
        return accountList;
    }
}
src/main/java/com/moral/service/impl/DeviceServiceImpl.java
@@ -20,6 +20,8 @@
import com.moral.mapper.OrganizationMapper;
import com.moral.service.AccountService;
import com.moral.service.DeviceService;
import com.moral.util.TkMybatisUtils;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
@@ -27,10 +29,12 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import tk.mybatis.mapper.entity.Example;
import javax.annotation.Resource;
import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
@@ -48,6 +52,7 @@
    private static String DEVICE = "device";//设备信息数据key前缀
    private static String STATE = "state";//设备实时状态key前缀
    private static String DATA = "data";//设备实时数据key前缀
    //-----------------------redis key前缀-结束---------------------------------
    private String keysConnect(String... keys) {
        StringBuilder key = new StringBuilder(keys[0]);
@@ -57,6 +62,7 @@
        }
        return key.toString().toLowerCase();
    }
    @Resource
    private DeviceMapper deviceMapper;
    @Resource
@@ -74,6 +80,7 @@
    OrganizationMapper organizationMapper;
    @Resource
    DictionaryDataMapper dictionaryDataMapper;
    @Override
    public Map<String, Object> getDeviceStatesByAccount(Map<String, Object> parameters) {
        ValidateUtil.notNull(parameters.get("accountId"), "param.is.null");
@@ -136,7 +143,6 @@
    }
    /**
     *
     * @param mac
     * @param fromCache
     * @return 包含组织数组
@@ -157,6 +163,7 @@
    /**
     * 默认会从缓存取
     *
     * @param mac
     * @return
     */
@@ -165,12 +172,14 @@
        return getDeviceByMac(mac,true);
    }
    /*
     * 获取报警阀值在redis里的key
     */
    private String getDeviceKey(String mac) {
        return keysConnect(DEVICE,mac);
    }
//    /*
//     * 将校正值存入redis方法组 开始
//     */
@@ -193,9 +202,7 @@
    }
    /**
     *
     * @param params
     * map里 包括 组织id和4个坐标点
     * @param params map里 包括 组织id和4个坐标点
     * @return 返回未删除结果集
     */
    @Override
@@ -211,8 +218,10 @@
        }
        return deviceList;
    }
    /**
     *  根据组织id和设备名称 分页查询设备
     *
     * @param orgId
     * @param deviceName
     * @param pageSize
@@ -229,19 +238,24 @@
        switch (deviceName){
            case "正常":
                state = "0";
                deviceName = null;break;
                deviceName = null;
                break;
                case "轻度":
                state = "1";
                deviceName = null;break;
                deviceName = null;
                break;
            case "中度":
                state = "2";
                deviceName = null;break;
                deviceName = null;
                break;
            case "重度":
                state = "3";
                deviceName = null;break;
                deviceName = null;
                break;
            case "维保":
                state = "4";
                deviceName = null;break;
                deviceName = null;
                break;
        }
        List<Device> list = deviceMapper.selectByOrgIdAndDevName(orgId,orgIds,state,deviceName);
        //从redis里取状态
@@ -254,6 +268,7 @@
    /**
     * 根据组织id和监控点id 分页查询设备
     *
     * @param orgId
     * @param mpId
     * @param pageSize
@@ -274,6 +289,7 @@
        }
        return new PageResult(null,list);
    }
    private void loadDeviceState(List<Device> list){
        //从redis里取状态
        list.stream().map( device -> {
@@ -287,6 +303,7 @@
            return device;
        }).count();
    }
    private String getSateFromRedis(Integer mpId,String mac){
        Map<String,String> stateMap  = getStateMapFromRedis(mpId,mac);
@@ -297,12 +314,15 @@
        state = state == null ?Constants.DEVICE_STATE_OFFLINE:state;
        return  state;
    }
    public Map<String,String> getStateMapFromRedis(Integer mpId,String mac){
        StringBuilder key = new StringBuilder();
        //拼凑key
        key.append("state_").append(mpId).append("_").append(mac);
        return   redisUtils.get(key.toString(),new TypeReference<Map<String,String>>(){});
        return redisUtils.get(key.toString(), new TypeReference<Map<String, String>>() {
        });
    }
    private Device getDeviceWithOrgIdsByMac(String mac) {
        String key = "device_"+mac;
        Device device = redisUtils.get(key,Device.class);
@@ -318,38 +338,25 @@
    /**
     * 要在数据库更改后刷新
     * 刷新 redis 设备的信息,注意此处指删除不做更新。更新由task完成
     *
     * @param mac
     */
    private void refreshDeviceInRedis(String mac){
         if(!StringUtils.isBlank(mac)){
              String key = getDeviceKey(mac);
              redisUtils.remove(key);
         }else
         {
        } else {
             log.warn("param mac is null in method [refreshDeviceInRedis]");
         }
    }
    @Override
    public int countByExample(PageBean pageBean){
        Example example = ExampleUtil.generateExample(ENTITY_CLASS,pageBean);
        addDeletesToExample(example);
        TkMybatisUtils.addDeletesToExample(example);
        return deviceMapper.selectCountByExample(example);
    }
    /**
     * 增加删除条件过滤
     * @param example
     */
    private void addDeletesToExample(Example example){
        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);
        }
    }
    @Override
    public PageBean     queryByPageBean(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS,pageBean);
@@ -416,11 +423,11 @@
            }
            //刷新redis里设备信息
            refreshDeviceInRedis(device.getMac());
        }
        catch (Exception ex){
        } catch (Exception ex) {
            throw  ex;
        }
    }
    @Override
    public List<Map> countByTimes(Date start,Date end,String format){
        if(start==null||end==null||StringUtils.isBlank(format)){
@@ -445,6 +452,7 @@
    /**
     *  返回map{mac:,state:}
     *
     * @param macList
     * @return
     */
@@ -465,7 +473,8 @@
                //添加data
                if(BooleanUtils.isTrue(withData)){
                    String dataKey = "data_"+mac;
                    Map<String,String> dataMap = redisUtils.get(dataKey,new TypeReference<Map<String,String>>(){});
                    Map<String, String> dataMap = redisUtils.get(dataKey, new TypeReference<Map<String, String>>() {
                    });
                    if(!MapUtils.isEmpty(dataMap)){
                        resultMap.putAll(dataMap);
                    }
@@ -492,6 +501,7 @@
        ValidateUtil.notNull(parameters.get("organizationId"), "param.is.null");
        return deviceMapper.getDevicesByOrganizationId(parameters);
    }
    @Override
    public Map<String,Long> queryDeviceStateSummary(@NotNull Integer orgId){
        Map<String,Object> params = new HashMap<>();
src/main/java/com/moral/service/impl/MenuServiceImpl.java
New file
@@ -0,0 +1,139 @@
package com.moral.service.impl;
import java.util.Arrays;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
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.entity.Menu;
import com.moral.mapper.MenuMapper;
import com.moral.service.MenuService;
import com.moral.util.TkMybatisUtils;
import tk.mybatis.mapper.entity.Example;
@Service
public class MenuServiceImpl implements MenuService {
    private static Class ENTITY_CLASS = Menu.class;
    @Resource
    private MenuMapper menuMapper;
    @Override
    public void addOrModify(Menu menu) {
        try {
            menu.setUpdateTime(new Date());
            menu.setUpdateUser(menu.getUpdateUser());
            if (menu.getId() != null) {
                menuMapper.updateByPrimaryKeySelective(menu);
            } else {
                Menu menuQuery = new Menu();
                menuQuery.setMenuCode(menu.getMenuCode());
                menuQuery.setIsDelete(Constants.IS_DELETE_FALSE);
                Menu menuResult = menuMapper.selectOne(menuQuery);
                if (menuResult != null) {
                    menu.setId(menuResult.getId());
                    menuMapper.updateByPrimaryKeySelective(menu);
                } else {
                    menu.setIsDelete(Constants.IS_DELETE_FALSE);
                    menu.setCreateTime(new Date());
                    menu.setCreateUser(menu.getCreateUser());
                    menuMapper.insertSelective(menu);
                }
            }
        } 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
    public PageBean queryByAllPageBean(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();
        return new PageBean(menuList);
    }
    @Override
    public int countByExample(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
        TkMybatisUtils.addDeletesToExample(example);
        return menuMapper.selectCountByExample(example);
    }
    @Override
    public PageBean getMenuList(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
        if (pageBean.getPageSize() > 0) {
            PageHelper.startPage(pageBean.getPageIndex(), pageBean.getPageSize());
        }
        List<Menu> menuList = menuMapper.getMenuList(example);
        return new PageBean(menuList);
    }
    @Override
    public List<Menu> getMenuParentList(String menuName) {
        List<Menu> menuParentList = menuMapper.getParentMenuList(menuName);
        return menuParentList;
    }
    @Override
    public void deleteByIds(Integer[] ids) {
        Menu menu = new Menu();
        menu.setIsDelete(Constants.IS_DELETE_TRUE);
        Example example = new Example(ENTITY_CLASS);
        example.or().andIn("id", Arrays.asList(ids));
        menuMapper.updateByExampleSelective(menu, example);
    }
    @Override
    public List<Menu> getMenuListByName(String menuName) {
        List<Menu> menuList = menuMapper.getMenuListByName(menuName);
        return menuList;
    }
}
src/main/java/com/moral/service/impl/RoleMenuServiceImpl.java
New file
@@ -0,0 +1,76 @@
package com.moral.service.impl;
import java.util.Arrays;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.moral.common.bean.PageBean;
import com.moral.common.util.ExampleUtil;
import com.moral.entity.RoleMenu;
import com.moral.mapper.RoleMenuMapper;
import com.moral.service.RoleMenuService;
import tk.mybatis.mapper.entity.Example;
@Service
public class RoleMenuServiceImpl implements RoleMenuService {
    private static Class ENTITY_CLASS = RoleMenu.class;
    @Resource
    private RoleMenuMapper roleMenuMapper;
    @Override
    public void addOrModify(RoleMenu roleMenu) {
        try {
            if (roleMenu.getId() != null) {
                roleMenuMapper.updateByPrimaryKey(roleMenu);
            } else {
                RoleMenu roleMenuQuery = new RoleMenu();
                roleMenuQuery.setRoleId(roleMenu.getRoleId());
                roleMenuQuery.setMenuId(roleMenu.getMenuId());
                RoleMenu roleMenuResult = roleMenuMapper.selectOne(roleMenuQuery);
                if (roleMenuResult == null) {
                    roleMenuMapper.insertSelective(roleMenu);
                }
            }
        } catch (Exception ex) {
            throw ex;
        }
    }
    @Override
    public int countByExample(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
        return roleMenuMapper.selectCountByExample(example);
    }
    @Override
    public PageBean getRoleMenuList(PageBean pageBean) {
        Example example = ExampleUtil.generateExample(ENTITY_CLASS, pageBean);
        if (pageBean.getPageSize() > 0) {
            PageHelper.startPage(pageBean.getPageIndex(), pageBean.getPageSize());
        }
        List<RoleMenu> roleMenuList = roleMenuMapper.getRoleMenuList(example);
        return new PageBean(roleMenuList);
    }
    @Override
    public void deleteByIds(Integer... ids) {
        if (ids != null && ids.length > 0) {
            if (ids.length == 1) {
                roleMenuMapper.deleteByPrimaryKeyOwn(ids[0]);
            } else {
                Example example = new Example(ENTITY_CLASS);
                example.or().andIn("id", Arrays.asList(ids));
                roleMenuMapper.deleteByExample(example);
            }
        }
    }
}
src/main/java/com/moral/service/impl/RoleServiceImpl.java
New file
@@ -0,0 +1,86 @@
package com.moral.service.impl;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
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;
import com.moral.util.TkMybatisUtils;
import tk.mybatis.mapper.entity.Example;
@Service
public class RoleServiceImpl implements RoleService {
    private static Class ENTITY_CLASS = Role.class;
    @Resource
    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);
            } 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 {
                    role.setIsDelete(Constants.IS_DELETE_FALSE);
                    role.setCreateTime(new Date());
                    role.setCreateUser(role.getCreateUser());
                    roleMapper.insertSelective(role);
                }
            }
        } catch (Exception ex) {
            throw ex;
        }
    }
    @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);
        return roleMapper.selectCountByExample(example);
    }
    @Override
    public List<Role> getRoleList(String roleName) {
        List<Role> roleList = roleMapper.getRoleList(roleName);
        return roleList;
    }
}
src/main/java/com/moral/util/TkMybatisUtils.java
New file
@@ -0,0 +1,25 @@
package com.moral.util;
import java.util.List;
import com.moral.common.bean.Constants;
import tk.mybatis.mapper.entity.Example;
public class TkMybatisUtils {
    /**
     * 增加删除条件过滤
     * @param example
     */
    public static void addDeletesToExample(Example example){
        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);
        }
    }
}
src/main/resources/mapper/AccountMapper.xml
@@ -45,4 +45,14 @@
        FROM account
        WHERE id=#{id}
    </select>
    <select id="getAccountList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from account
        where is_delete=0 and expire_time > now()
        <if test="accountName != 'null'">
            and account_name like concat('%',#{accountName},'%')
        </if>
    </select>
</mapper>
src/main/resources/mapper/AccountRoleMapper.xml
New file
@@ -0,0 +1,80 @@
<?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.AccountRoleMapper">
    <resultMap id="ResultMap" type="com.moral.entity.AccountRole" >
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="account_id" property="accountId" jdbcType="INTEGER" />
        <result column="role_id" property="roleId" jdbcType="INTEGER" />
    </resultMap>
    <resultMap id="BaseResultMap" type="com.moral.entity.AccountRole" extends="ResultMap">
        <association property="account" javaType="com.moral.entity.Account">
            <result column="account_id" jdbcType="INTEGER" property="id" />
            <result column="account_name" jdbcType="VARCHAR" property="accountName" />
        </association>
        <association property="role" javaType="com.moral.entity.Role">
            <result column="role_id" property="id" jdbcType="INTEGER" />
            <result column="role_name" property="roleName" jdbcType="VARCHAR" />
        </association>
    </resultMap>
    <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="getAccountRoleList" resultMap="BaseResultMap">
        select
        ar.*,
        a.account_name,
        r.role_name
        from account_role ar
        left join account a on ar.account_id = a.id
        left join role r on ar.role_id = r.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.AccountRole" >
        update account_role
        set account_id = #{accountId,jdbcType=INTEGER},
        role_id = #{roleId,jdbcType=INTEGER}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <delete id="deleteByPrimaryKeyOwn" parameterType="java.lang.Integer" >
        delete from account_role
        where id = #{id,jdbcType=INTEGER}
    </delete>
</mapper>
src/main/resources/mapper/MenuMapper.xml
New file
@@ -0,0 +1,108 @@
<?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">
        <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="menu_icon" property="menuIcon" jdbcType="VARCHAR"/>
        <result column="menu_url" property="menuUrl" jdbcType="VARCHAR"/>
        <result column="menu_order" property="menuOrder" jdbcType="INTEGER"/>
        <result column="menu_parent_id" property="menuParentId" jdbcType="INTEGER"/>
        <result column="menu_remark" property="menuRemark" jdbcType="VARCHAR"/>
        <result column="is_delete" property="isDelete" 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"/>
    </resultMap>
    <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="selectWithMenuNameByExample" parameterType="tk.mybatis.mapper.entity.Example" resultMap="BaseResultMap">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from menu
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>
    <select id="getMenuList" resultMap="BaseResultMap" parameterType="tk.mybatis.mapper.entity.Example">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from menu
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
        <if test="orderByClause != null">
            order by ${orderByClause}
        </if>
    </select>
    <sql id="Base_Column_List">
        id, menu_code, menu_name, 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
        distinct
        <include refid="Base_Column_List"/>
        from menu
        where id IN
        (select distinct(menu_parent_Id) from menu
        where menu_parent_Id is not null)
        <if test="menuName != 'null'">
            and menu_name like concat('%',#{menuName},'%')
        </if>
    </select>
    <select id="getMenuListByName" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from menu
        where is_delete=0
        <if test="menuName != 'null'">
            and menu_name like concat('%',#{menuName},'%')
        </if>
    </select>
</mapper>
src/main/resources/mapper/RoleMapper.xml
New file
@@ -0,0 +1,115 @@
<?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.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>
    <sql id="Base_Column_List">
        id, role_code, role_name, 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>
    <select id="getRoleList" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List"/>
        from role
        where is_delete=0
        <if test="roleName != 'null'">
            and role_name like concat('%',#{roleName},'%')
        </if>
    </select>
</mapper>
src/main/resources/mapper/RoleMenuMapper.xml
New file
@@ -0,0 +1,80 @@
<?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.RoleMenuMapper">
    <resultMap id="ResultMap" type="com.moral.entity.RoleMenu" >
        <id column="id" property="id" jdbcType="INTEGER" />
        <result column="role_id" property="roleId" jdbcType="INTEGER" />
        <result column="menu_id" property="menuId" jdbcType="INTEGER" />
    </resultMap>
    <resultMap id="BaseResultMap" type="com.moral.entity.RoleMenu" extends="ResultMap">
        <association property="role" javaType="com.moral.entity.Role">
            <result column="role_id" property="id" jdbcType="INTEGER" />
            <result column="role_name" property="roleName" jdbcType="VARCHAR" />
        </association>
        <association property="menu" javaType="com.moral.entity.Menu">
            <result column="menu_id" property="id" jdbcType="INTEGER"/>
            <result column="menu_name" property="menuName" jdbcType="VARCHAR"/>
        </association>
    </resultMap>
    <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="getRoleMenuList" resultMap="BaseResultMap">
        select
        rm.*,
        r.role_name,
        m.menu_name
        from role_menu rm
        left join role r on rm.role_id = r.id
        left join menu m on rm.menu_id = m.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.RoleMenu" >
        update role_menu
        set role_id = #{roleId,jdbcType=INTEGER},
        menu_id = #{menuId,jdbcType=INTEGER}
        where id = #{id,jdbcType=INTEGER}
    </update>
    <delete id="deleteByPrimaryKeyOwn" parameterType="java.lang.Integer" >
        delete from role_menu
        where id = #{id,jdbcType=INTEGER}
    </delete>
</mapper>