-
数据库层:用于存储实验室的各种信息,包括实验室设备、试剂、文献、人员等。
-
应用层:用于实现实验室信息管理系统的各种功能,包括设备管理、试剂管理、文献管理、人员管理、实验计划管理、实验数据管理等。
-
用户界面层:用于提供用户与实验室信息管理系统进行交互的界面,包括Web界面、移动端界面等。
-
安全层:用于保障实验室信息的安全性,包括用户身份验证、数据加密、访问控制等。
-
数据分析层:用于对实验室信息进行分析和挖掘,以提供决策支持和优化实验室管理。
-
通信层:用于实现实验室信息管理系统与其他系统的数据交换和通信,包括与仪器设备的通信、与实验室信息系统的集成等。
package co.fuyond;import co.fuyond.annotation.AnonymousAccess;
import co.fuyond.utils.SpringContextHolder;
import com.binarywang.spring.starter.wxjava.miniapp.config.WxMaAutoConfiguration;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;@EnableAsync
@RestController
@SpringBootApplication(exclude = {WxMaAutoConfiguration.class})
@EnableTransactionManagement
@MapperScan(basePackages = {"co.fuyond.modules.*.service.mapper", "co.fuyond.config", "co.fuyond.mapper"})
public class AppRun {
public static void main(String[] args) {
SpringApplication.run(AppRun.class, args);
System.out.println(
" __ \n" +
" __ __ ___ / / ___ ___ \n" +
" / // /(_-< / _ \\/ _ \\ / _ \\ \n" +
" \\_, //___//_//_/\\___// .__/ \n" +
"/___/ /_/ \n " + "\n系统管理后台启动成功 \n");
} @Bean
public SpringContextHolder springContextHolder() {
return new SpringContextHolder();
} @Bean
public ServletWebServerFactory webServerFactory() {
TomcatServletWebServerFactory fa = new TomcatServletWebServerFactory();
fa.addConnectorCustomizers(connector -> connector.setProperty("relaxedQueryChars", "[]{}"));
return fa;
} /**
* 访问首页提示
*
* @return /
*/
@GetMapping("/")
@AnonymousAccess
public String index() {
return "Backend service started successfully";
}
}
package co.fuyond.config;import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;@Configuration(proxyBeanMethods = false)
@EnableWebMvc
public class ConfigurerAdapter implements WebMvcConfigurer {
@Value("${file.path}")
private String path;
@Value("${file.avatar}")
private String avatar; @Bean
public CorsFilter corsFilter() {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
CorsConfiguration config = new CorsConfiguration();
// 允许cookies跨域
config.setAllowCredentials(true);
// #允许向该服务器提交请求的URI,*表示全部允许,在SpringMVC中,如果设成*,会自动转成当前请求头中的Origin
config.addAllowedOriginPattern("*");
// #允许访问的头信息,*表示全部
config.addAllowedHeader("*");
// 预检请求的缓存时间(秒),即在这个时间段里,对于相同的跨域请求不会再预检了
config.setMaxAge(18000L);
// 允许提交请求的方法类型,*表示全部允许
config.addAllowedMethod("OPTIONS");
config.addAllowedMethod("HEAD");
config.addAllowedMethod("GET");
config.addAllowedMethod("PUT");
config.addAllowedMethod("POST");
config.addAllowedMethod("DELETE");
config.addAllowedMethod("PATCH");
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
} @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
String avatarUtl = "file:" + avatar.replace("\\", "/");
String pathUtl = "file:" + path.replace("\\", "/");
registry.addResourceHandler("/avatar/**").addResourceLocations(avatarUtl).setCachePeriod(0);
registry.addResourceHandler("/file/**").addResourceLocations(pathUtl).setCachePeriod(0);
registry.addResourceHandler("/**").addResourceLocations("classpath:/META-INF/resources/").setCachePeriod(0);
}
}
package co.fuyond.config;
import co.fuyond.modules.system.domain.Dept;
import co.fuyond.modules.system.service.DeptService;
import co.fuyond.modules.system.service.RoleService;
import co.fuyond.modules.system.service.UserService;
import co.fuyond.modules.system.service.dto.RoleSmallDto;
import co.fuyond.modules.system.service.dto.UserDto;
import co.fuyond.utils.SecurityUtils;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;/**
* 数据权限配置
*
* @author hupeng
*/
@Component
public class DataScope {
private final String[] scopeType = {"全部", "本级", "自定义"};
private final UserService userService;
private final RoleService roleService;
private final DeptService deptService; public DataScope(UserService userService, RoleService roleService, DeptService deptService) {
this.userService = userService;
this.roleService = roleService;
this.deptService = deptService;
} public Set<Long> getDeptIds() {
UserDto user = userService.findByName(SecurityUtils.getUsername()); // 用于存储部门id
Set<Long> deptIds = new HashSet<>(); // 查询用户角色
List<RoleSmallDto> roleSet = roleService.findByUsersId(user.getId());
for (RoleSmallDto role : roleSet) {
if (scopeType[0].equals(role.getDataScope())) {
return new HashSet<>();
} // 存储本级的数据权限
if (scopeType[1].equals(role.getDataScope())) {
deptIds.add(user.getDept().getId());
} // 存储自定义的数据权限
if (scopeType[2].equals(role.getDataScope())) {
Set<Dept> depts = deptService.findByRoleIds(role.getId());
for (Dept dept : depts) {
deptIds.add(dept.getId());
List<Dept> deptChildren = deptService.findByPid(dept.getId());
if (deptChildren != null && deptChildren.size() != 0) {
deptIds.addAll(getDeptChildren(deptChildren));
}
}
}
}
return deptIds;
} public List<Long> getDeptChildren(List<Dept> deptList) {
List<Long> list = new ArrayList<>();
deptList.forEach(dept -> {
if (dept != null && dept.getEnabled()) {
List<Dept> depts = deptService.findByPid(dept.getId());
if (deptList.size() != 0) {
list.addAll(getDeptChildren(depts));
}
list.add(dept.getId());
}
}
);
return list;
}
}
package co.fuyond.config;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;/**
* MybatisPlus配置
*/
@Configuration(proxyBeanMethods = false)
public class MybatisPlusConfig {
/**
* mybatis-plus分页插件
*/
@Bean
public MybatisPlusInterceptor mybatisPlusInterceptor() {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
return interceptor;
}
}
package co.fuyond.config;import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;/**
* @author: ZhangHouYing
*/
@Configuration(proxyBeanMethods = false)
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
}package co.fuyond.config.thread;import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;import java.util.concurrent.Executor;
import java.util.concurrent.ThreadPoolExecutor;/**
* 异步任务线程池装配类
*
* @author https://juejin.im/entry/5abb8f6951882555677e9da2
*/
@Slf4j
@Configuration(proxyBeanMethods = false)
public class AsyncTaskExecutePool implements AsyncConfigurer {
/**
* 注入配置类
*/
private final AsyncTaskProperties config; public AsyncTaskExecutePool(AsyncTaskProperties config) {
this.config = config;
} @Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//核心线程池大小
executor.setCorePoolSize(config.getCorePoolSize());
//最大线程数
executor.setMaxPoolSize(config.getMaxPoolSize());
//队列容量
executor.setQueueCapacity(config.getQueueCapacity());
//活跃时间
executor.setKeepAliveSeconds(config.getKeepAliveSeconds());
//线程名字前缀
executor.setThreadNamePrefix("el-async-");
// setRejectedExecutionHandler:当pool已经达到max size的时候,如何处理新任务
// CallerRunsPolicy:不在新线程中执行任务,而是由调用者所在的线程来执行
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
executor.initialize();
return executor;
} @Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return (throwable, method, objects) -> {
log.error("====" + throwable.getMessage() + "====", throwable);
log.error("exception method:" + method.getName());
};
}
}package co.fuyond.config.thread;import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;/**
* 线程池配置属性类
*
* @author https://juejin.im/entry/5abb8f6951882555677e9da2
*/
@Data
@Component
@ConfigurationProperties(prefix = "task.pool")
public class AsyncTaskProperties {
private int corePoolSize;
private int maxPoolSize;
private int keepAliveSeconds;
private int queueCapacity;
}package co.fuyond.config.thread;import org.springframework.stereotype.Component;import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;@Component
public class TheadFactoryName implements ThreadFactory {
private static final AtomicInteger POOL_NUMBER = new AtomicInteger(1);
private final ThreadGroup group;
private final AtomicInteger threadNumber = new AtomicInteger(1);
private final String namePrefix; public TheadFactoryName() {
this("el-pool");
} private TheadFactoryName(String name) {
SecurityManager s = System.getSecurityManager();
group = (s != null) ? s.getThreadGroup() :
Thread.currentThread().getThreadGroup();
//此时namePrefix就是 name + 第几个用这个工厂创建线程池的
this.namePrefix = name +
POOL_NUMBER.getAndIncrement();
} @Override
public Thread newThread(Runnable r) {
//此时线程的名字 就是 namePrefix + -thread- + 这个线程池中第几个执行的线程
Thread t = new Thread(group, r,
namePrefix + "-thread-" + threadNumber.getAndIncrement(),
0);
if (t.isDaemon()) {
t.setDaemon(false);
}
if (t.getPriority() != Thread.NORM_PRIORITY) {
t.setPriority(Thread.NORM_PRIORITY);
}
return t;
}
}package co.fuyond.config.thread;import co.fuyond.utils.SpringContextHolder;import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;public class ThreadPoolExecutorUtil {
public static ThreadPoolExecutor getPoll() {
AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class);
return new ThreadPoolExecutor(
properties.getCorePoolSize(),
properties.getMaxPoolSize(),
properties.getKeepAliveSeconds(),
TimeUnit.SECONDS,
new ArrayBlockingQueue<>(properties.getQueueCapacity()),
new TheadFactoryName()
);
}
}
package co.fuyond.controller;
import co.fuyond.domain.HrAgreement; import co.fuyond.domain.PageResult; import co.fuyond.dozer.service.IGenerator; import co.fuyond.dto.HrAgreementDto; import co.fuyond.dto.HrAgreementQueryCriteria; import co.fuyond.modules.logging.aop.log.Log; import co.fuyond.service.HrAgreementService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Arrays;
/**
* @author liutao
* @createDate 2023-03-27 13:24:00
*/@AllArgsConstructor@Api(tags = "WEBhr_agreement管理")@RestController@RequestMapping("/api/hrAgreement")public class HrAgreementController {
private final IGenerator generator; @Autowired private HrAgreementService hrAgreementService;
@Log("导出数据") @ApiOperation("导出数据") @GetMapping(value = "/download") @PreAuthorize("@el.check('admin','hrAgreement:list')") public void download(HttpServletResponse response, HrAgreementQueryCriteria criteria) throws IOException { hrAgreementService.download(generator.convert(hrAgreementService.queryAll(criteria), HrAgreementDto.class), response); }
@GetMapping @Log("查询hr_agreement") @ApiOperation("查询hr_agreement") @PreAuthorize("@el.check('admin','hrAgreement:list')") public ResponseEntity<PageResult<HrAgreementDto>> getHrAgreements(HrAgreementQueryCriteria criteria, Pageable pageable) { return new ResponseEntity<>(hrAgreementService.queryAll(criteria, pageable), HttpStatus.OK); }
@PostMapping @Log("新增hr_agreement") @ApiOperation("新增hr_agreement") @PreAuthorize("@el.check('admin','hrAgreement:add')") public ResponseEntity<Object> create(@Validated @RequestBody HrAgreement resources) { return new ResponseEntity<>(hrAgreementService.save(resources), HttpStatus.CREATED); }
@PutMapping @Log("修改hr_agreement") @ApiOperation("修改hr_agreement") @PreAuthorize("@el.check('admin','hrAgreement:edit')") public ResponseEntity<Object> update(@Validated @RequestBody HrAgreement resources) { hrAgreementService.updateById(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); }
@Log("删除hr_agreement") @ApiOperation("删除hr_agreement") @PreAuthorize("@el.check('admin','hrAgreement:del')") @DeleteMapping public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) { Arrays.asList(ids).forEach(id -> { hrAgreementService.removeById(id); }); return new ResponseEntity<>(HttpStatus.OK); }}package co.fuyond.controller;
import co.fuyond.domain.HrBanner; import co.fuyond.domain.PageResult; import co.fuyond.dozer.service.IGenerator; import co.fuyond.dto.HrBannerDto; import co.fuyond.dto.HrBannerQueryCriteria; import co.fuyond.modules.logging.aop.log.Log; import co.fuyond.service.HrBannerService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.AllArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Arrays;
/**
* @author liutao
* @createDate 2023-03-27 13:24:00
*/@AllArgsConstructor@Api(tags = "hr_banner管理")@RestController@RequestMapping("/api/hrBanner")public class HrBannerController {
private final IGenerator generator; @Autowired private HrBannerService hrBannerService;
@Log("导出数据") @ApiOperation("导出数据") @GetMapping(value = "/download") @PreAuthorize("@el.check('admin','hrBanner:list')") public void download(HttpServletResponse response, HrBannerQueryCriteria criteria) throws IOException { hrBannerService.download(generator.convert(hrBannerService.queryAll(criteria), HrBannerDto.class), response); }
@GetMapping @Log("查询hr_banner") @ApiOperation("查询hr_banner") @PreAuthorize("@el.check('admin','hrBanner:list')") public ResponseEntity<PageResult<HrBannerDto>> getHrBanners(HrBannerQueryCriteria criteria, Pageable pageable) { return new ResponseEntity<>(hrBannerService.queryAll(criteria, pageable), HttpStatus.OK); }
@PostMapping @Log("新增hr_banner") @ApiOperation("新增hr_banner") @PreAuthorize("@el.check('admin','hrBanner:add')") public ResponseEntity<Object> create(@Validated @RequestBody HrBanner resources) { return new ResponseEntity<>(hrBannerService.save(resources), HttpStatus.CREATED); }
@PutMapping @Log("修改hr_banner") @ApiOperation("修改hr_banner") @PreAuthorize("@el.check('admin','hrBanner:edit')") public ResponseEntity<Object> update(@Validated @RequestBody HrBanner resources) { hrBannerService.updateById(resources); return new ResponseEntity<>(HttpStatus.NO_CONTENT); }
@Log("删除hr_banner") @ApiOperation("删除hr_banner") @PreAuthorize("@el.check('admin','hrBanner:del')") @DeleteMapping public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) { Arrays.asList(ids).forEach(id -> { hrBannerService.removeById(id); }); return new ResponseEntity<>(HttpStatus.OK); }}
package co.fuyond.controller;import co.fuyond.domain.HrDelivery;
import co.fuyond.domain.PageResult;
import co.fuyond.dozer.service.IGenerator;
import co.fuyond.dto.HrDeliveryDto;
import co.fuyond.dto.HrDeliveryQueryCriteria;
import co.fuyond.dto.HrResumeDto;
import co.fuyond.dto.HrResumeQueryCriteria;
import co.fuyond.modules.logging.aop.log.Log;
import co.fuyond.modules.security.security.vo.JwtUser;
import co.fuyond.service.HrDeliveryService;
import co.fuyond.service.HrResumeService;
import co.fuyond.vo.HrStudentResumeVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;/**
* @author liutao
* @createDate 2023-03-27 13:24:00
*/
@AllArgsConstructor
@Api(tags = "WEB简历投递管理")
@RestController
@RequestMapping("/api/hrDelivery")
public class HrDeliveryController {
private final IGenerator generator;
@Autowired
private HrDeliveryService hrDeliveryService;
@Autowired
private HrResumeService hrResumeService; @Log("导出数据")
@ApiOperation("web导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('admin','hrDelivery:list')")
public void download(HttpServletResponse response, HrDeliveryQueryCriteria criteria) throws IOException {
hrDeliveryService.download(generator.convert(hrDeliveryService.queryAll(criteria), HrDeliveryDto.class), response);
} @GetMapping
@Log("查询hr_delivery")
@ApiOperation("web查询hr_delivery")
@PreAuthorize("@el.check('admin','hrDelivery:list')")
public ResponseEntity<PageResult<HrDeliveryDto>> getHrDeliverys(HrDeliveryQueryCriteria criteria, Pageable pageable) {
return new ResponseEntity<>(hrDeliveryService.queryAll(criteria, pageable), HttpStatus.OK);
} @PostMapping
@Log("新增hr_delivery")
@ApiOperation("web新增hr_delivery")
@PreAuthorize("@el.check('admin','hrDelivery:add')")
public ResponseEntity<Object> create(@Validated @RequestBody HrDelivery resources) {
return new ResponseEntity<>(hrDeliveryService.save(resources), HttpStatus.CREATED);
} @PutMapping
@Log("修改hr_delivery")
@ApiOperation("web修改hr_delivery")
@PreAuthorize("@el.check('admin','hrDelivery:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody HrDelivery resources) {
hrDeliveryService.updateById(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} @Log("删除hr_delivery")
@ApiOperation("web删除hr_delivery")
@PreAuthorize("@el.check('admin','hrDelivery:del')")
@DeleteMapping
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
Arrays.asList(ids).forEach(id -> {
hrDeliveryService.removeById(id);
});
return new ResponseEntity<>(HttpStatus.OK);
} /**
* 获取单个简历详细信息
*
* @param resumeId 简历id
* @return 简历全部信息
*/
@GetMapping("/studentResumeInfo")
@PreAuthorize("@el.check('admin','hrDelivery:list')")
public ResponseEntity<HrStudentResumeVo> getStudentResumesInfo(@RequestParam Long resumeId) {
HrStudentResumeVo resumeVo = hrResumeService.getStudentResumesInfo(resumeId);
return new ResponseEntity<>(resumeVo, HttpStatus.OK);
} /**
* 获取当前企业收到的简历
*
* @param userDetails 当前登录信息
* @param pageable 分页参数
* @param criteria 查询条件
* @return 简历信息
*/
@GetMapping("/studentResume")
@PreAuthorize("@el.check('admin','hrDelivery:list')")
public ResponseEntity<PageResult<HrResumeDto>> getStudentResumes(@AuthenticationPrincipal UserDetails userDetails, Pageable pageable, HrResumeQueryCriteria criteria) {
JwtUser user = (JwtUser) userDetails;
if (user.getEnterpriseAuthentication().equals(1)) {
return new ResponseEntity<>(hrDeliveryService.getStudentResumesByEnterpriseId(user.getEnterpriseInfoId(), criteria, pageable), HttpStatus.OK);
}
return null;
} /**
* 根据招聘id获取招聘下所有简历信息
*
* @param employmentId 招聘id
* @return 简历信息
*/
@GetMapping("/getResumeByEmploymentId")
@PreAuthorize("@el.check('admin','hrDelivery:list')")
public ResponseEntity<List<HrStudentResumeVo>> getResumeByEmploymentId(@RequestParam Long employmentId) {
ArrayList<HrStudentResumeVo> resumeVos = hrResumeService.getResumeInfoByEmploymentId(employmentId);
return new ResponseEntity<>(resumeVos, HttpStatus.OK);
}
}package co.fuyond.controller;import co.fuyond.domain.HrEmployment;
import co.fuyond.domain.PageResult;
import co.fuyond.dozer.service.IGenerator;
import co.fuyond.dto.HrEmploymentDto;
import co.fuyond.dto.HrEmploymentEnterpriseInfoDto;
import co.fuyond.dto.HrEmploymentQueryCriteria;
import co.fuyond.modules.logging.aop.log.Log;
import co.fuyond.modules.security.security.vo.JwtUser;
import co.fuyond.service.HrEmploymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;/**
* @author liutao
* @createDate 2023-03-27 13:24:00
*/
@AllArgsConstructor
@Api(tags = "WEB招聘信息管理")
@RestController
@RequestMapping("/api/hrEmployment")
public class HrEmploymentController {
private final IGenerator generator;
@Autowired
private HrEmploymentService hrEmploymentService; @Log("导出数据")
@ApiOperation("web导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('admin','hrEmployment:list')")
public void download(HttpServletResponse response, HrEmploymentQueryCriteria criteria) throws IOException {
hrEmploymentService.download(generator.convert(hrEmploymentService.queryAll(criteria), HrEmploymentDto.class), response);
} @GetMapping
@Log("查询hr_employment")
@ApiOperation("web查询hr_employment")
@PreAuthorize("@el.check('admin','hrEmployment:list')")
public ResponseEntity<PageResult<HrEmploymentDto>> getHrEmployments(HrEmploymentQueryCriteria criteria, Pageable pageable) {
return new ResponseEntity<>(hrEmploymentService.queryAll(criteria, pageable), HttpStatus.OK);
} @PostMapping
@Log("新增hr_employment")
@ApiOperation("web新增hr_employment")
@PreAuthorize("@el.check('admin','hrEmployment:add')")
public ResponseEntity<Object> create(@Validated @RequestBody HrEmployment resources, @AuthenticationPrincipal UserDetails userDetails) {
JwtUser user = (JwtUser) userDetails;
resources.setEnterpriseInfoId(user.getEnterpriseInfoId());
return new ResponseEntity<>(hrEmploymentService.save(resources), HttpStatus.CREATED);
} @PutMapping
@Log("修改hr_employment")
@ApiOperation("web修改hr_employment")
@PreAuthorize("@el.check('admin','hrEmployment:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody HrEmployment resources) {
hrEmploymentService.updateById(resources);
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
} @Log("删除hr_employment")
@ApiOperation("web删除hr_employment")
@PreAuthorize("@el.check('admin','hrEmployment:del')")
@DeleteMapping
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
Arrays.asList(ids).forEach(id -> {
hrEmploymentService.delById(id);
});
return new ResponseEntity<>(HttpStatus.OK);
} /**
* web获取招聘信息和企业部分信息
*
* @param name 搜索招聘/企业名字
* @param pageable 分页参数
* @return
*/
@GetMapping("/getInfo")
@PreAuthorize("@el.check('admin','hrEmployment:list')")
public ResponseEntity<PageResult<HrEmploymentEnterpriseInfoDto>> getAndEnterpriseInfo(String name, Pageable pageable) {
return new ResponseEntity<>(hrEmploymentService.findAndEnterpriseInfo(name, pageable), HttpStatus.OK);
}
}package co.fuyond.controller;import co.fuyond.domain.HrEnterpriseInfo;
import co.fuyond.domain.PageResult;
import co.fuyond.dozer.service.IGenerator;
import co.fuyond.dto.HrEnterpriseInfoDto;
import co.fuyond.dto.HrEnterpriseInfoQueryCriteria;
import co.fuyond.modules.logging.aop.log.Log;
import co.fuyond.modules.security.security.vo.JwtUser;
import co.fuyond.modules.system.domain.User;
import co.fuyond.modules.system.domain.UsersRoles;
import co.fuyond.modules.system.service.UserService;
import co.fuyond.modules.system.service.UsersRolesService;
import co.fuyond.service.HrEnterpriseInfoService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;/**
* @author liutao
* @createDate 2023-03-27 13:24:00
*/
@AllArgsConstructor
@Api(tags = "WEB企业信息管理")
@RestController
@RequestMapping("/api/hrEnterpriseInfo")
public class HrEnterpriseInfoController {
private final IGenerator generator;
@Autowired
private HrEnterpriseInfoService hrEnterpriseInfoService;
@Autowired
private UserService userService;
@Autowired
private UsersRolesService usersRolesService; @Log("导出数据")
@ApiOperation("web导出数据")
@GetMapping(value = "/download")
@PreAuthorize("@el.check('admin','hrEnterpriseInfo:list')")
public void download(HttpServletResponse response, HrEnterpriseInfoQueryCriteria criteria) throws IOException {
hrEnterpriseInfoService.download(generator.convert(hrEnterpriseInfoService.queryAll(criteria), HrEnterpriseInfoDto.class), response);
} @GetMapping
@Log("查询hr_enterprise_info")
@ApiOperation("web查询hr_enterprise_info")
@PreAuthorize("@el.check('admin','hrEnterpriseInfo:list')")
public ResponseEntity<PageResult<HrEnterpriseInfoDto>> getHrEnterpriseInfos(HrEnterpriseInfoQueryCriteria criteria, Pageable pageable) {
PageResult<HrEnterpriseInfoDto> pageResult = hrEnterpriseInfoService.queryAll(criteria, pageable);
for (HrEnterpriseInfoDto dto : pageResult.getContent()) {
User user = userService.getOne(new QueryWrapper<User>().eq("enterprise_info_id", dto.getId()).select("id", "enterprise_authentication"));
if (user != null && user.getEnterpriseAuthentication() != null) {
dto.setEnterpriseAuthentication(user.getEnterpriseAuthentication());
}
}
return new ResponseEntity<>(pageResult, HttpStatus.OK);
} @PostMapping
@Log("新增hr_enterprise_info")
@ApiOperation("web新增hr_enterprise_info")
@PreAuthorize("@el.check('admin','hrEnterpriseInfo:add')")
public ResponseEntity<Object> create(@Validated @RequestBody HrEnterpriseInfo resources) {
return new ResponseEntity<>(hrEnterpriseInfoService.save(resources), HttpStatus.CREATED);
} @PutMapping
@Log("修改hr_enterprise_info")
@ApiOperation("web修改hr_enterprise_info")
@PreAuthorize("@el.check('admin','hrEnterpriseInfo:edit')")
public ResponseEntity<Object> update(@Validated @RequestBody HrEnterpriseInfo resources) {
hrEnterpriseInfoService.updateById(resources);
return new ResponseEn