mirror of https://github.com/elunez/eladmin
代码优化
parent
a9e12b5ccd
commit
900ca221a9
|
@ -26,13 +26,13 @@ public class GenConfigController {
|
||||||
|
|
||||||
@ApiOperation("查询")
|
@ApiOperation("查询")
|
||||||
@GetMapping(value = "/{tableName}")
|
@GetMapping(value = "/{tableName}")
|
||||||
public ResponseEntity get(@PathVariable String tableName){
|
public ResponseEntity<Object> get(@PathVariable String tableName){
|
||||||
return new ResponseEntity<>(genConfigService.find(tableName), HttpStatus.OK);
|
return new ResponseEntity<>(genConfigService.find(tableName), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("修改")
|
@ApiOperation("修改")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public ResponseEntity emailConfig(@Validated @RequestBody GenConfig genConfig){
|
public ResponseEntity<Object> emailConfig(@Validated @RequestBody GenConfig genConfig){
|
||||||
return new ResponseEntity<>(genConfigService.update(genConfig.getTableName(), genConfig),HttpStatus.OK);
|
return new ResponseEntity<>(genConfigService.update(genConfig.getTableName(), genConfig),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,13 +38,13 @@ public class GeneratorController {
|
||||||
|
|
||||||
@ApiOperation("查询数据库数据")
|
@ApiOperation("查询数据库数据")
|
||||||
@GetMapping(value = "/tables/all")
|
@GetMapping(value = "/tables/all")
|
||||||
public ResponseEntity getTables(){
|
public ResponseEntity<Object> getTables(){
|
||||||
return new ResponseEntity<>(generatorService.getTables(), HttpStatus.OK);
|
return new ResponseEntity<>(generatorService.getTables(), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("查询数据库数据")
|
@ApiOperation("查询数据库数据")
|
||||||
@GetMapping(value = "/tables")
|
@GetMapping(value = "/tables")
|
||||||
public ResponseEntity getTables(@RequestParam(defaultValue = "") String name,
|
public ResponseEntity<Object> getTables(@RequestParam(defaultValue = "") String name,
|
||||||
@RequestParam(defaultValue = "0")Integer page,
|
@RequestParam(defaultValue = "0")Integer page,
|
||||||
@RequestParam(defaultValue = "10")Integer size){
|
@RequestParam(defaultValue = "10")Integer size){
|
||||||
int[] startEnd = PageUtil.transToStartEnd(page+1, size);
|
int[] startEnd = PageUtil.transToStartEnd(page+1, size);
|
||||||
|
@ -53,7 +53,7 @@ public class GeneratorController {
|
||||||
|
|
||||||
@ApiOperation("查询字段数据")
|
@ApiOperation("查询字段数据")
|
||||||
@GetMapping(value = "/columns")
|
@GetMapping(value = "/columns")
|
||||||
public ResponseEntity getTables(@RequestParam String tableName){
|
public ResponseEntity<Object> getTables(@RequestParam String tableName){
|
||||||
List<ColumnInfo> columnInfos = generatorService.getColumns(tableName);
|
List<ColumnInfo> columnInfos = generatorService.getColumns(tableName);
|
||||||
// 异步同步表信息
|
// 异步同步表信息
|
||||||
generatorService.sync(columnInfos);
|
generatorService.sync(columnInfos);
|
||||||
|
@ -62,14 +62,14 @@ public class GeneratorController {
|
||||||
|
|
||||||
@ApiOperation("保存字段数据")
|
@ApiOperation("保存字段数据")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public ResponseEntity save(@RequestBody List<ColumnInfo> columnInfos){
|
public ResponseEntity<HttpStatus> save(@RequestBody List<ColumnInfo> columnInfos){
|
||||||
generatorService.save(columnInfos);
|
generatorService.save(columnInfos);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("生成代码")
|
@ApiOperation("生成代码")
|
||||||
@PostMapping(value = "/{tableName}/{type}")
|
@PostMapping(value = "/{tableName}/{type}")
|
||||||
public ResponseEntity generator(@PathVariable String tableName, @PathVariable Integer type, HttpServletRequest request, HttpServletResponse response){
|
public ResponseEntity<Object> generator(@PathVariable String tableName, @PathVariable Integer type, HttpServletRequest request, HttpServletResponse response){
|
||||||
if(!generatorEnabled && type == 0){
|
if(!generatorEnabled && type == 0){
|
||||||
throw new BadRequestException("此环境不允许生成代码,请选择预览或者下载查看!");
|
throw new BadRequestException("此环境不允许生成代码,请选择预览或者下载查看!");
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,6 @@ public class GeneratorController {
|
||||||
break;
|
break;
|
||||||
default: throw new BadRequestException("没有这个选项");
|
default: throw new BadRequestException("没有这个选项");
|
||||||
}
|
}
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,14 +61,14 @@ public interface GeneratorService {
|
||||||
* @param columns 字段信息
|
* @param columns 字段信息
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
ResponseEntity preview(GenConfig genConfig, List<ColumnInfo> columns);
|
ResponseEntity<Object> preview(GenConfig genConfig, List<ColumnInfo> columns);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打包下载
|
* 打包下载
|
||||||
* @param genConfig 配置信息
|
* @param genConfig 配置信息
|
||||||
* @param columns 字段信息
|
* @param columns 字段信息
|
||||||
* @param request
|
* @param request /
|
||||||
* @param response
|
* @param response /
|
||||||
*/
|
*/
|
||||||
void download(GenConfig genConfig, List<ColumnInfo> columns, HttpServletRequest request, HttpServletResponse response);
|
void download(GenConfig genConfig, List<ColumnInfo> columns, HttpServletRequest request, HttpServletResponse response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,9 @@ public interface LogRepository extends JpaRepository<Log,Long>, JpaSpecification
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据日志类型删除信息
|
* 根据日志类型删除信息
|
||||||
* @param logType
|
* @param logType 日志类型
|
||||||
*/
|
*/
|
||||||
@Query(nativeQuery = true,value = "delete from log where log_type = ?1")
|
@Query(nativeQuery = true,value = "delete from log where log_type = ?1")
|
||||||
@Modifying
|
@Modifying
|
||||||
@Transactional
|
|
||||||
void deleteByLogType(String logType);
|
void deleteByLogType(String logType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -50,14 +49,14 @@ public class LogController {
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("日志查询")
|
@ApiOperation("日志查询")
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity getLogs(LogQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getLogs(LogQueryCriteria criteria, Pageable pageable){
|
||||||
criteria.setLogType("INFO");
|
criteria.setLogType("INFO");
|
||||||
return new ResponseEntity<>(logService.queryAll(criteria,pageable), HttpStatus.OK);
|
return new ResponseEntity<>(logService.queryAll(criteria,pageable), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/user")
|
@GetMapping(value = "/user")
|
||||||
@ApiOperation("用户日志查询")
|
@ApiOperation("用户日志查询")
|
||||||
public ResponseEntity getUserLogs(LogQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getUserLogs(LogQueryCriteria criteria, Pageable pageable){
|
||||||
criteria.setLogType("INFO");
|
criteria.setLogType("INFO");
|
||||||
criteria.setBlurry(SecurityUtils.getUsername());
|
criteria.setBlurry(SecurityUtils.getUsername());
|
||||||
return new ResponseEntity<>(logService.queryAllByUser(criteria,pageable), HttpStatus.OK);
|
return new ResponseEntity<>(logService.queryAllByUser(criteria,pageable), HttpStatus.OK);
|
||||||
|
@ -66,7 +65,7 @@ public class LogController {
|
||||||
@GetMapping(value = "/error")
|
@GetMapping(value = "/error")
|
||||||
@ApiOperation("错误日志查询")
|
@ApiOperation("错误日志查询")
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity getErrorLogs(LogQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getErrorLogs(LogQueryCriteria criteria, Pageable pageable){
|
||||||
criteria.setLogType("ERROR");
|
criteria.setLogType("ERROR");
|
||||||
return new ResponseEntity<>(logService.queryAll(criteria,pageable), HttpStatus.OK);
|
return new ResponseEntity<>(logService.queryAll(criteria,pageable), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
@ -74,24 +73,24 @@ public class LogController {
|
||||||
@GetMapping(value = "/error/{id}")
|
@GetMapping(value = "/error/{id}")
|
||||||
@ApiOperation("日志异常详情查询")
|
@ApiOperation("日志异常详情查询")
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity getErrorLogs(@PathVariable Long id){
|
public ResponseEntity<Object> getErrorLogs(@PathVariable Long id){
|
||||||
return new ResponseEntity<>(logService.findByErrDetail(id), HttpStatus.OK);
|
return new ResponseEntity<>(logService.findByErrDetail(id), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
@DeleteMapping(value = "/del/error")
|
@DeleteMapping(value = "/del/error")
|
||||||
@Log("删除所有ERROR日志")
|
@Log("删除所有ERROR日志")
|
||||||
@ApiOperation("删除所有ERROR日志")
|
@ApiOperation("删除所有ERROR日志")
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity delAllByError(){
|
public ResponseEntity<Object> delAllByError(){
|
||||||
logService.delAllByError();
|
logService.delAllByError();
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping(value = "/del/info")
|
@DeleteMapping(value = "/del/info")
|
||||||
@Log("删除所有INFO日志")
|
@Log("删除所有INFO日志")
|
||||||
@ApiOperation("删除所有INFO日志")
|
@ApiOperation("删除所有INFO日志")
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity delAllByInfo(){
|
public ResponseEntity<Object> delAllByInfo(){
|
||||||
logService.delAllByInfo();
|
logService.delAllByInfo();
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,7 +183,8 @@ public class DeployServiceImpl implements DeployService {
|
||||||
private void backupApp(ExecuteShellUtil executeShellUtil, String ip, String fileSavePath, String appName, String backupPath, Long id) {
|
private void backupApp(ExecuteShellUtil executeShellUtil, String ip, String fileSavePath, String appName, String backupPath, Long id) {
|
||||||
String deployDate = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN);
|
String deployDate = DateUtil.format(new Date(), DatePattern.PURE_DATETIME_PATTERN);
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
if (!backupPath.endsWith(FILE_SEPARATOR)&&!backupPath.endsWith("\\")) {
|
String endsWith = "\\";
|
||||||
|
if (!backupPath.endsWith(FILE_SEPARATOR)&&!backupPath.endsWith(endsWith)) {
|
||||||
backupPath += FILE_SEPARATOR;
|
backupPath += FILE_SEPARATOR;
|
||||||
}
|
}
|
||||||
backupPath += appName + FILE_SEPARATOR + deployDate + "\n";
|
backupPath += appName + FILE_SEPARATOR + deployDate + "\n";
|
||||||
|
@ -259,8 +260,7 @@ public class DeployServiceImpl implements DeployService {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkFile(ExecuteShellUtil executeShellUtil, AppDto appDTO) {
|
private boolean checkFile(ExecuteShellUtil executeShellUtil, AppDto appDTO) {
|
||||||
StringBuilder sb = new StringBuilder("find ").append(appDTO.getDeployPath()).append(" -name ").append(appDTO.getName());
|
String result = executeShellUtil.executeForResult("find " + appDTO.getDeployPath() + " -name " + appDTO.getName());
|
||||||
String result = executeShellUtil.executeForResult(sb.toString());
|
|
||||||
return result.indexOf("/tcp:")>0;
|
return result.indexOf("/tcp:")>0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ServerController {
|
||||||
@Log("查询服务监控")
|
@Log("查询服务监控")
|
||||||
@ApiOperation("查询服务监控")
|
@ApiOperation("查询服务监控")
|
||||||
@PreAuthorize("@el.check('server:list')")
|
@PreAuthorize("@el.check('server:list')")
|
||||||
public ResponseEntity getServers(ServerQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getServers(ServerQueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity<>(serverService.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity<>(serverService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ public class ServerController {
|
||||||
@Log("新增服务监控")
|
@Log("新增服务监控")
|
||||||
@ApiOperation("新增服务监控")
|
@ApiOperation("新增服务监控")
|
||||||
@PreAuthorize("@el.check('server:add')")
|
@PreAuthorize("@el.check('server:add')")
|
||||||
public ResponseEntity create(@Validated @RequestBody Server resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody Server resources){
|
||||||
return new ResponseEntity<>(serverService.create(resources),HttpStatus.CREATED);
|
return new ResponseEntity<>(serverService.create(resources),HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,9 +48,9 @@ public class ServerController {
|
||||||
@Log("修改服务监控")
|
@Log("修改服务监控")
|
||||||
@ApiOperation("修改服务监控")
|
@ApiOperation("修改服务监控")
|
||||||
@PreAuthorize("@el.check('server:edit')")
|
@PreAuthorize("@el.check('server:edit')")
|
||||||
public ResponseEntity update(@Validated @RequestBody Server resources){
|
public ResponseEntity<Object> update(@Validated @RequestBody Server resources){
|
||||||
serverService.update(resources);
|
serverService.update(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
|
|
|
@ -28,20 +28,20 @@ public class VisitsController {
|
||||||
|
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("创建访问记录")
|
@ApiOperation("创建访问记录")
|
||||||
public ResponseEntity create(){
|
public ResponseEntity<Object> create(){
|
||||||
visitsService.count(RequestHolder.getHttpServletRequest());
|
visitsService.count(RequestHolder.getHttpServletRequest());
|
||||||
return new ResponseEntity(HttpStatus.CREATED);
|
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("查询")
|
@ApiOperation("查询")
|
||||||
public ResponseEntity get(){
|
public ResponseEntity<Object> get(){
|
||||||
return new ResponseEntity<>(visitsService.get(),HttpStatus.OK);
|
return new ResponseEntity<>(visitsService.get(),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/chartData")
|
@GetMapping(value = "/chartData")
|
||||||
@ApiOperation("查询图表数据")
|
@ApiOperation("查询图表数据")
|
||||||
public ResponseEntity getChartData(){
|
public ResponseEntity<Object> getChartData(){
|
||||||
return new ResponseEntity<>(visitsService.getChartData(),HttpStatus.OK);
|
return new ResponseEntity<>(visitsService.getChartData(),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class QuartzJobController {
|
||||||
@ApiOperation("查询定时任务")
|
@ApiOperation("查询定时任务")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('timing:list')")
|
@PreAuthorize("@el.check('timing:list')")
|
||||||
public ResponseEntity getJobs(JobQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getJobs(JobQueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity<>(quartzJobService.queryAll(criteria,pageable), HttpStatus.OK);
|
return new ResponseEntity<>(quartzJobService.queryAll(criteria,pageable), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class QuartzJobController {
|
||||||
@ApiOperation("查询任务执行日志")
|
@ApiOperation("查询任务执行日志")
|
||||||
@GetMapping(value = "/logs")
|
@GetMapping(value = "/logs")
|
||||||
@PreAuthorize("@el.check('timing:list')")
|
@PreAuthorize("@el.check('timing:list')")
|
||||||
public ResponseEntity getJobLogs(JobQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getJobLogs(JobQueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity<>(quartzJobService.queryAllLog(criteria,pageable), HttpStatus.OK);
|
return new ResponseEntity<>(quartzJobService.queryAllLog(criteria,pageable), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ public class QuartzJobController {
|
||||||
@ApiOperation("新增定时任务")
|
@ApiOperation("新增定时任务")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('timing:add')")
|
@PreAuthorize("@el.check('timing:add')")
|
||||||
public ResponseEntity create(@Validated @RequestBody QuartzJob resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody QuartzJob resources){
|
||||||
if (resources.getId() != null) {
|
if (resources.getId() != null) {
|
||||||
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
||||||
}
|
}
|
||||||
|
@ -82,35 +82,35 @@ public class QuartzJobController {
|
||||||
@ApiOperation("修改定时任务")
|
@ApiOperation("修改定时任务")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@PreAuthorize("@el.check('timing:edit')")
|
@PreAuthorize("@el.check('timing:edit')")
|
||||||
public ResponseEntity update(@Validated(QuartzJob.Update.class) @RequestBody QuartzJob resources){
|
public ResponseEntity<Object> update(@Validated(QuartzJob.Update.class) @RequestBody QuartzJob resources){
|
||||||
quartzJobService.update(resources);
|
quartzJobService.update(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("更改定时任务状态")
|
@Log("更改定时任务状态")
|
||||||
@ApiOperation("更改定时任务状态")
|
@ApiOperation("更改定时任务状态")
|
||||||
@PutMapping(value = "/{id}")
|
@PutMapping(value = "/{id}")
|
||||||
@PreAuthorize("@el.check('timing:edit')")
|
@PreAuthorize("@el.check('timing:edit')")
|
||||||
public ResponseEntity updateIsPause(@PathVariable Long id){
|
public ResponseEntity<Object> updateIsPause(@PathVariable Long id){
|
||||||
quartzJobService.updateIsPause(quartzJobService.findById(id));
|
quartzJobService.updateIsPause(quartzJobService.findById(id));
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("执行定时任务")
|
@Log("执行定时任务")
|
||||||
@ApiOperation("执行定时任务")
|
@ApiOperation("执行定时任务")
|
||||||
@PutMapping(value = "/exec/{id}")
|
@PutMapping(value = "/exec/{id}")
|
||||||
@PreAuthorize("@el.check('timing:edit')")
|
@PreAuthorize("@el.check('timing:edit')")
|
||||||
public ResponseEntity execution(@PathVariable Long id){
|
public ResponseEntity<Object> execution(@PathVariable Long id){
|
||||||
quartzJobService.execution(quartzJobService.findById(id));
|
quartzJobService.execution(quartzJobService.findById(id));
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("删除定时任务")
|
@Log("删除定时任务")
|
||||||
@ApiOperation("删除定时任务")
|
@ApiOperation("删除定时任务")
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
@PreAuthorize("@el.check('timing:del')")
|
@PreAuthorize("@el.check('timing:del')")
|
||||||
public ResponseEntity delete(@PathVariable Long id){
|
public ResponseEntity<Object> delete(@PathVariable Long id){
|
||||||
quartzJobService.delete(quartzJobService.findById(id));
|
quartzJobService.delete(quartzJobService.findById(id));
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class AuthController {
|
||||||
@ApiOperation("登录授权")
|
@ApiOperation("登录授权")
|
||||||
@AnonymousAccess
|
@AnonymousAccess
|
||||||
@PostMapping(value = "/login")
|
@PostMapping(value = "/login")
|
||||||
public ResponseEntity login(@Validated @RequestBody AuthUser authUser, HttpServletRequest request){
|
public ResponseEntity<Object> login(@Validated @RequestBody AuthUser authUser, HttpServletRequest request){
|
||||||
// 密码解密
|
// 密码解密
|
||||||
RSA rsa = new RSA(privateKey, null);
|
RSA rsa = new RSA(privateKey, null);
|
||||||
String password = new String(rsa.decrypt(authUser.getPassword(), KeyType.PrivateKey));
|
String password = new String(rsa.decrypt(authUser.getPassword(), KeyType.PrivateKey));
|
||||||
|
@ -108,7 +108,7 @@ public class AuthController {
|
||||||
|
|
||||||
@ApiOperation("获取用户信息")
|
@ApiOperation("获取用户信息")
|
||||||
@GetMapping(value = "/info")
|
@GetMapping(value = "/info")
|
||||||
public ResponseEntity getUserInfo(){
|
public ResponseEntity<Object> getUserInfo(){
|
||||||
JwtUser jwtUser = (JwtUser)userDetailsService.loadUserByUsername(SecurityUtils.getUsername());
|
JwtUser jwtUser = (JwtUser)userDetailsService.loadUserByUsername(SecurityUtils.getUsername());
|
||||||
return ResponseEntity.ok(jwtUser);
|
return ResponseEntity.ok(jwtUser);
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ public class AuthController {
|
||||||
@AnonymousAccess
|
@AnonymousAccess
|
||||||
@ApiOperation("获取验证码")
|
@ApiOperation("获取验证码")
|
||||||
@GetMapping(value = "/code")
|
@GetMapping(value = "/code")
|
||||||
public ResponseEntity getCode(){
|
public ResponseEntity<Object> getCode(){
|
||||||
// 算术类型 https://gitee.com/whvse/EasyCaptcha
|
// 算术类型 https://gitee.com/whvse/EasyCaptcha
|
||||||
ArithmeticCaptcha captcha = new ArithmeticCaptcha(111, 36);
|
ArithmeticCaptcha captcha = new ArithmeticCaptcha(111, 36);
|
||||||
// 几位数运算,默认是两位
|
// 几位数运算,默认是两位
|
||||||
|
@ -137,8 +137,8 @@ public class AuthController {
|
||||||
@ApiOperation("退出登录")
|
@ApiOperation("退出登录")
|
||||||
@AnonymousAccess
|
@AnonymousAccess
|
||||||
@DeleteMapping(value = "/logout")
|
@DeleteMapping(value = "/logout")
|
||||||
public ResponseEntity logout(HttpServletRequest request){
|
public ResponseEntity<Object> logout(HttpServletRequest request){
|
||||||
onlineUserService.logout(tokenProvider.getToken(request));
|
onlineUserService.logout(tokenProvider.getToken(request));
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class OnlineController {
|
||||||
@ApiOperation("查询在线用户")
|
@ApiOperation("查询在线用户")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity getAll(String filter, Pageable pageable){
|
public ResponseEntity<Object> getAll(String filter, Pageable pageable){
|
||||||
return new ResponseEntity<>(onlineUserService.getAll(filter, pageable),HttpStatus.OK);
|
return new ResponseEntity<>(onlineUserService.getAll(filter, pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ public class OnlineController {
|
||||||
@ApiOperation("踢出用户")
|
@ApiOperation("踢出用户")
|
||||||
@DeleteMapping(value = "/{key}")
|
@DeleteMapping(value = "/{key}")
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity delete(@PathVariable String key) throws Exception {
|
public ResponseEntity<Object> delete(@PathVariable String key) throws Exception {
|
||||||
onlineUserService.kickOut(key);
|
onlineUserService.kickOut(key);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,7 @@ public class OnlineUserService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测用户是否在之前已经登录,已经登录踢下线
|
* 检测用户是否在之前已经登录,已经登录踢下线
|
||||||
* @param userName
|
* @param userName 用户名
|
||||||
*/
|
*/
|
||||||
public void checkLoginOnUser(String userName, String igoreToken){
|
public void checkLoginOnUser(String userName, String igoreToken){
|
||||||
List<OnlineUser> onlineUsers = getAll(userName);
|
List<OnlineUser> onlineUsers = getAll(userName);
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -52,7 +51,7 @@ public class DeptController {
|
||||||
@ApiOperation("查询部门")
|
@ApiOperation("查询部门")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||||
public ResponseEntity getDepts(DeptQueryCriteria criteria){
|
public ResponseEntity<Object> getDepts(DeptQueryCriteria criteria){
|
||||||
// 数据权限
|
// 数据权限
|
||||||
criteria.setIds(dataScope.getDeptIds());
|
criteria.setIds(dataScope.getDeptIds());
|
||||||
List<DeptDto> deptDtos = deptService.queryAll(criteria);
|
List<DeptDto> deptDtos = deptService.queryAll(criteria);
|
||||||
|
@ -63,7 +62,7 @@ public class DeptController {
|
||||||
@ApiOperation("新增部门")
|
@ApiOperation("新增部门")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('dept:add')")
|
@PreAuthorize("@el.check('dept:add')")
|
||||||
public ResponseEntity create(@Validated @RequestBody Dept resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody Dept resources){
|
||||||
if (resources.getId() != null) {
|
if (resources.getId() != null) {
|
||||||
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
||||||
}
|
}
|
||||||
|
@ -74,21 +73,21 @@ public class DeptController {
|
||||||
@ApiOperation("修改部门")
|
@ApiOperation("修改部门")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@PreAuthorize("@el.check('dept:edit')")
|
@PreAuthorize("@el.check('dept:edit')")
|
||||||
public ResponseEntity update(@Validated(Dept.Update.class) @RequestBody Dept resources){
|
public ResponseEntity<Object> update(@Validated(Dept.Update.class) @RequestBody Dept resources){
|
||||||
deptService.update(resources);
|
deptService.update(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("删除部门")
|
@Log("删除部门")
|
||||||
@ApiOperation("删除部门")
|
@ApiOperation("删除部门")
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
@PreAuthorize("@el.check('dept:del')")
|
@PreAuthorize("@el.check('dept:del')")
|
||||||
public ResponseEntity delete(@PathVariable Long id){
|
public ResponseEntity<Object> delete(@PathVariable Long id){
|
||||||
try {
|
try {
|
||||||
deptService.delete(id);
|
deptService.delete(id);
|
||||||
}catch (Throwable e){
|
}catch (Throwable e){
|
||||||
ThrowableUtil.throwForeignKeyException(e, "该部门存在岗位或者角色关联,请取消关联后再试");
|
ThrowableUtil.throwForeignKeyException(e, "该部门存在岗位或者角色关联,请取消关联后再试");
|
||||||
}
|
}
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -46,7 +46,7 @@ public class DictController {
|
||||||
@ApiOperation("查询字典")
|
@ApiOperation("查询字典")
|
||||||
@GetMapping(value = "/all")
|
@GetMapping(value = "/all")
|
||||||
@PreAuthorize("@el.check('dict:list')")
|
@PreAuthorize("@el.check('dict:list')")
|
||||||
public ResponseEntity all(){
|
public ResponseEntity<Object> all(){
|
||||||
return new ResponseEntity<>(dictService.queryAll(new DictQueryCriteria()),HttpStatus.OK);
|
return new ResponseEntity<>(dictService.queryAll(new DictQueryCriteria()),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class DictController {
|
||||||
@ApiOperation("查询字典")
|
@ApiOperation("查询字典")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('dict:list')")
|
@PreAuthorize("@el.check('dict:list')")
|
||||||
public ResponseEntity getDicts(DictQueryCriteria resources, Pageable pageable){
|
public ResponseEntity<Object> getDicts(DictQueryCriteria resources, Pageable pageable){
|
||||||
return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK);
|
return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ public class DictController {
|
||||||
@ApiOperation("新增字典")
|
@ApiOperation("新增字典")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('dict:add')")
|
@PreAuthorize("@el.check('dict:add')")
|
||||||
public ResponseEntity create(@Validated @RequestBody Dict resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody Dict resources){
|
||||||
if (resources.getId() != null) {
|
if (resources.getId() != null) {
|
||||||
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
||||||
}
|
}
|
||||||
|
@ -73,17 +73,17 @@ public class DictController {
|
||||||
@ApiOperation("修改字典")
|
@ApiOperation("修改字典")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@PreAuthorize("@el.check('dict:edit')")
|
@PreAuthorize("@el.check('dict:edit')")
|
||||||
public ResponseEntity update(@Validated(Dict.Update.class) @RequestBody Dict resources){
|
public ResponseEntity<Object> update(@Validated(Dict.Update.class) @RequestBody Dict resources){
|
||||||
dictService.update(resources);
|
dictService.update(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("删除字典")
|
@Log("删除字典")
|
||||||
@ApiOperation("删除字典")
|
@ApiOperation("删除字典")
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
@PreAuthorize("@el.check('dict:del')")
|
@PreAuthorize("@el.check('dict:del')")
|
||||||
public ResponseEntity delete(@PathVariable Long id){
|
public ResponseEntity<Object> delete(@PathVariable Long id){
|
||||||
dictService.delete(id);
|
dictService.delete(id);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -38,7 +38,7 @@ public class DictDetailController {
|
||||||
@Log("查询字典详情")
|
@Log("查询字典详情")
|
||||||
@ApiOperation("查询字典详情")
|
@ApiOperation("查询字典详情")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity getDictDetails(DictDetailQueryCriteria criteria,
|
public ResponseEntity<Object> getDictDetails(DictDetailQueryCriteria criteria,
|
||||||
@PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
|
@PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
|
||||||
return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class DictDetailController {
|
||||||
@Log("查询多个字典详情")
|
@Log("查询多个字典详情")
|
||||||
@ApiOperation("查询多个字典详情")
|
@ApiOperation("查询多个字典详情")
|
||||||
@GetMapping(value = "/map")
|
@GetMapping(value = "/map")
|
||||||
public ResponseEntity getDictDetailMaps(DictDetailQueryCriteria criteria,
|
public ResponseEntity<Object> getDictDetailMaps(DictDetailQueryCriteria criteria,
|
||||||
@PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
|
@PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){
|
||||||
String[] names = criteria.getDictName().split(",");
|
String[] names = criteria.getDictName().split(",");
|
||||||
Map<String,Object> map = new HashMap<>(names.length);
|
Map<String,Object> map = new HashMap<>(names.length);
|
||||||
|
@ -61,7 +61,7 @@ public class DictDetailController {
|
||||||
@ApiOperation("新增字典详情")
|
@ApiOperation("新增字典详情")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('dict:add')")
|
@PreAuthorize("@el.check('dict:add')")
|
||||||
public ResponseEntity create(@Validated @RequestBody DictDetail resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody DictDetail resources){
|
||||||
if (resources.getId() != null) {
|
if (resources.getId() != null) {
|
||||||
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
||||||
}
|
}
|
||||||
|
@ -72,17 +72,17 @@ public class DictDetailController {
|
||||||
@ApiOperation("修改字典详情")
|
@ApiOperation("修改字典详情")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@PreAuthorize("@el.check('dict:edit')")
|
@PreAuthorize("@el.check('dict:edit')")
|
||||||
public ResponseEntity update(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources){
|
public ResponseEntity<Object> update(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources){
|
||||||
dictDetailService.update(resources);
|
dictDetailService.update(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("删除字典详情")
|
@Log("删除字典详情")
|
||||||
@ApiOperation("删除字典详情")
|
@ApiOperation("删除字典详情")
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
@PreAuthorize("@el.check('dict:del')")
|
@PreAuthorize("@el.check('dict:del')")
|
||||||
public ResponseEntity delete(@PathVariable Long id){
|
public ResponseEntity<Object> delete(@PathVariable Long id){
|
||||||
dictDetailService.delete(id);
|
dictDetailService.delete(id);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -52,7 +52,7 @@ public class JobController {
|
||||||
@ApiOperation("查询岗位")
|
@ApiOperation("查询岗位")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('job:list','user:list')")
|
@PreAuthorize("@el.check('job:list','user:list')")
|
||||||
public ResponseEntity getJobs(JobQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getJobs(JobQueryCriteria criteria, Pageable pageable){
|
||||||
// 数据权限
|
// 数据权限
|
||||||
criteria.setDeptIds(dataScope.getDeptIds());
|
criteria.setDeptIds(dataScope.getDeptIds());
|
||||||
return new ResponseEntity<>(jobService.queryAll(criteria, pageable),HttpStatus.OK);
|
return new ResponseEntity<>(jobService.queryAll(criteria, pageable),HttpStatus.OK);
|
||||||
|
@ -62,7 +62,7 @@ public class JobController {
|
||||||
@ApiOperation("新增岗位")
|
@ApiOperation("新增岗位")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('job:add')")
|
@PreAuthorize("@el.check('job:add')")
|
||||||
public ResponseEntity create(@Validated @RequestBody Job resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody Job resources){
|
||||||
if (resources.getId() != null) {
|
if (resources.getId() != null) {
|
||||||
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
||||||
}
|
}
|
||||||
|
@ -73,21 +73,21 @@ public class JobController {
|
||||||
@ApiOperation("修改岗位")
|
@ApiOperation("修改岗位")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@PreAuthorize("@el.check('job:edit')")
|
@PreAuthorize("@el.check('job:edit')")
|
||||||
public ResponseEntity update(@Validated(Job.Update.class) @RequestBody Job resources){
|
public ResponseEntity<Object> update(@Validated(Job.Update.class) @RequestBody Job resources){
|
||||||
jobService.update(resources);
|
jobService.update(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("删除岗位")
|
@Log("删除岗位")
|
||||||
@ApiOperation("删除岗位")
|
@ApiOperation("删除岗位")
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
@PreAuthorize("@el.check('job:del')")
|
@PreAuthorize("@el.check('job:del')")
|
||||||
public ResponseEntity delete(@PathVariable Long id){
|
public ResponseEntity<Object> delete(@PathVariable Long id){
|
||||||
try {
|
try {
|
||||||
jobService.delete(id);
|
jobService.delete(id);
|
||||||
}catch (Throwable e){
|
}catch (Throwable e){
|
||||||
ThrowableUtil.throwForeignKeyException(e, "该岗位存在用户关联,请取消关联后再试");
|
ThrowableUtil.throwForeignKeyException(e, "该岗位存在用户关联,请取消关联后再试");
|
||||||
}
|
}
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -58,7 +58,7 @@ public class MenuController {
|
||||||
|
|
||||||
@ApiOperation("获取前端所需菜单")
|
@ApiOperation("获取前端所需菜单")
|
||||||
@GetMapping(value = "/build")
|
@GetMapping(value = "/build")
|
||||||
public ResponseEntity buildMenus(){
|
public ResponseEntity<Object> buildMenus(){
|
||||||
UserDto user = userService.findByName(SecurityUtils.getUsername());
|
UserDto user = userService.findByName(SecurityUtils.getUsername());
|
||||||
List<MenuDto> menuDtoList = menuService.findByRoles(roleService.findByUsersId(user.getId()));
|
List<MenuDto> menuDtoList = menuService.findByRoles(roleService.findByUsersId(user.getId()));
|
||||||
List<MenuDto> menuDtos = (List<MenuDto>) menuService.buildTree(menuDtoList).get("content");
|
List<MenuDto> menuDtos = (List<MenuDto>) menuService.buildTree(menuDtoList).get("content");
|
||||||
|
@ -68,7 +68,7 @@ public class MenuController {
|
||||||
@ApiOperation("返回全部的菜单")
|
@ApiOperation("返回全部的菜单")
|
||||||
@GetMapping(value = "/tree")
|
@GetMapping(value = "/tree")
|
||||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||||
public ResponseEntity getMenuTree(){
|
public ResponseEntity<Object> getMenuTree(){
|
||||||
return new ResponseEntity<>(menuService.getMenuTree(menuService.findByPid(0L)),HttpStatus.OK);
|
return new ResponseEntity<>(menuService.getMenuTree(menuService.findByPid(0L)),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public class MenuController {
|
||||||
@ApiOperation("查询菜单")
|
@ApiOperation("查询菜单")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('menu:list')")
|
@PreAuthorize("@el.check('menu:list')")
|
||||||
public ResponseEntity getMenus(MenuQueryCriteria criteria){
|
public ResponseEntity<Object> getMenus(MenuQueryCriteria criteria){
|
||||||
List<MenuDto> menuDtoList = menuService.queryAll(criteria);
|
List<MenuDto> menuDtoList = menuService.queryAll(criteria);
|
||||||
return new ResponseEntity<>(menuService.buildTree(menuDtoList),HttpStatus.OK);
|
return new ResponseEntity<>(menuService.buildTree(menuDtoList),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public class MenuController {
|
||||||
@ApiOperation("新增菜单")
|
@ApiOperation("新增菜单")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('menu:add')")
|
@PreAuthorize("@el.check('menu:add')")
|
||||||
public ResponseEntity create(@Validated @RequestBody Menu resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody Menu resources){
|
||||||
if (resources.getId() != null) {
|
if (resources.getId() != null) {
|
||||||
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
||||||
}
|
}
|
||||||
|
@ -96,21 +96,21 @@ public class MenuController {
|
||||||
@ApiOperation("修改菜单")
|
@ApiOperation("修改菜单")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@PreAuthorize("@el.check('menu:edit')")
|
@PreAuthorize("@el.check('menu:edit')")
|
||||||
public ResponseEntity update(@Validated(Menu.Update.class) @RequestBody Menu resources){
|
public ResponseEntity<Object> update(@Validated(Menu.Update.class) @RequestBody Menu resources){
|
||||||
menuService.update(resources);
|
menuService.update(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("删除菜单")
|
@Log("删除菜单")
|
||||||
@ApiOperation("删除菜单")
|
@ApiOperation("删除菜单")
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
@PreAuthorize("@el.check('menu:del')")
|
@PreAuthorize("@el.check('menu:del')")
|
||||||
public ResponseEntity delete(@PathVariable Long id){
|
public ResponseEntity<Object> delete(@PathVariable Long id){
|
||||||
List<Menu> menuList = menuService.findByPid(id);
|
List<Menu> menuList = menuService.findByPid(id);
|
||||||
Set<Menu> menuSet = new HashSet<>();
|
Set<Menu> menuSet = new HashSet<>();
|
||||||
menuSet.add(menuService.findOne(id));
|
menuSet.add(menuService.findOne(id));
|
||||||
menuSet = menuService.getDeleteMenus(menuList, menuSet);
|
menuSet = menuService.getDeleteMenus(menuList, menuSet);
|
||||||
menuService.delete(menuSet);
|
menuService.delete(menuSet);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class RoleController {
|
||||||
@ApiOperation("获取单个role")
|
@ApiOperation("获取单个role")
|
||||||
@GetMapping(value = "/{id}")
|
@GetMapping(value = "/{id}")
|
||||||
@PreAuthorize("@el.check('roles:list')")
|
@PreAuthorize("@el.check('roles:list')")
|
||||||
public ResponseEntity getRoles(@PathVariable Long id){
|
public ResponseEntity<Object> getRoles(@PathVariable Long id){
|
||||||
return new ResponseEntity<>(roleService.findById(id), HttpStatus.OK);
|
return new ResponseEntity<>(roleService.findById(id), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class RoleController {
|
||||||
@ApiOperation("返回全部的角色")
|
@ApiOperation("返回全部的角色")
|
||||||
@GetMapping(value = "/all")
|
@GetMapping(value = "/all")
|
||||||
@PreAuthorize("@el.check('roles:list','user:add','user:edit')")
|
@PreAuthorize("@el.check('roles:list','user:add','user:edit')")
|
||||||
public ResponseEntity getAll(@PageableDefault(value = 2000, sort = {"level"}, direction = Sort.Direction.ASC) Pageable pageable){
|
public ResponseEntity<Object> getAll(@PageableDefault(value = 2000, sort = {"level"}, direction = Sort.Direction.ASC) Pageable pageable){
|
||||||
return new ResponseEntity<>(roleService.queryAll(pageable),HttpStatus.OK);
|
return new ResponseEntity<>(roleService.queryAll(pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,13 +73,13 @@ public class RoleController {
|
||||||
@ApiOperation("查询角色")
|
@ApiOperation("查询角色")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('roles:list')")
|
@PreAuthorize("@el.check('roles:list')")
|
||||||
public ResponseEntity getRoles(RoleQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getRoles(RoleQueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity<>(roleService.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity<>(roleService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("获取用户级别")
|
@ApiOperation("获取用户级别")
|
||||||
@GetMapping(value = "/level")
|
@GetMapping(value = "/level")
|
||||||
public ResponseEntity getLevel(){
|
public ResponseEntity<Object> getLevel(){
|
||||||
UserDto user = userService.findByName(SecurityUtils.getUsername());
|
UserDto user = userService.findByName(SecurityUtils.getUsername());
|
||||||
List<Integer> levels = roleService.findByUsersId(user.getId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList());
|
List<Integer> levels = roleService.findByUsersId(user.getId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList());
|
||||||
return new ResponseEntity<>(Dict.create().set("level", Collections.min(levels)),HttpStatus.OK);
|
return new ResponseEntity<>(Dict.create().set("level", Collections.min(levels)),HttpStatus.OK);
|
||||||
|
@ -89,7 +89,7 @@ public class RoleController {
|
||||||
@ApiOperation("新增角色")
|
@ApiOperation("新增角色")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('roles:add')")
|
@PreAuthorize("@el.check('roles:add')")
|
||||||
public ResponseEntity create(@Validated @RequestBody Role resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody Role resources){
|
||||||
if (resources.getId() != null) {
|
if (resources.getId() != null) {
|
||||||
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
throw new BadRequestException("A new "+ ENTITY_NAME +" cannot already have an ID");
|
||||||
}
|
}
|
||||||
|
@ -100,30 +100,30 @@ public class RoleController {
|
||||||
@ApiOperation("修改角色")
|
@ApiOperation("修改角色")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@PreAuthorize("@el.check('roles:edit')")
|
@PreAuthorize("@el.check('roles:edit')")
|
||||||
public ResponseEntity update(@Validated(Role.Update.class) @RequestBody Role resources){
|
public ResponseEntity<Object> update(@Validated(Role.Update.class) @RequestBody Role resources){
|
||||||
roleService.update(resources);
|
roleService.update(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("修改角色菜单")
|
@Log("修改角色菜单")
|
||||||
@ApiOperation("修改角色菜单")
|
@ApiOperation("修改角色菜单")
|
||||||
@PutMapping(value = "/menu")
|
@PutMapping(value = "/menu")
|
||||||
@PreAuthorize("@el.check('roles:edit')")
|
@PreAuthorize("@el.check('roles:edit')")
|
||||||
public ResponseEntity updateMenu(@RequestBody Role resources){
|
public ResponseEntity<Object> updateMenu(@RequestBody Role resources){
|
||||||
roleService.updateMenu(resources,roleService.findById(resources.getId()));
|
roleService.updateMenu(resources,roleService.findById(resources.getId()));
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("删除角色")
|
@Log("删除角色")
|
||||||
@ApiOperation("删除角色")
|
@ApiOperation("删除角色")
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
@PreAuthorize("@el.check('roles:del')")
|
@PreAuthorize("@el.check('roles:del')")
|
||||||
public ResponseEntity delete(@PathVariable Long id){
|
public ResponseEntity<Object> delete(@PathVariable Long id){
|
||||||
try {
|
try {
|
||||||
roleService.delete(id);
|
roleService.delete(id);
|
||||||
}catch (Throwable e){
|
}catch (Throwable e){
|
||||||
ThrowableUtil.throwForeignKeyException(e, "该角色存在用户关联,请取消关联后再试");
|
ThrowableUtil.throwForeignKeyException(e, "该角色存在用户关联,请取消关联后再试");
|
||||||
}
|
}
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public class UserController {
|
||||||
@ApiOperation("查询用户")
|
@ApiOperation("查询用户")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('user:list')")
|
@PreAuthorize("@el.check('user:list')")
|
||||||
public ResponseEntity getUsers(UserQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getUsers(UserQueryCriteria criteria, Pageable pageable){
|
||||||
Set<Long> deptSet = new HashSet<>();
|
Set<Long> deptSet = new HashSet<>();
|
||||||
Set<Long> result = new HashSet<>();
|
Set<Long> result = new HashSet<>();
|
||||||
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
|
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
|
||||||
|
@ -107,7 +107,7 @@ public class UserController {
|
||||||
@ApiOperation("新增用户")
|
@ApiOperation("新增用户")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('user:add')")
|
@PreAuthorize("@el.check('user:add')")
|
||||||
public ResponseEntity create(@Validated @RequestBody User resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody User resources){
|
||||||
checkLevel(resources);
|
checkLevel(resources);
|
||||||
// 默认密码 123456
|
// 默认密码 123456
|
||||||
resources.setPassword(passwordEncoder.encode("123456"));
|
resources.setPassword(passwordEncoder.encode("123456"));
|
||||||
|
@ -118,29 +118,29 @@ public class UserController {
|
||||||
@ApiOperation("修改用户")
|
@ApiOperation("修改用户")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@PreAuthorize("@el.check('user:edit')")
|
@PreAuthorize("@el.check('user:edit')")
|
||||||
public ResponseEntity update(@Validated(User.Update.class) @RequestBody User resources){
|
public ResponseEntity<Object> update(@Validated(User.Update.class) @RequestBody User resources){
|
||||||
checkLevel(resources);
|
checkLevel(resources);
|
||||||
userService.update(resources);
|
userService.update(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("修改用户:个人中心")
|
@Log("修改用户:个人中心")
|
||||||
@ApiOperation("修改用户:个人中心")
|
@ApiOperation("修改用户:个人中心")
|
||||||
@PutMapping(value = "center")
|
@PutMapping(value = "center")
|
||||||
public ResponseEntity center(@Validated(User.Update.class) @RequestBody User resources){
|
public ResponseEntity<Object> center(@Validated(User.Update.class) @RequestBody User resources){
|
||||||
UserDto userDto = userService.findByName(SecurityUtils.getUsername());
|
UserDto userDto = userService.findByName(SecurityUtils.getUsername());
|
||||||
if(!resources.getId().equals(userDto.getId())){
|
if(!resources.getId().equals(userDto.getId())){
|
||||||
throw new BadRequestException("不能修改他人资料");
|
throw new BadRequestException("不能修改他人资料");
|
||||||
}
|
}
|
||||||
userService.updateCenter(resources);
|
userService.updateCenter(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("删除用户")
|
@Log("删除用户")
|
||||||
@ApiOperation("删除用户")
|
@ApiOperation("删除用户")
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
@PreAuthorize("@el.check('user:del')")
|
@PreAuthorize("@el.check('user:del')")
|
||||||
public ResponseEntity delete(@PathVariable Long id){
|
public ResponseEntity<Object> delete(@PathVariable Long id){
|
||||||
UserDto user = userService.findByName(SecurityUtils.getUsername());
|
UserDto user = userService.findByName(SecurityUtils.getUsername());
|
||||||
Integer currentLevel = Collections.min(roleService.findByUsersId(user.getId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList()));
|
Integer currentLevel = Collections.min(roleService.findByUsersId(user.getId()).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList()));
|
||||||
Integer optLevel = Collections.min(roleService.findByUsersId(id).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList()));
|
Integer optLevel = Collections.min(roleService.findByUsersId(id).stream().map(RoleSmallDto::getLevel).collect(Collectors.toList()));
|
||||||
|
@ -149,12 +149,12 @@ public class UserController {
|
||||||
throw new BadRequestException("角色权限不足");
|
throw new BadRequestException("角色权限不足");
|
||||||
}
|
}
|
||||||
userService.delete(id);
|
userService.delete(id);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("修改密码")
|
@ApiOperation("修改密码")
|
||||||
@PostMapping(value = "/updatePass")
|
@PostMapping(value = "/updatePass")
|
||||||
public ResponseEntity updatePass(@RequestBody UserPassVo passVo){
|
public ResponseEntity<Object> updatePass(@RequestBody UserPassVo passVo){
|
||||||
// 密码解密
|
// 密码解密
|
||||||
RSA rsa = new RSA(privateKey, null);
|
RSA rsa = new RSA(privateKey, null);
|
||||||
String oldPass = new String(rsa.decrypt(passVo.getOldPass(), KeyType.PrivateKey));
|
String oldPass = new String(rsa.decrypt(passVo.getOldPass(), KeyType.PrivateKey));
|
||||||
|
@ -167,20 +167,20 @@ public class UserController {
|
||||||
throw new BadRequestException("新密码不能与旧密码相同");
|
throw new BadRequestException("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
userService.updatePass(user.getUsername(),passwordEncoder.encode(newPass));
|
userService.updatePass(user.getUsername(),passwordEncoder.encode(newPass));
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("修改头像")
|
@ApiOperation("修改头像")
|
||||||
@PostMapping(value = "/updateAvatar")
|
@PostMapping(value = "/updateAvatar")
|
||||||
public ResponseEntity updateAvatar(@RequestParam MultipartFile file){
|
public ResponseEntity<Object> updateAvatar(@RequestParam MultipartFile file){
|
||||||
userService.updateAvatar(file);
|
userService.updateAvatar(file);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("修改邮箱")
|
@Log("修改邮箱")
|
||||||
@ApiOperation("修改邮箱")
|
@ApiOperation("修改邮箱")
|
||||||
@PostMapping(value = "/updateEmail/{code}")
|
@PostMapping(value = "/updateEmail/{code}")
|
||||||
public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User user){
|
public ResponseEntity<Object> updateEmail(@PathVariable String code,@RequestBody User user){
|
||||||
// 密码解密
|
// 密码解密
|
||||||
RSA rsa = new RSA(privateKey, null);
|
RSA rsa = new RSA(privateKey, null);
|
||||||
String password = new String(rsa.decrypt(user.getPassword(), KeyType.PrivateKey));
|
String password = new String(rsa.decrypt(user.getPassword(), KeyType.PrivateKey));
|
||||||
|
@ -191,7 +191,7 @@ public class UserController {
|
||||||
VerificationCode verificationCode = new VerificationCode(code, ElAdminConstant.RESET_MAIL,"email",user.getEmail());
|
VerificationCode verificationCode = new VerificationCode(code, ElAdminConstant.RESET_MAIL,"email",user.getEmail());
|
||||||
verificationCodeService.validated(verificationCode);
|
verificationCodeService.validated(verificationCode);
|
||||||
userService.updateEmail(userDto.getUsername(),user.getEmail());
|
userService.updateEmail(userDto.getUsername(),user.getEmail());
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class ${className}Controller {
|
||||||
@Log("查询${apiAlias}")
|
@Log("查询${apiAlias}")
|
||||||
@ApiOperation("查询${apiAlias}")
|
@ApiOperation("查询${apiAlias}")
|
||||||
@PreAuthorize("@el.check('${changeClassName}:list')")
|
@PreAuthorize("@el.check('${changeClassName}:list')")
|
||||||
public ResponseEntity get${className}s(${className}QueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> get${className}s(${className}QueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity<>(${changeClassName}Service.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ public class ${className}Controller {
|
||||||
@Log("新增${apiAlias}")
|
@Log("新增${apiAlias}")
|
||||||
@ApiOperation("新增${apiAlias}")
|
@ApiOperation("新增${apiAlias}")
|
||||||
@PreAuthorize("@el.check('${changeClassName}:add')")
|
@PreAuthorize("@el.check('${changeClassName}:add')")
|
||||||
public ResponseEntity create(@Validated @RequestBody ${className} resources){
|
public ResponseEntity<Object> create(@Validated @RequestBody ${className} resources){
|
||||||
return new ResponseEntity<>(${changeClassName}Service.create(resources),HttpStatus.CREATED);
|
return new ResponseEntity<>(${changeClassName}Service.create(resources),HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,26 +57,26 @@ public class ${className}Controller {
|
||||||
@Log("修改${apiAlias}")
|
@Log("修改${apiAlias}")
|
||||||
@ApiOperation("修改${apiAlias}")
|
@ApiOperation("修改${apiAlias}")
|
||||||
@PreAuthorize("@el.check('${changeClassName}:edit')")
|
@PreAuthorize("@el.check('${changeClassName}:edit')")
|
||||||
public ResponseEntity update(@Validated @RequestBody ${className} resources){
|
public ResponseEntity<Object> update(@Validated @RequestBody ${className} resources){
|
||||||
${changeClassName}Service.update(resources);
|
${changeClassName}Service.update(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping(value = "/{${pkChangeColName}}")
|
@DeleteMapping(value = "/{${pkChangeColName}}")
|
||||||
@Log("删除${apiAlias}")
|
@Log("删除${apiAlias}")
|
||||||
@ApiOperation("删除${apiAlias}")
|
@ApiOperation("删除${apiAlias}")
|
||||||
@PreAuthorize("@el.check('${changeClassName}:del')")
|
@PreAuthorize("@el.check('${changeClassName}:del')")
|
||||||
public ResponseEntity delete(@PathVariable ${pkColumnType} ${pkChangeColName}){
|
public ResponseEntity<Object> delete(@PathVariable ${pkColumnType} ${pkChangeColName}){
|
||||||
${changeClassName}Service.delete(${pkChangeColName});
|
${changeClassName}Service.delete(${pkChangeColName});
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("多选删除${apiAlias}")
|
@Log("多选删除${apiAlias}")
|
||||||
@ApiOperation("多选删除${apiAlias}")
|
@ApiOperation("多选删除${apiAlias}")
|
||||||
@PreAuthorize("@el.check('${changeClassName}:del')")
|
@PreAuthorize("@el.check('${changeClassName}:del')")
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
public ResponseEntity deleteAll(@RequestBody ${pkColumnType}[] ids) {
|
public ResponseEntity<Object> deleteAll(@RequestBody ${pkColumnType}[] ids) {
|
||||||
${changeClassName}Service.deleteAll(ids);
|
${changeClassName}Service.deleteAll(ids);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -47,10 +47,10 @@ public class AliPayController {
|
||||||
@Log("配置支付宝")
|
@Log("配置支付宝")
|
||||||
@ApiOperation("配置支付宝")
|
@ApiOperation("配置支付宝")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public ResponseEntity payConfig(@Validated @RequestBody AlipayConfig alipayConfig){
|
public ResponseEntity<Object> payConfig(@Validated @RequestBody AlipayConfig alipayConfig){
|
||||||
alipayConfig.setId(1L);
|
alipayConfig.setId(1L);
|
||||||
alipayService.update(alipayConfig);
|
alipayService.update(alipayConfig);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("支付宝PC网页支付")
|
@Log("支付宝PC网页支付")
|
||||||
|
|
|
@ -28,23 +28,23 @@ public class EmailController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity get(){
|
public ResponseEntity<Object> get(){
|
||||||
return new ResponseEntity<>(emailService.find(),HttpStatus.OK);
|
return new ResponseEntity<>(emailService.find(),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("配置邮件")
|
@Log("配置邮件")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@ApiOperation("配置邮件")
|
@ApiOperation("配置邮件")
|
||||||
public ResponseEntity emailConfig(@Validated @RequestBody EmailConfig emailConfig){
|
public ResponseEntity<Object> emailConfig(@Validated @RequestBody EmailConfig emailConfig){
|
||||||
emailService.update(emailConfig,emailService.find());
|
emailService.update(emailConfig,emailService.find());
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("发送邮件")
|
@Log("发送邮件")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("发送邮件")
|
@ApiOperation("发送邮件")
|
||||||
public ResponseEntity send(@Validated @RequestBody EmailVo emailVo) throws Exception {
|
public ResponseEntity<Object> send(@Validated @RequestBody EmailVo emailVo) throws Exception {
|
||||||
emailService.send(emailVo,emailService.find());
|
emailService.send(emailVo,emailService.find());
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class LocalStorageController {
|
||||||
@ApiOperation("查询文件")
|
@ApiOperation("查询文件")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@PreAuthorize("@el.check('storage:list')")
|
@PreAuthorize("@el.check('storage:list')")
|
||||||
public ResponseEntity getLocalStorages(LocalStorageQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getLocalStorages(LocalStorageQueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity<>(localStorageService.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity<>(localStorageService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,31 +49,31 @@ public class LocalStorageController {
|
||||||
@ApiOperation("上传文件")
|
@ApiOperation("上传文件")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('storage:add')")
|
@PreAuthorize("@el.check('storage:add')")
|
||||||
public ResponseEntity create(@RequestParam String name, @RequestParam("file") MultipartFile file){
|
public ResponseEntity<Object> create(@RequestParam String name, @RequestParam("file") MultipartFile file){
|
||||||
return new ResponseEntity<>(localStorageService.create(name, file),HttpStatus.CREATED);
|
return new ResponseEntity<>(localStorageService.create(name, file),HttpStatus.CREATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("修改文件")
|
@ApiOperation("修改文件")
|
||||||
@PutMapping
|
@PutMapping
|
||||||
@PreAuthorize("@el.check('storage:edit')")
|
@PreAuthorize("@el.check('storage:edit')")
|
||||||
public ResponseEntity update(@Validated @RequestBody LocalStorage resources){
|
public ResponseEntity<Object> update(@Validated @RequestBody LocalStorage resources){
|
||||||
localStorageService.update(resources);
|
localStorageService.update(resources);
|
||||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation("删除文件")
|
@ApiOperation("删除文件")
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
@PreAuthorize("@el.check('storage:del')")
|
@PreAuthorize("@el.check('storage:del')")
|
||||||
public ResponseEntity delete(@PathVariable Long id){
|
public ResponseEntity<Object> delete(@PathVariable Long id){
|
||||||
localStorageService.delete(id);
|
localStorageService.delete(id);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("多选删除")
|
@Log("多选删除")
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
@ApiOperation("多选删除")
|
@ApiOperation("多选删除")
|
||||||
public ResponseEntity deleteAll(@RequestBody Long[] ids) {
|
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
|
||||||
localStorageService.deleteAll(ids);
|
localStorageService.deleteAll(ids);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -38,7 +38,7 @@ public class PictureController {
|
||||||
@PreAuthorize("@el.check('pictures:list')")
|
@PreAuthorize("@el.check('pictures:list')")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
@ApiOperation("查询图片")
|
@ApiOperation("查询图片")
|
||||||
public ResponseEntity getRoles(PictureQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getRoles(PictureQueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity<>(pictureService.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity<>(pictureService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class PictureController {
|
||||||
@PreAuthorize("@el.check('pictures:add')")
|
@PreAuthorize("@el.check('pictures:add')")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("上传图片")
|
@ApiOperation("上传图片")
|
||||||
public ResponseEntity upload(@RequestParam MultipartFile file){
|
public ResponseEntity<Object> upload(@RequestParam MultipartFile file){
|
||||||
String userName = SecurityUtils.getUsername();
|
String userName = SecurityUtils.getUsername();
|
||||||
Picture picture = pictureService.upload(file,userName);
|
Picture picture = pictureService.upload(file,userName);
|
||||||
Map<String,Object> map = new HashMap<>(3);
|
Map<String,Object> map = new HashMap<>(3);
|
||||||
|
@ -68,9 +68,9 @@ public class PictureController {
|
||||||
@ApiOperation("删除图片")
|
@ApiOperation("删除图片")
|
||||||
@PreAuthorize("@el.check('pictures:del')")
|
@PreAuthorize("@el.check('pictures:del')")
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
public ResponseEntity delete(@PathVariable Long id) {
|
public ResponseEntity<Object> delete(@PathVariable Long id) {
|
||||||
pictureService.delete(pictureService.findById(id));
|
pictureService.delete(pictureService.findById(id));
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("多选删除图片")
|
@Log("多选删除图片")
|
||||||
|
|
|
@ -37,17 +37,17 @@ public class QiniuController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/config")
|
@GetMapping(value = "/config")
|
||||||
public ResponseEntity get(){
|
public ResponseEntity<Object> get(){
|
||||||
return new ResponseEntity<>(qiNiuService.find(), HttpStatus.OK);
|
return new ResponseEntity<>(qiNiuService.find(), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("配置七牛云存储")
|
@Log("配置七牛云存储")
|
||||||
@ApiOperation("配置七牛云存储")
|
@ApiOperation("配置七牛云存储")
|
||||||
@PutMapping(value = "/config")
|
@PutMapping(value = "/config")
|
||||||
public ResponseEntity emailConfig(@Validated @RequestBody QiniuConfig qiniuConfig){
|
public ResponseEntity<Object> emailConfig(@Validated @RequestBody QiniuConfig qiniuConfig){
|
||||||
qiNiuService.update(qiniuConfig);
|
qiNiuService.update(qiniuConfig);
|
||||||
qiNiuService.update(qiniuConfig.getType());
|
qiNiuService.update(qiniuConfig.getType());
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("导出数据")
|
@Log("导出数据")
|
||||||
|
@ -60,14 +60,14 @@ public class QiniuController {
|
||||||
@Log("查询文件")
|
@Log("查询文件")
|
||||||
@ApiOperation("查询文件")
|
@ApiOperation("查询文件")
|
||||||
@GetMapping
|
@GetMapping
|
||||||
public ResponseEntity getRoles(QiniuQueryCriteria criteria, Pageable pageable){
|
public ResponseEntity<Object> getRoles(QiniuQueryCriteria criteria, Pageable pageable){
|
||||||
return new ResponseEntity<>(qiNiuService.queryAll(criteria,pageable),HttpStatus.OK);
|
return new ResponseEntity<>(qiNiuService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("上传文件")
|
@Log("上传文件")
|
||||||
@ApiOperation("上传文件")
|
@ApiOperation("上传文件")
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public ResponseEntity upload(@RequestParam MultipartFile file){
|
public ResponseEntity<Object> upload(@RequestParam MultipartFile file){
|
||||||
QiniuContent qiniuContent = qiNiuService.upload(file,qiNiuService.find());
|
QiniuContent qiniuContent = qiNiuService.upload(file,qiNiuService.find());
|
||||||
Map<String,Object> map = new HashMap<>(3);
|
Map<String,Object> map = new HashMap<>(3);
|
||||||
map.put("id",qiniuContent.getId());
|
map.put("id",qiniuContent.getId());
|
||||||
|
@ -79,15 +79,15 @@ public class QiniuController {
|
||||||
@Log("同步七牛云数据")
|
@Log("同步七牛云数据")
|
||||||
@ApiOperation("同步七牛云数据")
|
@ApiOperation("同步七牛云数据")
|
||||||
@PostMapping(value = "/synchronize")
|
@PostMapping(value = "/synchronize")
|
||||||
public ResponseEntity synchronize(){
|
public ResponseEntity<Object> synchronize(){
|
||||||
qiNiuService.synchronize(qiNiuService.find());
|
qiNiuService.synchronize(qiNiuService.find());
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("下载文件")
|
@Log("下载文件")
|
||||||
@ApiOperation("下载文件")
|
@ApiOperation("下载文件")
|
||||||
@GetMapping(value = "/download/{id}")
|
@GetMapping(value = "/download/{id}")
|
||||||
public ResponseEntity download(@PathVariable Long id){
|
public ResponseEntity<Object> download(@PathVariable Long id){
|
||||||
Map<String,Object> map = new HashMap<>(1);
|
Map<String,Object> map = new HashMap<>(1);
|
||||||
map.put("url", qiNiuService.download(qiNiuService.findByContentId(id),qiNiuService.find()));
|
map.put("url", qiNiuService.download(qiNiuService.findByContentId(id),qiNiuService.find()));
|
||||||
return new ResponseEntity<>(map,HttpStatus.OK);
|
return new ResponseEntity<>(map,HttpStatus.OK);
|
||||||
|
@ -96,16 +96,16 @@ public class QiniuController {
|
||||||
@Log("删除文件")
|
@Log("删除文件")
|
||||||
@ApiOperation("删除文件")
|
@ApiOperation("删除文件")
|
||||||
@DeleteMapping(value = "/{id}")
|
@DeleteMapping(value = "/{id}")
|
||||||
public ResponseEntity delete(@PathVariable Long id){
|
public ResponseEntity<Object> delete(@PathVariable Long id){
|
||||||
qiNiuService.delete(qiNiuService.findByContentId(id),qiNiuService.find());
|
qiNiuService.delete(qiNiuService.findByContentId(id),qiNiuService.find());
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Log("删除多张图片")
|
@Log("删除多张图片")
|
||||||
@ApiOperation("删除多张图片")
|
@ApiOperation("删除多张图片")
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
public ResponseEntity deleteAll(@RequestBody Long[] ids) {
|
public ResponseEntity<Object> deleteAll(@RequestBody Long[] ids) {
|
||||||
qiNiuService.deleteAll(ids, qiNiuService.find());
|
qiNiuService.deleteAll(ids, qiNiuService.find());
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,29 +31,29 @@ public class VerificationCodeController {
|
||||||
|
|
||||||
@PostMapping(value = "/resetEmail")
|
@PostMapping(value = "/resetEmail")
|
||||||
@ApiOperation("重置邮箱,发送验证码")
|
@ApiOperation("重置邮箱,发送验证码")
|
||||||
public ResponseEntity resetEmail(@RequestBody VerificationCode code) throws Exception {
|
public ResponseEntity<Object> resetEmail(@RequestBody VerificationCode code) throws Exception {
|
||||||
code.setScenes(ElAdminConstant.RESET_MAIL);
|
code.setScenes(ElAdminConstant.RESET_MAIL);
|
||||||
EmailVo emailVo = verificationCodeService.sendEmail(code);
|
EmailVo emailVo = verificationCodeService.sendEmail(code);
|
||||||
emailService.send(emailVo,emailService.find());
|
emailService.send(emailVo,emailService.find());
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/email/resetPass")
|
@PostMapping(value = "/email/resetPass")
|
||||||
@ApiOperation("重置密码,发送验证码")
|
@ApiOperation("重置密码,发送验证码")
|
||||||
public ResponseEntity resetPass(@RequestParam String email) throws Exception {
|
public ResponseEntity<Object> resetPass(@RequestParam String email) throws Exception {
|
||||||
VerificationCode code = new VerificationCode();
|
VerificationCode code = new VerificationCode();
|
||||||
code.setType("email");
|
code.setType("email");
|
||||||
code.setValue(email);
|
code.setValue(email);
|
||||||
code.setScenes(ElAdminConstant.RESET_MAIL);
|
code.setScenes(ElAdminConstant.RESET_MAIL);
|
||||||
EmailVo emailVo = verificationCodeService.sendEmail(code);
|
EmailVo emailVo = verificationCodeService.sendEmail(code);
|
||||||
emailService.send(emailVo,emailService.find());
|
emailService.send(emailVo,emailService.find());
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(value = "/validated")
|
@GetMapping(value = "/validated")
|
||||||
@ApiOperation("验证码验证")
|
@ApiOperation("验证码验证")
|
||||||
public ResponseEntity validated(VerificationCode code){
|
public ResponseEntity<Object> validated(VerificationCode code){
|
||||||
verificationCodeService.validated(code);
|
verificationCodeService.validated(code);
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue