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

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

@@ -5,8 +5,10 @@
package com.jeesite.autoconfigure.sys;
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.support.MsgInnerServiceSupport;
import com.jeesite.modules.sys.service.EmpUserService;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
@@ -25,8 +27,8 @@ public class MsgAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public MsgInnerService msgInnerService(){
return new MsgInnerServiceSupport();
public MsgInnerService msgInnerService(EmpUserService empUserService, MsgInnerRecordDao msgInnerRecordDao){
return new MsgInnerServiceSupport(empUserService, msgInnerRecordDao);
}
}

View File

@@ -5,6 +5,10 @@
package com.jeesite.autoconfigure.sys;
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.support.*;
import org.springframework.boot.autoconfigure.AutoConfiguration;
@@ -31,20 +35,20 @@ public class SysAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public CompanyService companyService(){
return new CompanyServiceSupport();
public CompanyService companyService(CompanyOfficeDao companyOfficeDao, DataScopeService dataScopeService, EmpUserService empUserService){
return new CompanyServiceSupport(companyOfficeDao, dataScopeService, empUserService);
}
@Bean
@ConditionalOnMissingBean
public EmployeeService employeeService(){
return new EmployeeServiceSupport();
public EmployeeService employeeService(EmployeePostDao employeePostDao, EmployeeOfficeDao employeeOfficeDao){
return new EmployeeServiceSupport(employeePostDao, employeeOfficeDao);
}
@Bean
@ConditionalOnMissingBean
public EmpUserService empUserService(){
return new EmpUserServiceSupport();
public EmpUserService empUserService(UserService userService, EmployeeService employeeService, EmployeeOfficeDao employeeOfficeDao){
return new EmpUserServiceSupport(userService, employeeService, employeeOfficeDao);
}
@Bean
@@ -55,14 +59,14 @@ public class SysAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public OfficeService officeService(){
return new OfficeServiceSupport();
public OfficeService officeService(DataScopeService dataScopeService, EmpUserService empUserService){
return new OfficeServiceSupport(dataScopeService, empUserService);
}
@Bean
@ConditionalOnMissingBean
public PostService postService(){
return new PostServiceSupport();
public PostService postService(PostRoleDao postRoleDao, EmpUserService empUserService){
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.service.EmpUserService;
import io.netty.util.concurrent.DefaultThreadFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
@@ -40,16 +39,19 @@ import java.util.concurrent.TimeUnit;
*/
public class MsgInnerServiceSupport extends CrudService<MsgInnerDao, MsgInner>
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<>(),
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 主键

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.MsgLocalPushTask;
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.Module;
import com.jeesite.modules.sys.service.*;
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.stereotype.Component;
@@ -31,7 +31,28 @@ import org.springframework.stereotype.Component;
@Component
@ConditionalOnProperty(name="jeesite.initdata", havingValue="true", matchIfMissing=false)
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
public boolean initData() throws Exception {
if (GenUtils.isTableExists(Global.getTablePrefix() + "sys_module")) {
@@ -56,8 +77,7 @@ public class InitCoreData extends BaseInitDataTests {
return true;
}
// @Autowired
// private AreaService areaService;
// private final AreaService areaService;
/**
* 区域、行政区划表
*/
@@ -85,8 +105,7 @@ public class InitCoreData extends BaseInitDataTests {
// });
}
@Autowired
private ConfigService configService;
private final ConfigService configService;
/**
* 参数配置表
*/
@@ -105,8 +124,7 @@ public class InitCoreData extends BaseInitDataTests {
});
}
@Autowired
private ModuleService moduleService;
private final ModuleService moduleService;
/**
* 系统模块表
*/
@@ -124,10 +142,8 @@ public class InitCoreData extends BaseInitDataTests {
});
}
@Autowired
private DictTypeService dictTypeService;
@Autowired
private DictDataService dictDataService;
private final DictTypeService dictTypeService;
private final DictDataService dictDataService;
/**
* 系统字典、用户字典表
*/
@@ -158,8 +174,7 @@ public class InitCoreData extends BaseInitDataTests {
});
}
@Autowired
private RoleService roleService;
private final RoleService roleService;
/**
* 角色表
*/
@@ -179,10 +194,8 @@ public class InitCoreData extends BaseInitDataTests {
});
}
@Autowired
private MenuService menuService;
@Autowired
private RoleMenuDao roleMenuDao;
private final MenuService menuService;
private final RoleMenuDao roleMenuDao;
/**
* 菜单表
*/
@@ -205,8 +218,7 @@ public class InitCoreData extends BaseInitDataTests {
});
}
@Autowired
private UserService userService;
private final UserService userService;
/**
* 用户表
*/
@@ -226,8 +238,7 @@ public class InitCoreData extends BaseInitDataTests {
});
}
@Autowired
private OfficeService officeService;
private final OfficeService officeService;
/**
* 组织机构、部门表
*/
@@ -245,8 +256,7 @@ public class InitCoreData extends BaseInitDataTests {
});
}
@Autowired
private CompanyService companyService;
private final CompanyService companyService;
/**
* 公司表
*/
@@ -265,8 +275,7 @@ public class InitCoreData extends BaseInitDataTests {
});
}
@Autowired
private PostService postService;
private final PostService postService;
/**
* 岗位表
*/
@@ -284,8 +293,7 @@ public class InitCoreData extends BaseInitDataTests {
});
}
@Autowired
private EmpUserService empUserService;
private final EmpUserService empUserService;
/**
* 员工、用户表
*/
@@ -322,8 +330,7 @@ public class InitCoreData extends BaseInitDataTests {
});
}
@Autowired(required = false)
private JobDao jobDao; // 默认情况下job是关闭状态需要注入jobDao
private final JobDao jobDao; // 默认情况下job是关闭状态需要注入jobDao
/**
* 初始化消息推送服务
*/
@@ -363,8 +370,7 @@ public class InitCoreData extends BaseInitDataTests {
jobDao.insert(job);
}
@Autowired
private BizCategoryService bizCategoryService;
private final BizCategoryService bizCategoryService;
public void initBizCategory() throws Exception{
// clearTable(BizCategory.class);
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.utils.EmpUtils;
import com.jeesite.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -31,13 +30,17 @@ import java.util.List;
public class CompanyServiceSupport extends TreeService<CompanyDao, Company>
implements CompanyService{
@Autowired
private CompanyOfficeDao companyOfficeDao;
@Autowired
private DataScopeService dataScopeService;
@Autowired
private EmpUserService empUserService;
protected final CompanyOfficeDao companyOfficeDao;
protected final DataScopeService dataScopeService;
protected final EmpUserService empUserService;
public CompanyServiceSupport(CompanyOfficeDao companyOfficeDao, DataScopeService dataScopeService,
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.utils.EmpUtils;
import com.jeesite.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -41,13 +40,16 @@ import java.util.List;
public class EmpUserServiceSupport extends CrudService<EmpUserDao, EmpUser>
implements EmpUserService{
@Autowired
private UserService userService;
@Autowired
private EmployeeService employeeService;
@Autowired
private EmployeeOfficeDao employeeOfficeDao;
protected final UserService userService;
protected final EmployeeService employeeService;
protected final EmployeeOfficeDao employeeOfficeDao;
public EmpUserServiceSupport(UserService userService, EmployeeService employeeService, 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.EmployeePost;
import com.jeesite.modules.sys.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -28,11 +27,14 @@ import java.util.List;
public class EmployeeServiceSupport extends CrudService<EmployeeDao, Employee>
implements EmployeeService{
@Autowired
private EmployeePostDao employeePostDao;
@Autowired
private EmployeeOfficeDao employeeOfficeDao;
protected final EmployeePostDao employeePostDao;
protected final 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.utils.EmpUtils;
import com.jeesite.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
@@ -35,11 +34,14 @@ import java.util.List;
public class OfficeServiceSupport extends TreeService<OfficeDao, Office>
implements OfficeService{
@Autowired
private DataScopeService dataScopeService;
@Autowired
private EmpUserService empUserService;
protected final DataScopeService dataScopeService;
protected final 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.modules.sys.dao.PostDao;
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.PostService;
import com.jeesite.modules.sys.utils.CorpUtils;
import com.jeesite.modules.sys.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@@ -30,10 +31,13 @@ import java.util.List;
public class PostServiceSupport extends CrudService<PostDao, Post>
implements PostService{
@Autowired
private PostRoleDao postRoleDao;
@Autowired
private EmpUserService empUserService;
protected final PostRoleDao postRoleDao;
protected final 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 org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.session.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Controller;
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 org.junit.Assert;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
@@ -36,18 +35,22 @@ import java.util.List;
@SpringBootTest(classes = ApplicationTest.class)
public class DaoMapperTest extends BaseSpringContextTests {
@Autowired
private PostDao postDao;
@Autowired
private UserDao userDao;
@Autowired
private AreaDao areaDao;
@Autowired
private CompanyDao companyDao;
@Autowired
private FileUploadDao fileUploadDao;
@Autowired
private EmpUserDao empUserDao;
private final PostDao postDao;
private final UserDao userDao;
private final AreaDao areaDao;
private final CompanyDao companyDao;
private final FileUploadDao fileUploadDao;
private final EmpUserDao empUserDao;
public DaoMapperTest(PostDao postDao, UserDao userDao, AreaDao areaDao, CompanyDao companyDao,
FileUploadDao fileUploadDao, EmpUserDao empUserDao) {
this.postDao = postDao;
this.userDao = userDao;
this.areaDao = areaDao;
this.companyDao = companyDao;
this.fileUploadDao = fileUploadDao;
this.empUserDao = empUserDao;
}
@Test
public void testTableAnnotation() throws Exception{

View File

@@ -4,18 +4,16 @@
*/
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.lang.StringUtils;
import com.jeesite.common.tests.BaseSpringContextTests;
import com.jeesite.modules.gen.entity.GenTable;
import com.jeesite.modules.gen.entity.GenTableColumn;
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
@@ -27,9 +25,12 @@ import com.jeesite.modules.gen.service.GenTableService;
@Rollback(false)
public class GenTableToolTest extends BaseSpringContextTests {
@Autowired
private GenTableService genTableService;
private final GenTableService genTableService;
public GenTableToolTest(GenTableService genTableService) {
this.genTableService = genTableService;
}
@Test
public void execute() throws Exception{
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 org.apache.commons.lang3.StringUtils;
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;
@@ -41,11 +40,14 @@ import java.util.List;
@Rollback(false)
public class MsgPushTest extends BaseSpringContextTests {
@Autowired
private UserService userService;
@Autowired
private MsgTemplateService msgTemplateService;
private final UserService userService;
private final MsgTemplateService msgTemplateService;
public MsgPushTest(UserService userService, MsgTemplateService msgTemplateService) {
this.userService = userService;
this.msgTemplateService = msgTemplateService;
}
@Test
public void testSend(){
User user = UserUtils.get("system");