Merge branch 'master' of http://git.estsh.com/i3-IMPP/i3plus-core
commit
cfbe830662
@ -0,0 +1,197 @@
|
||||
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
||||
|
||||
import cn.estsh.i3plus.core.api.iservice.busi.ISysRoleService;
|
||||
import cn.estsh.i3plus.platform.common.convert.ConvertBean;
|
||||
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
|
||||
import cn.estsh.i3plus.pojo.platform.bean.RefRoleMenu;
|
||||
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
|
||||
import cn.estsh.i3plus.pojo.platform.bean.SysMenu;
|
||||
import cn.estsh.i3plus.pojo.platform.bean.SysRole;
|
||||
import cn.estsh.i3plus.pojo.platform.repository.RefRoleMenuRepository;
|
||||
import cn.estsh.i3plus.pojo.platform.repository.SysMenuRepository;
|
||||
import cn.estsh.i3plus.pojo.platform.repository.SysRoleRepository;
|
||||
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
|
||||
import cn.estsh.impp.framework.boot.auth.AuthUtil;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 系统角色业务接口实现
|
||||
* @Reference :
|
||||
* @Author : wei.peng
|
||||
* @Date : 2018-10-22 16:58:43.779
|
||||
* @Modify :
|
||||
**/
|
||||
@Service
|
||||
public class SysRoleService implements ISysRoleService {
|
||||
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(SysRoleService.class);
|
||||
|
||||
@Autowired
|
||||
private SysRoleRepository sysRoleRDao;
|
||||
|
||||
@Autowired
|
||||
private SysMenuRepository sysMenuRDao;
|
||||
|
||||
@Autowired
|
||||
private RefRoleMenuRepository refRoleMenuRDao;
|
||||
|
||||
@Override
|
||||
public void updateSysRole(SysRole sysRole) {
|
||||
LOGGER.info("系统角色 SYS_ROLE :{}", sysRole);
|
||||
sysRoleRDao.update(sysRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysRoleStatus(String id, int status, SessionUser user) {
|
||||
LOGGER.info("系统角色 SYS_MENU id:{} status:{} user:{}", id,status,user);
|
||||
SysRole role = sysRoleRDao.getById(Long.parseLong(id));
|
||||
role.setRoleStatusId(status);
|
||||
role.setModifyUser(user.getUserName());
|
||||
sysRoleRDao.update(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysRoleStatusByIds(String[] ids, int status, SessionUser user) {
|
||||
LOGGER.info("系统功能 SYS_MENU ids:{} status:{} user:{}", ids, status, user);
|
||||
StringBuffer where = new StringBuffer();
|
||||
|
||||
HqlPack.getInPack(String.join(",", ids), "id", where);
|
||||
sysRoleRDao.updateByHqlWhere(where.toString(), "roleStatusId", status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSysRoleById(String id) {
|
||||
LOGGER.info("系统角色 SYS_ROLE Key:{}", id);
|
||||
sysRoleRDao.deleteById(Long.parseLong(id));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SysRole insertSysRole(SysRole sysRole) {
|
||||
LOGGER.info("系统角色 SYS_ROLE :{}", sysRole);
|
||||
return sysRoleRDao.insert(sysRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshSysRoleRef(String roleId,String[] ids,SessionUser user) {
|
||||
LOGGER.info("系统角色 SYS_ROLE :{}", roleId);
|
||||
LOGGER.info("系统角色 List<SysMenu> :{}", ids);
|
||||
|
||||
refreshBatchSysRoleRef(new String[]{roleId}, ids, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshBatchSysRoleRef(String[] roleIds, String[] ids,SessionUser user) {
|
||||
LOGGER.info("系统角色 String[] :{}", roleIds);
|
||||
LOGGER.info("系统角色 List<SysMenu> :{}", ids);
|
||||
|
||||
String roleWhere = CoreHqlPack.packHqlIds("id", roleIds);
|
||||
List<SysRole> roleList = sysRoleRDao.findByHqlWhere(roleWhere);
|
||||
|
||||
if(roleList != null && roleList.size() > 0){
|
||||
List<String> moduleListRdd = new ArrayList<>();
|
||||
List<String> featuresListRdd = new ArrayList<>(); // 冗余
|
||||
List<RefRoleMenu> refs = new ArrayList<>(); // 角色权限关系
|
||||
|
||||
// 封装需要删除的IDS
|
||||
Long[] rids = new Long[roleList.size()];
|
||||
for (int i = 0; i < roleList.size(); i++) {
|
||||
rids[i] = roleList.get(i).getId();
|
||||
}
|
||||
// 删除角色权限关系
|
||||
String deleteWhere = CoreHqlPack.packHqlIds("roleId", roleIds);
|
||||
List<RefRoleMenu> refRoleMenuList = refRoleMenuRDao.findByHqlWhere(deleteWhere);
|
||||
refRoleMenuRDao.deleteAll(refRoleMenuList);
|
||||
|
||||
if(ids != null && ids.length > 0){
|
||||
String menuWhere = CoreHqlPack.packHqlIds("id", ids);
|
||||
List<SysMenu> list = sysMenuRDao.findByHqlWhere(menuWhere);
|
||||
|
||||
// 插入角色权限关系
|
||||
if(list != null && list.size() > 0){
|
||||
for (SysMenu menu : list) {
|
||||
for (SysRole role : roleList) {
|
||||
RefRoleMenu ref = new RefRoleMenu(menu.getId(), menu.getName(), role.getId(), role.getName());
|
||||
ConvertBean.modelInitialize(ref, user);
|
||||
refs.add(ref);
|
||||
}
|
||||
|
||||
// 冗余信息封装
|
||||
if(CommonEnumUtil.METHOD_LEVEL.MODULE.getValue() == menu.getMenuTypeId().intValue()){
|
||||
moduleListRdd.add(menu.getName());
|
||||
}
|
||||
if(CommonEnumUtil.METHOD_LEVEL.BUTTON.getValue() == menu.getMenuTypeId().intValue()){
|
||||
featuresListRdd.add(menu.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 冗余信息
|
||||
for (SysRole role : roleList) {
|
||||
role.setRedModuleNumber(moduleListRdd.size());
|
||||
role.setRedModuleNames(String.join(",",moduleListRdd));
|
||||
|
||||
role.setRedMenuNumber(featuresListRdd.size());
|
||||
role.setRedMenuNames(String.join(",",featuresListRdd));
|
||||
}
|
||||
|
||||
refRoleMenuRDao.saveAll(refs);
|
||||
sysRoleRDao.saveAll(roleList);
|
||||
}else {
|
||||
throw ImppExceptionBuilder.newInstance()
|
||||
.setSystemID(CommonEnumUtil.SOFT_TYPE.CORE.getCode())
|
||||
.setErrorCode(ImppExceptionEnum.VARIFY_EXCEPTION_DATA_NOT_EXIT.getCode())
|
||||
.setErrorDetail("角色信息不存在")
|
||||
.setErrorSolution("请重新输入")
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RefRoleMenu> findRefRoleMenuByRoleId(String roleId) {
|
||||
LOGGER.info("系统角色权限关系 RefRoleMenu find By RoleId");
|
||||
return refRoleMenuRDao.findByProperty("roleId",Long.parseLong(roleId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRole> findSysRoleAll() {
|
||||
LOGGER.info("系统角色 SYS_ROLE find All");
|
||||
return sysRoleRDao.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysRole getSysRoleById(String id) {
|
||||
LOGGER.info("系统角色 SYS_ROLE find id:{}", id);
|
||||
return sysRoleRDao.getOne(Long.parseLong(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListPager<SysRole> querySysRole(SysRole role, Pager pager) {
|
||||
LOGGER.info("系统角色 SysRole find role :{} page :{}", role, pager);
|
||||
|
||||
if (role == null) {
|
||||
//不传入实体对象,查询所有
|
||||
int count = sysRoleRDao.listCount();
|
||||
pager = PagerHelper.getPager(pager, count);
|
||||
return new ListPager(sysRoleRDao.listPager(pager), pager);
|
||||
} else {
|
||||
//生成hql查询语句
|
||||
String hqlPack = CoreHqlPack.packHqlSysRole(role);
|
||||
pager = PagerHelper.getPager(pager, sysRoleRDao.findByHqlWhereCount(hqlPack));
|
||||
return new ListPager(sysRoleRDao.findByHqlWherePage(hqlPack + role.orderBy(), pager), pager);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
||||
|
||||
import cn.estsh.i3plus.core.api.iservice.busi.ISysRoleService;
|
||||
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||
import cn.estsh.i3plus.pojo.base.common.PagerHelper;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.base.tool.HqlPack;
|
||||
import cn.estsh.i3plus.pojo.platform.bean.SessionUser;
|
||||
import cn.estsh.i3plus.pojo.platform.bean.SysRole;
|
||||
import cn.estsh.i3plus.pojo.platform.repository.SysRoleRepository;
|
||||
import cn.estsh.i3plus.pojo.platform.sqlpack.CoreHqlPack;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppExceptionBuilder;
|
||||
import cn.estsh.impp.framework.boot.exception.ImppExceptionEnum;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 系统角色业务接口实现
|
||||
* @Reference :
|
||||
* @Author : wei.peng
|
||||
* @Date : 2018-10-22 16:58:43.779
|
||||
* @Modify :
|
||||
**/
|
||||
@Service
|
||||
public class SysRoleServiceImpl implements ISysRoleService {
|
||||
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(SysRoleServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private SysRoleRepository sysRoleRDao;
|
||||
|
||||
@Override
|
||||
public void updateSysRole(SysRole sysRole) {
|
||||
LOGGER.info("系统角色 SYS_ROLE :{}", sysRole);
|
||||
sysRoleRDao.update(sysRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysRoleStatus(String id, int status, SessionUser user) {
|
||||
LOGGER.info("系统角色 SYS_MENU id:{} status:{} user:{}", id,status,user);
|
||||
SysRole role = sysRoleRDao.getById(Long.parseLong(id));
|
||||
role.setRoleStatusId(status);
|
||||
role.setModifyUser(user.getUserName());
|
||||
sysRoleRDao.update(role);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysRoleStatusByIds(String[] ids, int status, SessionUser user) {
|
||||
LOGGER.info("系统功能 SYS_MENU ids:{} status:{} user:{}", ids, status, user);
|
||||
StringBuffer where = new StringBuffer();
|
||||
|
||||
HqlPack.getInPack(String.join(",", ids), "id", where);
|
||||
sysRoleRDao.updateByHqlWhere(where.toString(), "roleStatusId", status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteSysRoleById(String id) {
|
||||
LOGGER.info("系统角色 SYS_ROLE Key:{}", id);
|
||||
sysRoleRDao.deleteById(Long.parseLong(id));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SysRole insertSysRole(SysRole sysRole) {
|
||||
LOGGER.info("系统角色 SYS_ROLE :{}", sysRole);
|
||||
return sysRoleRDao.insert(sysRole);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysRole> findSysRoleAll() {
|
||||
LOGGER.info("系统角色 SYS_ROLE find All");
|
||||
return sysRoleRDao.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysRole getSysRoleById(String id) {
|
||||
LOGGER.info("系统角色 SYS_ROLE find id:{}", id);
|
||||
return sysRoleRDao.getOne(Long.parseLong(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListPager<SysRole> querySysRole(SysRole role, Pager pager) {
|
||||
LOGGER.info("系统角色 SysRole find role :{} page :{}", role, pager);
|
||||
|
||||
if (role == null) {
|
||||
//不传入实体对象,查询所有
|
||||
int count = sysRoleRDao.listCount();
|
||||
pager = PagerHelper.getPager(pager, count);
|
||||
return new ListPager(sysRoleRDao.listPager(pager), pager);
|
||||
} else {
|
||||
//生成hql查询语句
|
||||
String hqlPack = CoreHqlPack.packHqlSysRole(role);
|
||||
pager = PagerHelper.getPager(pager, sysRoleRDao.findByHqlWhereCount(hqlPack));
|
||||
return new ListPager(sysRoleRDao.findByHqlWherePage(hqlPack + role.orderBy(), pager), pager);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
||||
|
||||
import cn.estsh.i3plus.core.api.iservice.busi.ISysFileService;
|
||||
import cn.estsh.i3plus.core.api.iservice.busi.ISysFileService;
|
||||
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.platform.bean.SysFile;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 测试 文件资源服务接口
|
||||
* @Reference :
|
||||
* @Author : yunhao
|
||||
* @Date : 2018-10-31 15:30
|
||||
* @Modify :
|
||||
**/
|
||||
public class TestSysFileService extends TestBase {
|
||||
|
||||
@Autowired
|
||||
ISysFileService sysFileService;
|
||||
|
||||
/**
|
||||
* 测试 查询所有文件资源
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testListSysFile() {
|
||||
List list = sysFileService.listSysFile();
|
||||
System.out.println(JSON.toJSONString(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 根据id查询文件资源
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testGetSysFileById() {
|
||||
SysFile sysFile = sysFileService.getSysFileById("1057110061127700480");
|
||||
System.out.println(JSON.toJSONString(sysFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 添加文件资源
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback(false)
|
||||
public void testInsertSysFile() {
|
||||
SysFile sysFile = new SysFile();
|
||||
sysFile.setName("文件doc");
|
||||
sysFile.setFileTypeId(1058251784058966016L);
|
||||
sysFile.setFileTypeName("doc");
|
||||
sysFile.setDownloads(999);
|
||||
sysFile.setFileSize(1024);
|
||||
sysFile.setCreateUser("中国移动");
|
||||
sysFile.setCreateDatetime("2018-01-01 00:00:00");
|
||||
for (int i = 0; i < 50; i++) {
|
||||
sysFile.setId(null);
|
||||
sysFile.setName("文件"+ i +".doc");
|
||||
sysFile.setCreateDatetime("2018-01-01 " + (i % 10) + "0:00:00");
|
||||
sysFileService.insertSysFile(sysFile);
|
||||
}
|
||||
System.out.println(JSON.toJSONString(sysFile));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 修改文件资源
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testUpdateSysFile(){
|
||||
SysFile sysFile = sysFileService.getSysFileById("1057110613261684736");
|
||||
sysFile.setName("测试修改");
|
||||
|
||||
sysFileService.updateSysFile(sysFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 根据id删除文件资源
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testDeleteSysFileById(){
|
||||
sysFileService.deleteSysFileById("1057111616417566720");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 复杂查询
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testQuerySysFileByPager(){
|
||||
SysFile sysFile = new SysFile();
|
||||
|
||||
Pager pager = new Pager();
|
||||
pager.setPageSize(10);
|
||||
pager.setCurrentPage(5);
|
||||
|
||||
ListPager list = sysFileService.querySysFileByPager(sysFile,pager);
|
||||
System.out.println(list);
|
||||
}
|
||||
}
|
@ -0,0 +1,104 @@
|
||||
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
||||
|
||||
import cn.estsh.i3plus.core.api.iservice.busi.ITaskTimeExpressionService;
|
||||
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.platform.bean.TaskTimeExpression;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description : 测试 时间表达式
|
||||
* @Reference :
|
||||
* @Author : yunhao
|
||||
* @Date : 2018-10-31 15:30
|
||||
* @Modify :
|
||||
**/
|
||||
public class TestTaskTimeExpressionService extends TestBase {
|
||||
|
||||
@Autowired
|
||||
ITaskTimeExpressionService taskTimeExpressionService;
|
||||
|
||||
/**
|
||||
* 测试 查询所有时间表达式
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testListTaskTimeExpression() {
|
||||
List list = taskTimeExpressionService.listTaskTimeExpression();
|
||||
System.out.println(JSON.toJSONString(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 根据id查询时间表达式
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testGetTaskTimeExpressionById() {
|
||||
TaskTimeExpression taskTimeExpression = taskTimeExpressionService.getTaskTimeExpressionById("1057110061127700480");
|
||||
System.out.println(JSON.toJSONString(taskTimeExpression));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 添加时间表达式
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback(false)
|
||||
public void testInsertTaskTimeExpression() {
|
||||
TaskTimeExpression taskTimeExpression = new TaskTimeExpression();
|
||||
taskTimeExpression.setName("表达式");
|
||||
taskTimeExpression.setTimeExpression("0000000");
|
||||
taskTimeExpression.setTimeDescription("描述");
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
taskTimeExpression.setId(null);
|
||||
taskTimeExpression.setName("表达式"+i);
|
||||
taskTimeExpressionService.insertTaskTimeExpression(taskTimeExpression);
|
||||
}
|
||||
System.out.println(JSON.toJSONString(taskTimeExpression));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 修改时间表达式
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testUpdateTaskTimeExpression(){
|
||||
TaskTimeExpression taskTimeExpression = taskTimeExpressionService.getTaskTimeExpressionById("1057110613261684736");
|
||||
taskTimeExpression.setName("测试修改");
|
||||
|
||||
taskTimeExpressionService.updateTaskTimeExpression(taskTimeExpression);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 根据id删除时间表达式
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testDeleteTaskTimeExpressionById(){
|
||||
taskTimeExpressionService.deleteTaskTimeExpressionById("1057111616417566720");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 复杂查询
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testQueryTaskTimeExpressionByPager(){
|
||||
TaskTimeExpression taskTimeExpression = new TaskTimeExpression();
|
||||
|
||||
Pager pager = new Pager();
|
||||
pager.setPageSize(10);
|
||||
pager.setCurrentPage(5);
|
||||
|
||||
ListPager list = taskTimeExpressionService.queryTaskTimeExpressionByPager(taskTimeExpression,pager);
|
||||
System.out.println(list);
|
||||
}
|
||||
}
|
@ -0,0 +1,109 @@
|
||||
package cn.estsh.i3plus.core.apiservice.serviceimpl.busi;
|
||||
|
||||
import cn.estsh.i3plus.core.api.iservice.busi.ITaskTimeService;
|
||||
import cn.estsh.i3plus.core.api.iservice.busi.ITaskTimeService;
|
||||
import cn.estsh.i3plus.pojo.base.bean.ListPager;
|
||||
import cn.estsh.i3plus.pojo.base.common.Pager;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.CommonEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.base.enumutil.ImppEnumUtil;
|
||||
import cn.estsh.i3plus.pojo.platform.bean.TaskTime;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.test.annotation.Rollback;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description :
|
||||
* @Reference :
|
||||
* @Author : yunhao
|
||||
* @Date : 2018-11-03 00:09
|
||||
* @Modify :
|
||||
**/
|
||||
public class TestTaskTimeService extends TestBase {
|
||||
|
||||
@Autowired
|
||||
ITaskTimeService taskTimeService;
|
||||
|
||||
/**
|
||||
* 测试 查询所有硬件
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testListTaskTime() {
|
||||
List list = taskTimeService.listTaskTime();
|
||||
System.out.println(JSON.toJSONString(list));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 根据id查询硬件
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testGetTaskTimeById() {
|
||||
TaskTime taskTime = taskTimeService.getTaskTimeById("1057110061127700480");
|
||||
System.out.println(JSON.toJSONString(taskTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 添加硬件
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
@Rollback(false)
|
||||
public void testInsertTaskTime() {
|
||||
TaskTime taskTime = new TaskTime();
|
||||
taskTime.setName("时间表达式");
|
||||
taskTime.setTaskStartDateTime("2018-01-01 00:00:00");
|
||||
taskTime.setTaskEndDateTime("2018-12-31 00:00:00");
|
||||
taskTime.setLastRunDateTime("2018-11-03 00:00:00");
|
||||
taskTime.setTaskTypeId(ImppEnumUtil.TASK_METHOD_TYPE.TYPE_GROUP.getValue());
|
||||
taskTime.setTaskStatus(CommonEnumUtil.DATA_STATUS.ENABLE.getValue());
|
||||
|
||||
for (int i = 0; i < 50; i++) {
|
||||
taskTime.setId(null);
|
||||
taskTime.setName("时间表达式"+i);
|
||||
taskTimeService.insertTaskTime(taskTime);
|
||||
}
|
||||
System.out.println(JSON.toJSONString(taskTime));
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 修改硬件
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testUpdateTaskTime(){
|
||||
TaskTime taskTime = taskTimeService.getTaskTimeById("1057110613261684736");
|
||||
taskTime.setName("测试修改");
|
||||
|
||||
taskTimeService.updateTaskTime(taskTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 根据id删除硬件
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testDeleteTaskTimeById(){
|
||||
taskTimeService.deleteTaskTimeById("1057111616417566720");
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试 复杂查询
|
||||
*/
|
||||
@Test
|
||||
@Transactional
|
||||
public void testQueryTaskTimeByPager(){
|
||||
TaskTime taskTime = new TaskTime();
|
||||
|
||||
Pager pager = new Pager();
|
||||
pager.setPageSize(10);
|
||||
pager.setCurrentPage(5);
|
||||
|
||||
ListPager list = taskTimeService.queryTaskTimeByPager(taskTime,pager);
|
||||
System.out.println(list);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue