Commit 900ca221 authored by Elune's avatar Elune
Browse files

代码优化

parent a9e12b5c
...@@ -47,10 +47,10 @@ public class AliPayController { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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);
} }
} }
\ No newline at end of file
...@@ -38,7 +38,7 @@ public class PictureController { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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);
} }
} }
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment