更改为构造注入并完善方法注释

This commit is contained in:
thinkgem
2025-10-12 20:34:34 +08:00
parent 06e88b5bad
commit 2454cb8037
19 changed files with 197 additions and 154 deletions

View File

@@ -4,12 +4,6 @@
*/ */
package com.jeesite.modules.app.db; package com.jeesite.modules.app.db;
import java.util.Date;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import com.jeesite.common.config.Global; import com.jeesite.common.config.Global;
import com.jeesite.common.tests.BaseInitDataTests; import com.jeesite.common.tests.BaseInitDataTests;
import com.jeesite.modules.app.entity.AppComment; import com.jeesite.modules.app.entity.AppComment;
@@ -17,6 +11,10 @@ import com.jeesite.modules.app.entity.AppUpgrade;
import com.jeesite.modules.app.service.AppCommentService; import com.jeesite.modules.app.service.AppCommentService;
import com.jeesite.modules.app.service.AppUpgradeService; import com.jeesite.modules.app.service.AppUpgradeService;
import com.jeesite.modules.gen.utils.GenUtils; import com.jeesite.modules.gen.utils.GenUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import java.util.Date;
/** /**
* 初始化APP表及数据 * 初始化APP表及数据
@@ -27,6 +25,11 @@ import com.jeesite.modules.gen.utils.GenUtils;
@ConditionalOnProperty(name="jeesite.initdata", havingValue="true", matchIfMissing=false) @ConditionalOnProperty(name="jeesite.initdata", havingValue="true", matchIfMissing=false)
public class InitAppData extends BaseInitDataTests { public class InitAppData extends BaseInitDataTests {
public InitAppData(AppUpgradeService appUpgradeService, AppCommentService appCommentService) {
this.appUpgradeService = appUpgradeService;
this.appCommentService = appCommentService;
}
@Override @Override
public boolean initData() throws Exception { public boolean initData() throws Exception {
if (GenUtils.isTableExists(Global.getTablePrefix() + "app_upgrade")) { if (GenUtils.isTableExists(Global.getTablePrefix() + "app_upgrade")) {
@@ -41,8 +44,7 @@ public class InitAppData extends BaseInitDataTests {
return true; return true;
} }
@Autowired private final AppUpgradeService appUpgradeService;
private AppUpgradeService appUpgradeService;
public void initAppUpgrade() throws Exception{ public void initAppUpgrade() throws Exception{
// clearTable(AppUpgrade.class); // clearTable(AppUpgrade.class);
initExcelData(AppUpgrade.class, params -> { initExcelData(AppUpgrade.class, params -> {
@@ -57,8 +59,7 @@ public class InitAppData extends BaseInitDataTests {
}); });
} }
@Autowired private final AppCommentService appCommentService;
private AppCommentService appCommentService;
public void initAppComment() throws Exception{ public void initAppComment() throws Exception{
// clearTable(AppComment.class); // clearTable(AppComment.class);
initExcelData(AppComment.class, params -> { initExcelData(AppComment.class, params -> {

View File

@@ -15,7 +15,6 @@ import com.jeesite.modules.cms.entity.Site;
import com.jeesite.modules.cms.service.CategoryService; import com.jeesite.modules.cms.service.CategoryService;
import com.jeesite.modules.cms.service.SiteService; import com.jeesite.modules.cms.service.SiteService;
import com.jeesite.modules.gen.utils.GenUtils; import com.jeesite.modules.gen.utils.GenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -28,6 +27,14 @@ import org.springframework.stereotype.Component;
@ConditionalOnProperty(name="jeesite.initdata", havingValue="true", matchIfMissing=false) @ConditionalOnProperty(name="jeesite.initdata", havingValue="true", matchIfMissing=false)
public class InitCmsData extends BaseInitDataTests { public class InitCmsData extends BaseInitDataTests {
public InitCmsData(SiteService siteService, CategoryService categoryService,
ArticleDao articleDao, ArticleDataDao articleDataDao) {
this.siteService = siteService;
this.categoryService = categoryService;
this.articleDao = articleDao;
this.articleDataDao = articleDataDao;
}
@Override @Override
public boolean initData() throws Exception { public boolean initData() throws Exception {
if (GenUtils.isTableExists(Global.getTablePrefix() + "cms_article")) { if (GenUtils.isTableExists(Global.getTablePrefix() + "cms_article")) {
@@ -44,8 +51,7 @@ public class InitCmsData extends BaseInitDataTests {
return true; return true;
} }
@Autowired private final SiteService siteService;
private SiteService siteService;
public void initSite() throws Exception{ public void initSite() throws Exception{
initExcelData(Site.class, params -> { initExcelData(Site.class, params -> {
String action = (String)params[0]; String action = (String)params[0];
@@ -59,8 +65,7 @@ public class InitCmsData extends BaseInitDataTests {
}); });
} }
@Autowired private final CategoryService categoryService;
private CategoryService categoryService;
public void initCategory() throws Exception{ public void initCategory() throws Exception{
initExcelData(Category.class, params -> { initExcelData(Category.class, params -> {
String action = (String)params[0]; String action = (String)params[0];
@@ -74,8 +79,7 @@ public class InitCmsData extends BaseInitDataTests {
}); });
} }
@Autowired private final ArticleDao articleDao;
private ArticleDao articleDao;
public void initArticle() throws Exception{ public void initArticle() throws Exception{
initExcelData(Article.class, params -> { initExcelData(Article.class, params -> {
String action = (String)params[0]; String action = (String)params[0];
@@ -89,8 +93,7 @@ public class InitCmsData extends BaseInitDataTests {
}); });
} }
@Autowired private final ArticleDataDao articleDataDao;
private ArticleDataDao articleDataDao;
public void initArticleData() throws Exception{ public void initArticleData() throws Exception{
initExcelData(ArticleData.class, params -> { initExcelData(ArticleData.class, params -> {
String action = (String)params[0]; String action = (String)params[0];

View File

@@ -5,8 +5,10 @@
package com.jeesite.autoconfigure.sys; package com.jeesite.autoconfigure.sys;
import com.jeesite.common.mybatis.MyBatisFactoryBean; import com.jeesite.common.mybatis.MyBatisFactoryBean;
import com.jeesite.modules.msg.dao.MsgInnerRecordDao;
import com.jeesite.modules.msg.service.MsgInnerService; import com.jeesite.modules.msg.service.MsgInnerService;
import com.jeesite.modules.msg.service.support.MsgInnerServiceSupport; import com.jeesite.modules.msg.service.support.MsgInnerServiceSupport;
import com.jeesite.modules.sys.service.EmpUserService;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -25,8 +27,8 @@ public class MsgAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public MsgInnerService msgInnerService(){ public MsgInnerService msgInnerService(EmpUserService empUserService, MsgInnerRecordDao msgInnerRecordDao){
return new MsgInnerServiceSupport(); return new MsgInnerServiceSupport(empUserService, msgInnerRecordDao);
} }
} }

View File

@@ -5,6 +5,10 @@
package com.jeesite.autoconfigure.sys; package com.jeesite.autoconfigure.sys;
import com.jeesite.common.mybatis.MyBatisFactoryBean; import com.jeesite.common.mybatis.MyBatisFactoryBean;
import com.jeesite.modules.sys.dao.CompanyOfficeDao;
import com.jeesite.modules.sys.dao.EmployeeOfficeDao;
import com.jeesite.modules.sys.dao.EmployeePostDao;
import com.jeesite.modules.sys.dao.PostRoleDao;
import com.jeesite.modules.sys.service.*; import com.jeesite.modules.sys.service.*;
import com.jeesite.modules.sys.service.support.*; import com.jeesite.modules.sys.service.support.*;
import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -31,20 +35,20 @@ public class SysAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public CompanyService companyService(){ public CompanyService companyService(CompanyOfficeDao companyOfficeDao, DataScopeService dataScopeService, EmpUserService empUserService){
return new CompanyServiceSupport(); return new CompanyServiceSupport(companyOfficeDao, dataScopeService, empUserService);
} }
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public EmployeeService employeeService(){ public EmployeeService employeeService(EmployeePostDao employeePostDao, EmployeeOfficeDao employeeOfficeDao){
return new EmployeeServiceSupport(); return new EmployeeServiceSupport(employeePostDao, employeeOfficeDao);
} }
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public EmpUserService empUserService(){ public EmpUserService empUserService(UserService userService, EmployeeService employeeService, EmployeeOfficeDao employeeOfficeDao){
return new EmpUserServiceSupport(); return new EmpUserServiceSupport(userService, employeeService, employeeOfficeDao);
} }
@Bean @Bean
@@ -55,14 +59,14 @@ public class SysAutoConfiguration {
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public OfficeService officeService(){ public OfficeService officeService(DataScopeService dataScopeService, EmpUserService empUserService){
return new OfficeServiceSupport(); return new OfficeServiceSupport(dataScopeService, empUserService);
} }
@Bean @Bean
@ConditionalOnMissingBean @ConditionalOnMissingBean
public PostService postService(){ public PostService postService(PostRoleDao postRoleDao, EmpUserService empUserService){
return new PostServiceSupport(); return new PostServiceSupport(postRoleDao, empUserService);
} }
} }

View File

@@ -23,7 +23,6 @@ import com.jeesite.modules.sys.entity.EmpUser;
import com.jeesite.modules.sys.entity.User; import com.jeesite.modules.sys.entity.User;
import com.jeesite.modules.sys.service.EmpUserService; import com.jeesite.modules.sys.service.EmpUserService;
import io.netty.util.concurrent.DefaultThreadFactory; import io.netty.util.concurrent.DefaultThreadFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import java.util.Date;
@@ -40,16 +39,19 @@ import java.util.concurrent.TimeUnit;
*/ */
public class MsgInnerServiceSupport extends CrudService<MsgInnerDao, MsgInner> public class MsgInnerServiceSupport extends CrudService<MsgInnerDao, MsgInner>
implements MsgInnerService { implements MsgInnerService {
@Autowired
private EmpUserService empUserService;
@Autowired
private MsgInnerRecordDao msgInnerRecordDao;
private static ExecutorService msgPushThreadPool = new ThreadPoolExecutor(5, 20, protected static final ExecutorService msgPushThreadPool = new ThreadPoolExecutor(5, 20,
60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(), 60L, TimeUnit.SECONDS, new LinkedBlockingQueue<>(),
new DefaultThreadFactory("cms-update-expired-weight")); new DefaultThreadFactory("cms-update-expired-weight"));
protected final EmpUserService empUserService;
protected final MsgInnerRecordDao msgInnerRecordDao;
public MsgInnerServiceSupport(EmpUserService empUserService, MsgInnerRecordDao msgInnerRecordDao) {
this.empUserService = empUserService;
this.msgInnerRecordDao = msgInnerRecordDao;
}
/** /**
* 获取单条数据 * 获取单条数据
* @param msgInner 主键 * @param msgInner 主键

View File

@@ -15,11 +15,11 @@ import com.jeesite.modules.job.entity.JobEntity;
import com.jeesite.modules.msg.task.impl.MsgLocalMergePushTask; import com.jeesite.modules.msg.task.impl.MsgLocalMergePushTask;
import com.jeesite.modules.msg.task.impl.MsgLocalPushTask; import com.jeesite.modules.msg.task.impl.MsgLocalPushTask;
import com.jeesite.modules.sys.dao.RoleMenuDao; import com.jeesite.modules.sys.dao.RoleMenuDao;
import com.jeesite.modules.sys.entity.Module;
import com.jeesite.modules.sys.entity.*; import com.jeesite.modules.sys.entity.*;
import com.jeesite.modules.sys.entity.Module;
import com.jeesite.modules.sys.service.*; import com.jeesite.modules.sys.service.*;
import org.quartz.CronTrigger; import org.quartz.CronTrigger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.ObjectProvider;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -31,7 +31,28 @@ import org.springframework.stereotype.Component;
@Component @Component
@ConditionalOnProperty(name="jeesite.initdata", havingValue="true", matchIfMissing=false) @ConditionalOnProperty(name="jeesite.initdata", havingValue="true", matchIfMissing=false)
public class InitCoreData extends BaseInitDataTests { public class InitCoreData extends BaseInitDataTests {
public InitCoreData(ConfigService configService, ModuleService moduleService, DictTypeService dictTypeService,
DictDataService dictDataService, RoleService roleService, MenuService menuService,
RoleMenuDao roleMenuDao, UserService userService, OfficeService officeService,
CompanyService companyService, PostService postService, EmpUserService empUserService,
ObjectProvider<JobDao> jobDao, BizCategoryService bizCategoryService) {
this.configService = configService;
this.moduleService = moduleService;
this.dictTypeService = dictTypeService;
this.dictDataService = dictDataService;
this.roleService = roleService;
this.menuService = menuService;
this.roleMenuDao = roleMenuDao;
this.userService = userService;
this.officeService = officeService;
this.companyService = companyService;
this.postService = postService;
this.empUserService = empUserService;
this.jobDao = jobDao.getIfAvailable();
this.bizCategoryService = bizCategoryService;
}
@Override @Override
public boolean initData() throws Exception { public boolean initData() throws Exception {
if (GenUtils.isTableExists(Global.getTablePrefix() + "sys_module")) { if (GenUtils.isTableExists(Global.getTablePrefix() + "sys_module")) {
@@ -56,8 +77,7 @@ public class InitCoreData extends BaseInitDataTests {
return true; return true;
} }
// @Autowired // private final AreaService areaService;
// private AreaService areaService;
/** /**
* 区域、行政区划表 * 区域、行政区划表
*/ */
@@ -85,8 +105,7 @@ public class InitCoreData extends BaseInitDataTests {
// }); // });
} }
@Autowired private final ConfigService configService;
private ConfigService configService;
/** /**
* 参数配置表 * 参数配置表
*/ */
@@ -105,8 +124,7 @@ public class InitCoreData extends BaseInitDataTests {
}); });
} }
@Autowired private final ModuleService moduleService;
private ModuleService moduleService;
/** /**
* 系统模块表 * 系统模块表
*/ */
@@ -124,10 +142,8 @@ public class InitCoreData extends BaseInitDataTests {
}); });
} }
@Autowired private final DictTypeService dictTypeService;
private DictTypeService dictTypeService; private final DictDataService dictDataService;
@Autowired
private DictDataService dictDataService;
/** /**
* 系统字典、用户字典表 * 系统字典、用户字典表
*/ */
@@ -158,8 +174,7 @@ public class InitCoreData extends BaseInitDataTests {
}); });
} }
@Autowired private final RoleService roleService;
private RoleService roleService;
/** /**
* 角色表 * 角色表
*/ */
@@ -179,10 +194,8 @@ public class InitCoreData extends BaseInitDataTests {
}); });
} }
@Autowired private final MenuService menuService;
private MenuService menuService; private final RoleMenuDao roleMenuDao;
@Autowired
private RoleMenuDao roleMenuDao;
/** /**
* 菜单表 * 菜单表
*/ */
@@ -205,8 +218,7 @@ public class InitCoreData extends BaseInitDataTests {
}); });
} }
@Autowired private final UserService userService;
private UserService userService;
/** /**
* 用户表 * 用户表
*/ */
@@ -226,8 +238,7 @@ public class InitCoreData extends BaseInitDataTests {
}); });
} }
@Autowired private final OfficeService officeService;
private OfficeService officeService;
/** /**
* 组织机构、部门表 * 组织机构、部门表
*/ */
@@ -245,8 +256,7 @@ public class InitCoreData extends BaseInitDataTests {
}); });
} }
@Autowired private final CompanyService companyService;
private CompanyService companyService;
/** /**
* 公司表 * 公司表
*/ */
@@ -265,8 +275,7 @@ public class InitCoreData extends BaseInitDataTests {
}); });
} }
@Autowired private final PostService postService;
private PostService postService;
/** /**
* 岗位表 * 岗位表
*/ */
@@ -284,8 +293,7 @@ public class InitCoreData extends BaseInitDataTests {
}); });
} }
@Autowired private final EmpUserService empUserService;
private EmpUserService empUserService;
/** /**
* 员工、用户表 * 员工、用户表
*/ */
@@ -322,8 +330,7 @@ public class InitCoreData extends BaseInitDataTests {
}); });
} }
@Autowired(required = false) private final JobDao jobDao; // 默认情况下job是关闭状态需要注入jobDao
private JobDao jobDao; // 默认情况下job是关闭状态需要注入jobDao
/** /**
* 初始化消息推送服务 * 初始化消息推送服务
*/ */
@@ -363,8 +370,7 @@ public class InitCoreData extends BaseInitDataTests {
jobDao.insert(job); jobDao.insert(job);
} }
@Autowired private final BizCategoryService bizCategoryService;
private BizCategoryService bizCategoryService;
public void initBizCategory() throws Exception{ public void initBizCategory() throws Exception{
// clearTable(BizCategory.class); // clearTable(BizCategory.class);
initExcelData(BizCategory.class, params -> { initExcelData(BizCategory.class, params -> {

View File

@@ -18,7 +18,6 @@ import com.jeesite.modules.sys.service.DataScopeService;
import com.jeesite.modules.sys.service.EmpUserService; import com.jeesite.modules.sys.service.EmpUserService;
import com.jeesite.modules.sys.utils.EmpUtils; import com.jeesite.modules.sys.utils.EmpUtils;
import com.jeesite.modules.sys.utils.UserUtils; import com.jeesite.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@@ -31,13 +30,17 @@ import java.util.List;
public class CompanyServiceSupport extends TreeService<CompanyDao, Company> public class CompanyServiceSupport extends TreeService<CompanyDao, Company>
implements CompanyService{ implements CompanyService{
@Autowired protected final CompanyOfficeDao companyOfficeDao;
private CompanyOfficeDao companyOfficeDao; protected final DataScopeService dataScopeService;
@Autowired protected final EmpUserService empUserService;
private DataScopeService dataScopeService;
@Autowired public CompanyServiceSupport(CompanyOfficeDao companyOfficeDao, DataScopeService dataScopeService,
private EmpUserService empUserService; EmpUserService empUserService) {
this.companyOfficeDao = companyOfficeDao;
this.dataScopeService = dataScopeService;
this.empUserService = empUserService;
}
/** /**
* 获取单条数据 * 获取单条数据
*/ */

View File

@@ -24,7 +24,6 @@ import com.jeesite.modules.sys.service.EmployeeService;
import com.jeesite.modules.sys.service.UserService; import com.jeesite.modules.sys.service.UserService;
import com.jeesite.modules.sys.utils.EmpUtils; import com.jeesite.modules.sys.utils.EmpUtils;
import com.jeesite.modules.sys.utils.UserUtils; import com.jeesite.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -41,13 +40,16 @@ import java.util.List;
public class EmpUserServiceSupport extends CrudService<EmpUserDao, EmpUser> public class EmpUserServiceSupport extends CrudService<EmpUserDao, EmpUser>
implements EmpUserService{ implements EmpUserService{
@Autowired protected final UserService userService;
private UserService userService; protected final EmployeeService employeeService;
@Autowired protected final EmployeeOfficeDao employeeOfficeDao;
private EmployeeService employeeService;
@Autowired public EmpUserServiceSupport(UserService userService, EmployeeService employeeService, EmployeeOfficeDao employeeOfficeDao) {
private EmployeeOfficeDao employeeOfficeDao; this.userService = userService;
this.employeeService = employeeService;
this.employeeOfficeDao = employeeOfficeDao;
}
/** /**
* 租户功能验证 * 租户功能验证
*/ */

View File

@@ -15,7 +15,6 @@ import com.jeesite.modules.sys.entity.Employee;
import com.jeesite.modules.sys.entity.EmployeeOffice; import com.jeesite.modules.sys.entity.EmployeeOffice;
import com.jeesite.modules.sys.entity.EmployeePost; import com.jeesite.modules.sys.entity.EmployeePost;
import com.jeesite.modules.sys.service.EmployeeService; import com.jeesite.modules.sys.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@@ -28,11 +27,14 @@ import java.util.List;
public class EmployeeServiceSupport extends CrudService<EmployeeDao, Employee> public class EmployeeServiceSupport extends CrudService<EmployeeDao, Employee>
implements EmployeeService{ implements EmployeeService{
@Autowired protected final EmployeePostDao employeePostDao;
private EmployeePostDao employeePostDao; protected final EmployeeOfficeDao employeeOfficeDao;
@Autowired
private EmployeeOfficeDao employeeOfficeDao; public EmployeeServiceSupport(EmployeePostDao employeePostDao, EmployeeOfficeDao employeeOfficeDao) {
this.employeePostDao = employeePostDao;
this.employeeOfficeDao = employeeOfficeDao;
}
/** /**
* 获取单条数据 * 获取单条数据
*/ */

View File

@@ -19,7 +19,6 @@ import com.jeesite.modules.sys.service.EmpUserService;
import com.jeesite.modules.sys.service.OfficeService; import com.jeesite.modules.sys.service.OfficeService;
import com.jeesite.modules.sys.utils.EmpUtils; import com.jeesite.modules.sys.utils.EmpUtils;
import com.jeesite.modules.sys.utils.UserUtils; import com.jeesite.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
@@ -35,11 +34,14 @@ import java.util.List;
public class OfficeServiceSupport extends TreeService<OfficeDao, Office> public class OfficeServiceSupport extends TreeService<OfficeDao, Office>
implements OfficeService{ implements OfficeService{
@Autowired protected final DataScopeService dataScopeService;
private DataScopeService dataScopeService; protected final EmpUserService empUserService;
@Autowired
private EmpUserService empUserService; public OfficeServiceSupport(DataScopeService dataScopeService, EmpUserService empUserService) {
this.dataScopeService = dataScopeService;
this.empUserService = empUserService;
}
/** /**
* 获取单条数据 * 获取单条数据
*/ */

View File

@@ -12,12 +12,13 @@ import com.jeesite.common.service.CrudService;
import com.jeesite.common.utils.PageUtils; import com.jeesite.common.utils.PageUtils;
import com.jeesite.modules.sys.dao.PostDao; import com.jeesite.modules.sys.dao.PostDao;
import com.jeesite.modules.sys.dao.PostRoleDao; import com.jeesite.modules.sys.dao.PostRoleDao;
import com.jeesite.modules.sys.entity.*; import com.jeesite.modules.sys.entity.EmpUser;
import com.jeesite.modules.sys.entity.Post;
import com.jeesite.modules.sys.entity.PostRole;
import com.jeesite.modules.sys.service.EmpUserService; import com.jeesite.modules.sys.service.EmpUserService;
import com.jeesite.modules.sys.service.PostService; import com.jeesite.modules.sys.service.PostService;
import com.jeesite.modules.sys.utils.CorpUtils; import com.jeesite.modules.sys.utils.CorpUtils;
import com.jeesite.modules.sys.utils.UserUtils; import com.jeesite.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List; import java.util.List;
@@ -30,10 +31,13 @@ import java.util.List;
public class PostServiceSupport extends CrudService<PostDao, Post> public class PostServiceSupport extends CrudService<PostDao, Post>
implements PostService{ implements PostService{
@Autowired protected final PostRoleDao postRoleDao;
private PostRoleDao postRoleDao; protected final EmpUserService empUserService;
@Autowired
private EmpUserService empUserService; public PostServiceSupport(PostRoleDao postRoleDao, EmpUserService empUserService) {
this.postRoleDao = postRoleDao;
this.empUserService = empUserService;
}
/** /**
* 查询岗位 * 查询岗位

View File

@@ -18,7 +18,6 @@ import com.jeesite.modules.sys.utils.UserUtils;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.session.Session; import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;

View File

@@ -20,7 +20,6 @@ import com.jeesite.modules.sys.dao.*;
import com.jeesite.modules.sys.entity.*; import com.jeesite.modules.sys.entity.*;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
@@ -36,18 +35,22 @@ import java.util.List;
@SpringBootTest(classes = ApplicationTest.class) @SpringBootTest(classes = ApplicationTest.class)
public class DaoMapperTest extends BaseSpringContextTests { public class DaoMapperTest extends BaseSpringContextTests {
@Autowired private final PostDao postDao;
private PostDao postDao; private final UserDao userDao;
@Autowired private final AreaDao areaDao;
private UserDao userDao; private final CompanyDao companyDao;
@Autowired private final FileUploadDao fileUploadDao;
private AreaDao areaDao; private final EmpUserDao empUserDao;
@Autowired
private CompanyDao companyDao; public DaoMapperTest(PostDao postDao, UserDao userDao, AreaDao areaDao, CompanyDao companyDao,
@Autowired FileUploadDao fileUploadDao, EmpUserDao empUserDao) {
private FileUploadDao fileUploadDao; this.postDao = postDao;
@Autowired this.userDao = userDao;
private EmpUserDao empUserDao; this.areaDao = areaDao;
this.companyDao = companyDao;
this.fileUploadDao = fileUploadDao;
this.empUserDao = empUserDao;
}
@Test @Test
public void testTableAnnotation() throws Exception{ public void testTableAnnotation() throws Exception{

View File

@@ -4,18 +4,16 @@
*/ */
package com.jeesite.test; package com.jeesite.test;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles;
import com.jeesite.common.config.Global; import com.jeesite.common.config.Global;
import com.jeesite.common.lang.StringUtils; import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.tests.BaseSpringContextTests; import com.jeesite.common.tests.BaseSpringContextTests;
import com.jeesite.modules.gen.entity.GenTable; import com.jeesite.modules.gen.entity.GenTable;
import com.jeesite.modules.gen.entity.GenTableColumn; import com.jeesite.modules.gen.entity.GenTableColumn;
import com.jeesite.modules.gen.service.GenTableService; import com.jeesite.modules.gen.service.GenTableService;
import org.junit.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles;
/** /**
* 代码生成工具API * 代码生成工具API
@@ -27,9 +25,12 @@ import com.jeesite.modules.gen.service.GenTableService;
@Rollback(false) @Rollback(false)
public class GenTableToolTest extends BaseSpringContextTests { public class GenTableToolTest extends BaseSpringContextTests {
@Autowired private final GenTableService genTableService;
private GenTableService genTableService;
public GenTableToolTest(GenTableService genTableService) {
this.genTableService = genTableService;
}
@Test @Test
public void execute() throws Exception{ public void execute() throws Exception{
GenTable genTable = new GenTable(); GenTable genTable = new GenTable();

View File

@@ -23,7 +23,6 @@ import com.jeesite.modules.sys.service.UserService;
import com.jeesite.modules.sys.utils.UserUtils; import com.jeesite.modules.sys.utils.UserUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback; import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
@@ -41,11 +40,14 @@ import java.util.List;
@Rollback(false) @Rollback(false)
public class MsgPushTest extends BaseSpringContextTests { public class MsgPushTest extends BaseSpringContextTests {
@Autowired private final UserService userService;
private UserService userService; private final MsgTemplateService msgTemplateService;
@Autowired
private MsgTemplateService msgTemplateService; public MsgPushTest(UserService userService, MsgTemplateService msgTemplateService) {
this.userService = userService;
this.msgTemplateService = msgTemplateService;
}
@Test @Test
public void testSend(){ public void testSend(){
User user = UserUtils.get("system"); User user = UserUtils.get("system");

View File

@@ -4,18 +4,16 @@
*/ */
package com.jeesite.modules.test.db; package com.jeesite.modules.test.db;
import com.jeesite.common.datasource.DataSourceHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
import com.jeesite.common.config.Global; import com.jeesite.common.config.Global;
import com.jeesite.common.datasource.DataSourceHolder;
import com.jeesite.common.lang.StringUtils; import com.jeesite.common.lang.StringUtils;
import com.jeesite.common.tests.BaseInitDataTests; import com.jeesite.common.tests.BaseInitDataTests;
import com.jeesite.modules.gen.entity.GenTable; import com.jeesite.modules.gen.entity.GenTable;
import com.jeesite.modules.gen.entity.GenTableColumn; import com.jeesite.modules.gen.entity.GenTableColumn;
import com.jeesite.modules.gen.service.GenTableService; import com.jeesite.modules.gen.service.GenTableService;
import com.jeesite.modules.gen.utils.GenUtils; import com.jeesite.modules.gen.utils.GenUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
/** /**
* 初始化核心表数据 * 初始化核心表数据
@@ -26,6 +24,10 @@ import com.jeesite.modules.gen.utils.GenUtils;
@ConditionalOnProperty(name="jeesite.initdata", havingValue="true", matchIfMissing=false) @ConditionalOnProperty(name="jeesite.initdata", havingValue="true", matchIfMissing=false)
public class InitTestData extends BaseInitDataTests { public class InitTestData extends BaseInitDataTests {
public InitTestData(GenTableService genTableService) {
this.genTableService = genTableService;
}
@Override @Override
public boolean initData() throws Exception { public boolean initData() throws Exception {
if (GenUtils.isTableExists("test_data")) { if (GenUtils.isTableExists("test_data")) {
@@ -36,8 +38,7 @@ public class InitTestData extends BaseInitDataTests {
return true; return true;
} }
@Autowired private final GenTableService genTableService;
private GenTableService genTableService;
/** /**
* 代码生成测试数据 * 代码生成测试数据
*/ */

View File

@@ -14,7 +14,6 @@ import com.jeesite.modules.test.dao.TestDataChildDao;
import com.jeesite.modules.test.dao.TestDataDao; import com.jeesite.modules.test.dao.TestDataDao;
import com.jeesite.modules.test.entity.TestData; import com.jeesite.modules.test.entity.TestData;
import com.jeesite.modules.test.entity.TestDataChild; import com.jeesite.modules.test.entity.TestDataChild;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@@ -28,9 +27,12 @@ import java.util.List;
@Service @Service
public class TestDataService extends CrudService<TestDataDao, TestData> { public class TestDataService extends CrudService<TestDataDao, TestData> {
@Autowired private final TestDataChildDao testDataChildDao;
private TestDataChildDao testDataChildDao;
public TestDataService(TestDataChildDao testDataChildDao) {
this.testDataChildDao = testDataChildDao;
}
/** /**
* 获取单条数据 * 获取单条数据
* @param testData 主键 * @param testData 主键

View File

@@ -9,7 +9,6 @@ import com.jeesite.common.tests.BaseSpringContextTests;
import com.jeesite.modules.test.dao.TestDataDao; import com.jeesite.modules.test.dao.TestDataDao;
import com.jeesite.modules.test.entity.TestData; import com.jeesite.modules.test.entity.TestData;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
@@ -24,9 +23,12 @@ import java.util.List;
@SpringBootTest(classes = ApplicationTest.class) @SpringBootTest(classes = ApplicationTest.class)
public class InsertBatchTest extends BaseSpringContextTests { public class InsertBatchTest extends BaseSpringContextTests {
@Autowired private final TestDataDao testDataDao;
private TestDataDao testDataDao;
public InsertBatchTest(TestDataDao testDataDao) {
this.testDataDao = testDataDao;
}
@Test @Test
public void testData1() throws Exception{ public void testData1() throws Exception{
List<TestData> list = ListUtils.newArrayList(); List<TestData> list = ListUtils.newArrayList();

View File

@@ -11,7 +11,6 @@ import com.jeesite.modules.test.entity.TestData;
import com.jeesite.modules.test.entity.TestDataChild; import com.jeesite.modules.test.entity.TestDataChild;
import com.jeesite.modules.test.service.TestDataService; import com.jeesite.modules.test.service.TestDataService;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ActiveProfiles;
@@ -32,9 +31,12 @@ import java.util.concurrent.Executors;
@SpringBootTest(classes = ApplicationTest.class) @SpringBootTest(classes = ApplicationTest.class)
public class MultiDataSourceTest extends BaseSpringContextTests { public class MultiDataSourceTest extends BaseSpringContextTests {
@Autowired private final TestDataService testDataService;
private TestDataService testDataService;
public MultiDataSourceTest(TestDataService testDataService) {
this.testDataService = testDataService;
}
@Test @Test
public void testData() throws Exception{ public void testData() throws Exception{
ExecutorService pool = Executors.newCachedThreadPool(); ExecutorService pool = Executors.newCachedThreadPool();