feat:编码规范
This commit is contained in:
+6
-6
@@ -93,17 +93,17 @@ public class QuartzJobController {
|
||||
}
|
||||
|
||||
@ApiOperation("更改定时任务状态")
|
||||
@PostMapping(value = "/switchJobPauseStatus/{id}")
|
||||
@PostMapping(value = "/switchQuartzJobStatus/{id}")
|
||||
@PreAuthorize("@el.check('timing:edit')")
|
||||
public ResponseEntity<Object> switchJobPauseStatus(@PathVariable Long id) {
|
||||
public ResponseEntity<Object> switchQuartzJobStatus(@PathVariable Long id) {
|
||||
quartzJobService.switchQuartzJobStatus(quartzJobService.getById(id));
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation("执行定时任务")
|
||||
@PostMapping(value = "/executionQuartzJob/{id}")
|
||||
@PostMapping(value = "/startQuartzJob/{id}")
|
||||
@PreAuthorize("@el.check('timing:edit')")
|
||||
public ResponseEntity<Object> executionQuartzJob(@PathVariable Long id) {
|
||||
public ResponseEntity<Object> startQuartzJob(@PathVariable Long id) {
|
||||
quartzJobService.startQuartzJob(quartzJobService.getById(id));
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
@@ -111,8 +111,8 @@ public class QuartzJobController {
|
||||
@ApiOperation("删除定时任务")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@el.check('timing:del')")
|
||||
public ResponseEntity<Object> deleteQuartzJob(@RequestBody Set<Long> ids) {
|
||||
quartzJobService.deleteJobByIds(ids);
|
||||
public ResponseEntity<Object> removeJobByIds(@RequestBody Set<Long> ids) {
|
||||
quartzJobService.removeJobByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ public interface QuartzJobService extends IService<QuartzJob> {
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteJobByIds(Set<Long> ids);
|
||||
void removeJobByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 更改定时任务状态
|
||||
|
||||
+6
-2
@@ -11,8 +11,8 @@ import cn.odboy.base.PageResult;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.model.job.domain.QuartzJob;
|
||||
import cn.odboy.model.job.domain.QuartzLog;
|
||||
import cn.odboy.model.job.request.UpdateQuartzJobRequest;
|
||||
import cn.odboy.model.job.request.QueryQuartzJobRequest;
|
||||
import cn.odboy.model.job.request.UpdateQuartzJobRequest;
|
||||
import cn.odboy.redis.RedisHelper;
|
||||
import cn.odboy.util.FileUtil;
|
||||
import cn.odboy.util.PageUtil;
|
||||
@@ -109,7 +109,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteJobByIds(Set<Long> ids) {
|
||||
public void removeJobByIds(Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
QuartzJob quartzJob = getById(id);
|
||||
quartzManage.deleteJob(quartzJob);
|
||||
@@ -126,6 +126,10 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||
continue;
|
||||
}
|
||||
QuartzJob quartzJob = getById(Long.parseLong(id));
|
||||
if (quartzJob == null) {
|
||||
// 防止子任务不存在
|
||||
continue;
|
||||
}
|
||||
// 执行任务
|
||||
String uuid = IdUtil.simpleUUID();
|
||||
quartzJob.setUuid(uuid);
|
||||
|
||||
+5
@@ -7,13 +7,16 @@ import cn.odboy.application.core.config.CaptchaProperties;
|
||||
import cn.odboy.application.core.config.LoginProperties;
|
||||
import cn.odboy.application.core.constant.LoginCodeEnum;
|
||||
import cn.odboy.application.core.context.TokenProvider;
|
||||
import cn.odboy.application.core.service.UserOnlineService;
|
||||
import cn.odboy.application.core.service.impl.UserDetailsServiceImpl;
|
||||
import cn.odboy.application.core.service.impl.UserOnlineServiceImpl;
|
||||
import cn.odboy.base.PageResult;
|
||||
import cn.odboy.constant.SystemConst;
|
||||
import cn.odboy.constant.SystemRedisKey;
|
||||
import cn.odboy.context.SecurityHelper;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.model.system.model.UserJwtModel;
|
||||
import cn.odboy.model.system.model.UserOnlineModel;
|
||||
import cn.odboy.model.system.request.UserLoginRequest;
|
||||
import cn.odboy.model.system.response.UserInfoResponse;
|
||||
import cn.odboy.properties.RsaProperties;
|
||||
@@ -25,8 +28,10 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ public interface UserCacheService {
|
||||
* @param userName 用户名
|
||||
*/
|
||||
@Async
|
||||
void cacheUserJwtModelByUserName(String userName, UserJwtModel user);
|
||||
void saveUserJwtModelByUserName(String userName, UserJwtModel user);
|
||||
|
||||
/**
|
||||
* 清理用户缓存信息
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public class UserCacheServiceImpl implements UserCacheService {
|
||||
|
||||
|
||||
@Override
|
||||
public void cacheUserJwtModelByUserName(String userName, UserJwtModel user) {
|
||||
public void saveUserJwtModelByUserName(String userName, UserJwtModel user) {
|
||||
// 转小写
|
||||
userName = StringUtil.lowerCase(userName);
|
||||
if (StringUtil.isNotEmpty(userName)) {
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
|
||||
// 初始化JwtUserDto
|
||||
userJwtModel = new UserJwtModel(user, dataService.describeDeptIdListByUserIdWithDeptId(user), authorities);
|
||||
// 添加缓存数据
|
||||
userCacheService.cacheUserJwtModelByUserName(username, userJwtModel);
|
||||
userCacheService.saveUserJwtModelByUserName(username, userJwtModel);
|
||||
}
|
||||
}
|
||||
return userJwtModel;
|
||||
|
||||
+4
-4
@@ -31,20 +31,20 @@ public class CaptchaController {
|
||||
@ApiOperation("重置邮箱,发送验证码")
|
||||
@PostMapping(value = "/sendResetEmailCaptcha")
|
||||
public ResponseEntity<Object> sendResetEmailCaptcha(@RequestParam String email) {
|
||||
emailService.sendEmailCaptcha(email, CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey());
|
||||
emailService.sendEmail(captchaService.renderCodeTemplate(email, CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey()));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("重置密码,发送验证码")
|
||||
@PostMapping(value = "/sendResetPasswordCaptcha")
|
||||
public ResponseEntity<Object> sendResetPasswordCaptcha(@RequestParam String email) {
|
||||
emailService.sendEmailCaptcha(email, CodeEnum.EMAIL_RESET_PWD_CODE.getKey());
|
||||
emailService.sendEmail(captchaService.renderCodeTemplate(email, CodeEnum.EMAIL_RESET_PWD_CODE.getKey()));
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("验证码验证")
|
||||
@PostMapping(value = "/validatedCaptcha")
|
||||
public ResponseEntity<Object> validatedCaptcha(@RequestParam String email, @RequestParam String code, @RequestParam Integer codeBi) {
|
||||
@PostMapping(value = "/checkCodeAvailable")
|
||||
public ResponseEntity<Object> checkCodeAvailable(@RequestParam String email, @RequestParam String code, @RequestParam Integer codeBi) {
|
||||
CodeBiEnum biEnum = CodeBiEnum.find(codeBi);
|
||||
switch (Objects.requireNonNull(biEnum)) {
|
||||
case ONE:
|
||||
|
||||
+11
-11
@@ -44,15 +44,15 @@ public class DeptController {
|
||||
@ApiOperation("查询部门")
|
||||
@GetMapping
|
||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||
public ResponseEntity<PageResult<Dept>> queryDept(QueryDeptRequest criteria) throws Exception {
|
||||
public ResponseEntity<PageResult<Dept>> describeDeptPage(QueryDeptRequest criteria) throws Exception {
|
||||
List<Dept> depts = deptService.describeDeptList(criteria, true);
|
||||
return new ResponseEntity<>(PageUtil.toPage(depts), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询部门:根据ID获取同级与上级数据")
|
||||
@PostMapping("/getDeptSuperior")
|
||||
@PostMapping("/describeDeptSuperiorTree")
|
||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||
public ResponseEntity<Object> getDeptSuperior(@RequestBody List<Long> ids, @RequestParam(defaultValue = "false") Boolean exclude) {
|
||||
public ResponseEntity<Object> describeDeptSuperiorTree(@RequestBody List<Long> ids, @RequestParam(defaultValue = "false") Boolean exclude) {
|
||||
Set<Dept> deptSet = new LinkedHashSet<>();
|
||||
for (Long id : ids) {
|
||||
Dept dept = deptService.describeDeptById(id);
|
||||
@@ -72,31 +72,31 @@ public class DeptController {
|
||||
}
|
||||
|
||||
@ApiOperation("新增部门")
|
||||
@PostMapping(value = "/createDept")
|
||||
@PostMapping(value = "/saveDept")
|
||||
@PreAuthorize("@el.check('dept:add')")
|
||||
public ResponseEntity<Object> createDept(@Validated @RequestBody CreateDeptRequest resources) {
|
||||
deptService.createDept(resources);
|
||||
public ResponseEntity<Object> saveDept(@Validated @RequestBody CreateDeptRequest resources) {
|
||||
deptService.saveDept(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation("修改部门")
|
||||
@PostMapping(value = "/updateDept")
|
||||
@PostMapping(value = "/modifyDept")
|
||||
@PreAuthorize("@el.check('dept:edit')")
|
||||
public ResponseEntity<Object> updateDept(@Validated(Dept.Update.class) @RequestBody Dept resources) {
|
||||
public ResponseEntity<Object> modifyDept(@Validated(Dept.Update.class) @RequestBody Dept resources) {
|
||||
deptService.modifyDept(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation("删除部门")
|
||||
@PostMapping(value = "/deleteDept")
|
||||
@PostMapping(value = "/removeDeptByIds")
|
||||
@PreAuthorize("@el.check('dept:del')")
|
||||
public ResponseEntity<Object> deleteDept(@RequestBody Set<Long> ids) {
|
||||
public ResponseEntity<Object> removeDeptByIds(@RequestBody Set<Long> ids) {
|
||||
Set<Dept> depts = new HashSet<>();
|
||||
// 获取部门,和其所有子部门
|
||||
deptService.traverseDeptByIdWithPids(ids, depts);
|
||||
// 验证是否被角色或用户关联
|
||||
deptService.verifyBindRelationByIds(depts);
|
||||
deptService.deleteDeptByIds(depts);
|
||||
deptService.removeDeptByIds(depts);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -53,26 +53,26 @@ public class DictController {
|
||||
}
|
||||
|
||||
@ApiOperation("新增字典")
|
||||
@PostMapping(value = "/createDict")
|
||||
@PostMapping(value = "/saveDict")
|
||||
@PreAuthorize("@el.check('dict:add')")
|
||||
public ResponseEntity<Object> createDict(@Validated @RequestBody CreateDictRequest resources) {
|
||||
dictService.createDict(resources);
|
||||
public ResponseEntity<Object> saveDict(@Validated @RequestBody CreateDictRequest resources) {
|
||||
dictService.saveDict(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation("修改字典")
|
||||
@PostMapping(value = "/updateDict")
|
||||
@PostMapping(value = "/modifyDictById")
|
||||
@PreAuthorize("@el.check('dict:edit')")
|
||||
public ResponseEntity<Object> updateDict(@Validated(Dict.Update.class) @RequestBody Dict resources) {
|
||||
public ResponseEntity<Object> modifyDictById(@Validated(Dict.Update.class) @RequestBody Dict resources) {
|
||||
dictService.modifyDictById(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation("删除字典")
|
||||
@PostMapping(value = "/deleteDict")
|
||||
@PostMapping(value = "/removeDictByIds")
|
||||
@PreAuthorize("@el.check('dict:del')")
|
||||
public ResponseEntity<Object> deleteDict(@RequestBody Set<Long> ids) {
|
||||
dictService.deleteDictByIds(ids);
|
||||
public ResponseEntity<Object> removeDictByIds(@RequestBody Set<Long> ids) {
|
||||
dictService.removeDictByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
+8
-11
@@ -13,11 +13,8 @@ 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.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -35,7 +32,7 @@ public class DictDetailController {
|
||||
|
||||
@ApiOperation("查询字典详情")
|
||||
@GetMapping
|
||||
public ResponseEntity<PageResult<DictDetail>> queryDictDetail(QueryDictDetailRequest criteria) {
|
||||
public ResponseEntity<PageResult<DictDetail>> describeDictDetailPage(QueryDictDetailRequest criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(dictDetailService.describeDictDetailPage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
@@ -52,26 +49,26 @@ public class DictDetailController {
|
||||
}
|
||||
|
||||
@ApiOperation("新增字典详情")
|
||||
@PostMapping
|
||||
@PostMapping(value = "/saveDictDetail")
|
||||
@PreAuthorize("@el.check('dict:add')")
|
||||
public ResponseEntity<Object> createDictDetail(@Validated @RequestBody CreateDictDetailRequest resources) {
|
||||
public ResponseEntity<Object> saveDictDetail(@Validated @RequestBody CreateDictDetailRequest resources) {
|
||||
dictDetailService.saveDictDetail(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation("修改字典详情")
|
||||
@PutMapping
|
||||
@PostMapping(value = "/modifyDictDetailById")
|
||||
@PreAuthorize("@el.check('dict:edit')")
|
||||
public ResponseEntity<Object> updateDictDetail(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources) {
|
||||
public ResponseEntity<Object> modifyDictDetailById(@Validated(DictDetail.Update.class) @RequestBody DictDetail resources) {
|
||||
dictDetailService.modifyDictDetailById(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation("删除字典详情")
|
||||
@DeleteMapping(value = "/{id}")
|
||||
@PostMapping(value = "/removeDictDetailById")
|
||||
@PreAuthorize("@el.check('dict:del')")
|
||||
public ResponseEntity<Object> deleteDictDetail(@PathVariable Long id) {
|
||||
dictDetailService.deleteDictDetailById(id);
|
||||
public ResponseEntity<Object> removeDictDetailById(@RequestBody DictDetail args) {
|
||||
dictDetailService.removeDictDetailById(args.getId());
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -46,28 +46,28 @@ public class JobController {
|
||||
}
|
||||
|
||||
@ApiOperation("新增岗位")
|
||||
@PostMapping(value = "/createJob")
|
||||
@PostMapping(value = "/saveJob")
|
||||
@PreAuthorize("@el.check('job:add')")
|
||||
public ResponseEntity<Object> createJob(@Validated @RequestBody CreateJobRequest resources) {
|
||||
jobService.createJob(resources);
|
||||
public ResponseEntity<Object> saveJob(@Validated @RequestBody CreateJobRequest resources) {
|
||||
jobService.saveJob(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation("修改岗位")
|
||||
@PostMapping(value = "/updateJob")
|
||||
@PostMapping(value = "/modifyJobById")
|
||||
@PreAuthorize("@el.check('job:edit')")
|
||||
public ResponseEntity<Object> updateJob(@Validated(Job.Update.class) @RequestBody Job resources) {
|
||||
public ResponseEntity<Object> modifyJobById(@Validated(Job.Update.class) @RequestBody Job resources) {
|
||||
jobService.modifyJobById(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation("删除岗位")
|
||||
@PostMapping(value = "/deleteJob")
|
||||
@PostMapping(value = "/removeJobByIds")
|
||||
@PreAuthorize("@el.check('job:del')")
|
||||
public ResponseEntity<Object> deleteJob(@RequestBody Set<Long> ids) {
|
||||
public ResponseEntity<Object> removeJobByIds(@RequestBody Set<Long> ids) {
|
||||
// 验证是否被用户关联
|
||||
jobService.verifyBindRelationByIds(ids);
|
||||
jobService.deleteJobByIds(ids);
|
||||
jobService.removeJobByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
+14
-14
@@ -56,16 +56,16 @@ public class MenuController {
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的菜单")
|
||||
@PostMapping(value = "/queryAllMenu")
|
||||
@PostMapping(value = "/describeMenuListByPid")
|
||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||
public ResponseEntity<List<Menu>> queryAllMenu(@RequestParam Long pid) {
|
||||
public ResponseEntity<List<Menu>> describeMenuListByPid(@RequestParam Long pid) {
|
||||
return new ResponseEntity<>(menuService.describeMenuListByPid(pid), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("根据菜单ID返回所有子节点ID,包含自身ID")
|
||||
@PostMapping(value = "/queryChildMenu")
|
||||
@PostMapping(value = "/describeChildMenuSet")
|
||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||
public ResponseEntity<Object> queryChildMenu(@RequestParam Long id) {
|
||||
public ResponseEntity<Object> describeChildMenuSet(@RequestParam Long id) {
|
||||
Set<Menu> menuSet = new HashSet<>();
|
||||
List<Menu> menuList = menuService.describeMenuListByPid(id);
|
||||
menuSet.add(menuService.getById(id));
|
||||
@@ -83,9 +83,9 @@ public class MenuController {
|
||||
}
|
||||
|
||||
@ApiOperation("查询菜单:根据ID获取同级与上级数据")
|
||||
@PostMapping("/queryMenuSuperior")
|
||||
@PostMapping("/describeMenuSuperior")
|
||||
@PreAuthorize("@el.check('menu:list')")
|
||||
public ResponseEntity<List<Menu>> queryMenuSuperior(@RequestBody List<Long> ids) {
|
||||
public ResponseEntity<List<Menu>> describeMenuSuperior(@RequestBody List<Long> ids) {
|
||||
Set<Menu> menus = new LinkedHashSet<>();
|
||||
if (CollectionUtil.isNotEmpty(ids)) {
|
||||
for (Long id : ids) {
|
||||
@@ -106,35 +106,35 @@ public class MenuController {
|
||||
}
|
||||
|
||||
@ApiOperation("新增菜单")
|
||||
@PostMapping(value = "/createMenu")
|
||||
@PostMapping(value = "/saveMenu")
|
||||
@PreAuthorize("@el.check('menu:add')")
|
||||
public ResponseEntity<Object> createMenu(@Validated @RequestBody Menu resources) {
|
||||
public ResponseEntity<Object> saveMenu(@Validated @RequestBody Menu resources) {
|
||||
if (resources.getId() != null) {
|
||||
throw new BadRequestException("A new " + ENTITY_NAME + " cannot already have an ID");
|
||||
}
|
||||
menuService.createMenu(resources);
|
||||
menuService.saveMenu(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation("修改菜单")
|
||||
@PostMapping(value = "/updateMenu")
|
||||
@PostMapping(value = "/modifyMenuById")
|
||||
@PreAuthorize("@el.check('menu:edit')")
|
||||
public ResponseEntity<Object> updateMenu(@Validated(Menu.Update.class) @RequestBody Menu resources) {
|
||||
public ResponseEntity<Object> modifyMenuById(@Validated(Menu.Update.class) @RequestBody Menu resources) {
|
||||
menuService.modifyMenuById(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation("删除菜单")
|
||||
@PostMapping(value = "/deleteMenu")
|
||||
@PostMapping(value = "/removeMenuByIds")
|
||||
@PreAuthorize("@el.check('menu:del')")
|
||||
public ResponseEntity<Object> deleteMenu(@RequestBody Set<Long> ids) {
|
||||
public ResponseEntity<Object> removeMenuByIds(@RequestBody Set<Long> ids) {
|
||||
Set<Menu> menuSet = new HashSet<>();
|
||||
for (Long id : ids) {
|
||||
List<Menu> menuList = menuService.describeMenuListByPid(id);
|
||||
menuSet.add(menuService.getById(id));
|
||||
menuSet = menuService.describeChildMenuSet(menuList, menuSet);
|
||||
}
|
||||
menuService.deleteMenuByIds(menuSet);
|
||||
menuService.removeMenuByIds(menuSet);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -7,7 +7,7 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@@ -19,10 +19,10 @@ public class MonitorController {
|
||||
|
||||
private final MonitorService serverService;
|
||||
|
||||
@GetMapping
|
||||
@PostMapping(value = "/describeServerMonitorInfo")
|
||||
@ApiOperation("查询服务监控")
|
||||
@PreAuthorize("@el.check('monitor:list')")
|
||||
public ResponseEntity<Object> queryMonitor() {
|
||||
public ResponseEntity<Object> describeServerMonitorInfo() {
|
||||
return new ResponseEntity<>(serverService.describeServerMonitorInfo(), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-19
@@ -17,7 +17,6 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -38,10 +37,10 @@ public class RoleController {
|
||||
private final RoleService roleService;
|
||||
|
||||
@ApiOperation("获取单个role")
|
||||
@PostMapping(value = "/getRoleById/{id}")
|
||||
@PostMapping(value = "/describeRoleById")
|
||||
@PreAuthorize("@el.check('roles:list')")
|
||||
public ResponseEntity<Role> getRoleById(@PathVariable Long id) {
|
||||
return new ResponseEntity<>(roleService.describeRoleById(id), HttpStatus.OK);
|
||||
public ResponseEntity<Role> describeRoleById(@RequestBody Role args) {
|
||||
return new ResponseEntity<>(roleService.describeRoleById(args.getId()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出角色数据")
|
||||
@@ -52,48 +51,48 @@ public class RoleController {
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的角色")
|
||||
@PostMapping(value = "/queryAllRole")
|
||||
@PostMapping(value = "/describeRoleList")
|
||||
@PreAuthorize("@el.check('roles:list','user:add','user:edit')")
|
||||
public ResponseEntity<List<Role>> queryAllRole() {
|
||||
public ResponseEntity<List<Role>> describeRoleList() {
|
||||
return new ResponseEntity<>(roleService.describeRoleList(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询角色")
|
||||
@GetMapping
|
||||
@PreAuthorize("@el.check('roles:list')")
|
||||
public ResponseEntity<PageResult<Role>> queryRole(QueryRoleRequest criteria) {
|
||||
public ResponseEntity<PageResult<Role>> describeRolePage(QueryRoleRequest criteria) {
|
||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
return new ResponseEntity<>(roleService.describeRolePage(criteria, page), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("获取用户级别")
|
||||
@PostMapping(value = "/getRoleLevel")
|
||||
public ResponseEntity<Object> getRoleLevel() {
|
||||
@PostMapping(value = "/describeRoleLevel")
|
||||
public ResponseEntity<Object> describeRoleLevel() {
|
||||
return new ResponseEntity<>(Dict.create().set("level", checkRoleLevels(null)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增角色")
|
||||
@PostMapping(value = "/createRole")
|
||||
@PostMapping(value = "/saveRole")
|
||||
@PreAuthorize("@el.check('roles:add')")
|
||||
public ResponseEntity<Object> createRole(@Validated @RequestBody CreateRoleRequest resources) {
|
||||
public ResponseEntity<Object> saveRole(@Validated @RequestBody CreateRoleRequest resources) {
|
||||
checkRoleLevels(resources.getLevel());
|
||||
roleService.createRole(resources);
|
||||
roleService.saveRole(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation("修改角色")
|
||||
@PostMapping(value = "/updateRole")
|
||||
@PostMapping(value = "/modifyRoleById")
|
||||
@PreAuthorize("@el.check('roles:edit')")
|
||||
public ResponseEntity<Object> updateRole(@Validated(Role.Update.class) @RequestBody Role resources) {
|
||||
public ResponseEntity<Object> modifyRoleById(@Validated(Role.Update.class) @RequestBody Role resources) {
|
||||
checkRoleLevels(resources.getLevel());
|
||||
roleService.modifyRoleById(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation("修改角色菜单")
|
||||
@PostMapping(value = "/updateRoleMenu")
|
||||
@PostMapping(value = "/modifyBindMenuById")
|
||||
@PreAuthorize("@el.check('roles:edit')")
|
||||
public ResponseEntity<Object> updateRoleMenu(@RequestBody Role resources) {
|
||||
public ResponseEntity<Object> modifyBindMenuById(@RequestBody Role resources) {
|
||||
Role role = roleService.getById(resources.getId());
|
||||
checkRoleLevels(role.getLevel());
|
||||
roleService.modifyBindMenuById(resources);
|
||||
@@ -101,16 +100,16 @@ public class RoleController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除角色")
|
||||
@PostMapping(value = "/deleteRole")
|
||||
@PostMapping(value = "/removeRoleByIds")
|
||||
@PreAuthorize("@el.check('roles:del')")
|
||||
public ResponseEntity<Object> deleteRole(@RequestBody Set<Long> ids) {
|
||||
public ResponseEntity<Object> removeRoleByIds(@RequestBody Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
Role role = roleService.getById(id);
|
||||
checkRoleLevels(role.getLevel());
|
||||
}
|
||||
// 验证是否被用户关联
|
||||
roleService.verifyBindRelationByIds(ids);
|
||||
roleService.deleteRoleByIds(ids);
|
||||
roleService.removeRoleByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
+21
-21
@@ -63,7 +63,7 @@ public class UserController {
|
||||
@ApiOperation("导出用户数据")
|
||||
@GetMapping(value = "/download")
|
||||
@PreAuthorize("@el.check('user:list')")
|
||||
public void exportUser(HttpServletResponse response, QueryUserRequest criteria) throws IOException {
|
||||
public void downloadUserExcel(HttpServletResponse response, QueryUserRequest criteria) throws IOException {
|
||||
userService.downloadUserExcel(userService.describeUserList(criteria), response);
|
||||
}
|
||||
|
||||
@@ -97,28 +97,28 @@ public class UserController {
|
||||
}
|
||||
|
||||
@ApiOperation("新增用户")
|
||||
@PostMapping(value = "/createUser")
|
||||
@PostMapping(value = "/saveUser")
|
||||
@PreAuthorize("@el.check('user:add')")
|
||||
public ResponseEntity<Object> createUser(@Validated @RequestBody User resources) {
|
||||
public ResponseEntity<Object> saveUser(@Validated @RequestBody User resources) {
|
||||
checkLevel(resources);
|
||||
// 默认密码 123456
|
||||
resources.setPassword(passwordEncoder.encode("123456"));
|
||||
userService.createUser(resources);
|
||||
userService.saveUser(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation("修改用户")
|
||||
@PostMapping(value = "/updateUser")
|
||||
@PostMapping(value = "/modifyUserById")
|
||||
@PreAuthorize("@el.check('user:edit')")
|
||||
public ResponseEntity<Object> updateUser(@Validated(User.Update.class) @RequestBody User resources) throws Exception {
|
||||
public ResponseEntity<Object> modifyUserById(@Validated(User.Update.class) @RequestBody User resources) throws Exception {
|
||||
checkLevel(resources);
|
||||
userService.modifyUserById(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation("修改用户:个人中心")
|
||||
@PostMapping(value = "updateCenterInfo")
|
||||
public ResponseEntity<Object> updateCenterInfo(@Validated(User.Update.class) @RequestBody User resources) {
|
||||
@PostMapping(value = "modifyUserCenterInfoById")
|
||||
public ResponseEntity<Object> modifyUserCenterInfoById(@Validated(User.Update.class) @RequestBody User resources) {
|
||||
if (!resources.getId().equals(SecurityHelper.getCurrentUserId())) {
|
||||
throw new BadRequestException("不能修改他人资料");
|
||||
}
|
||||
@@ -127,9 +127,9 @@ public class UserController {
|
||||
}
|
||||
|
||||
@ApiOperation("删除用户")
|
||||
@PostMapping(value = "/deleteUser")
|
||||
@PostMapping(value = "/removeUserByIds")
|
||||
@PreAuthorize("@el.check('user:del')")
|
||||
public ResponseEntity<Object> deleteUser(@RequestBody Set<Long> ids) {
|
||||
public ResponseEntity<Object> removeUserByIds(@RequestBody Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
Integer currentLevel = Collections.min(roleService.describeRoleListByUsersId(SecurityHelper.getCurrentUserId()).stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = Collections.min(roleService.describeRoleListByUsersId(id).stream().map(Role::getLevel).collect(Collectors.toList()));
|
||||
@@ -137,13 +137,13 @@ public class UserController {
|
||||
throw new BadRequestException("角色权限不足,不能删除:" + userService.describeUserById(id).getUsername());
|
||||
}
|
||||
}
|
||||
userService.deleteUserByIds(ids);
|
||||
userService.removeUserByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("修改密码")
|
||||
@PostMapping(value = "/updatePassword")
|
||||
public ResponseEntity<Object> updatePassword(@RequestBody UpdateUserPasswordResponse passVo) throws Exception {
|
||||
@PostMapping(value = "/modifyUserPasswordByUsername")
|
||||
public ResponseEntity<Object> modifyUserPasswordByUsername(@RequestBody UpdateUserPasswordResponse passVo) throws Exception {
|
||||
String oldPass = RsaEncryptUtil.decryptByPrivateKey(RsaProperties.privateKey, passVo.getOldPass());
|
||||
String newPass = RsaEncryptUtil.decryptByPrivateKey(RsaProperties.privateKey, passVo.getNewPass());
|
||||
User user = userService.describeUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
@@ -158,22 +158,22 @@ public class UserController {
|
||||
}
|
||||
|
||||
@ApiOperation("重置密码")
|
||||
@PostMapping(value = "/resetPwd")
|
||||
public ResponseEntity<Object> resetPwd(@RequestBody Set<Long> ids) {
|
||||
@PostMapping(value = "/resetUserPasswordByIds")
|
||||
public ResponseEntity<Object> resetUserPasswordByIds(@RequestBody Set<Long> ids) {
|
||||
String defaultPwd = passwordEncoder.encode("123456");
|
||||
userService.resetUserPasswordByIds(ids, defaultPwd);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("修改头像")
|
||||
@PostMapping(value = "/updateAvatar")
|
||||
public ResponseEntity<Object> updateUserAvatar(@RequestParam MultipartFile avatar) {
|
||||
@PostMapping(value = "/modifyUserAvatar")
|
||||
public ResponseEntity<Object> modifyUserAvatar(@RequestParam MultipartFile avatar) {
|
||||
return new ResponseEntity<>(userService.modifyUserAvatar(avatar), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("修改邮箱")
|
||||
@PostMapping(value = "/updateEmail/{code}")
|
||||
public ResponseEntity<Object> updateUserEmail(@PathVariable String code, @RequestBody User resources) throws Exception {
|
||||
@PostMapping(value = "/modifyUserEmailByUsername/{code}")
|
||||
public ResponseEntity<Object> modifyUserEmailByUsername(@PathVariable String code, @RequestBody User resources) throws Exception {
|
||||
String password = RsaEncryptUtil.decryptByPrivateKey(RsaProperties.privateKey, resources.getPassword());
|
||||
User user = userService.describeUserByUsername(SecurityHelper.getCurrentUsername());
|
||||
if (!passwordEncoder.matches(password, user.getPassword())) {
|
||||
@@ -198,9 +198,9 @@ public class UserController {
|
||||
}
|
||||
|
||||
@ApiOperation("查询用户基础数据")
|
||||
@PostMapping(value = "/queryUserMetaPage")
|
||||
@PostMapping(value = "/describeUserMetadataOptions")
|
||||
@PreAuthorize("@el.check('user:list')")
|
||||
public ResponseEntity<List<MyMetaOption>> queryUserMetaPage(@Validated @RequestBody QueryUserRequest criteria) {
|
||||
public ResponseEntity<List<MyMetaOption>> queryUserMetadataOptions(@Validated @RequestBody QueryUserRequest criteria) {
|
||||
int maxPageSize = 50;
|
||||
return new ResponseEntity<>(userService.page(new Page<>(criteria.getPage(), maxPageSize), new LambdaQueryWrapper<User>()
|
||||
.and(c -> {
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ public interface DeptService extends IService<Dept> {
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
void createDept(CreateDeptRequest resources);
|
||||
void saveDept(CreateDeptRequest resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
@@ -49,7 +49,7 @@ public interface DeptService extends IService<Dept> {
|
||||
*
|
||||
* @param depts /
|
||||
*/
|
||||
void deleteDeptByIds(Set<Dept> depts);
|
||||
void removeDeptByIds(Set<Dept> depts);
|
||||
|
||||
/**
|
||||
* 根据PID查询
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ public interface DictDetailService extends IService<DictDetail> {
|
||||
*
|
||||
* @param id /
|
||||
*/
|
||||
void deleteDictDetailById(Long id);
|
||||
void removeDictDetailById(Long id);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ public interface DictService extends IService<Dict> {
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
void createDict(CreateDictRequest resources);
|
||||
void saveDict(CreateDictRequest resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
@@ -50,7 +50,7 @@ public interface DictService extends IService<Dict> {
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteDictByIds(Set<Long> ids);
|
||||
void removeDictByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ public interface JobService extends IService<Job> {
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
void createJob(CreateJobRequest resources);
|
||||
void saveJob(CreateJobRequest resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
@@ -41,7 +41,7 @@ public interface JobService extends IService<Job> {
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteJobByIds(Set<Long> ids);
|
||||
void removeJobByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ public interface MenuService extends IService<Menu> {
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
void createMenu(Menu resources);
|
||||
void saveMenu(Menu resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
@@ -73,7 +73,7 @@ public interface MenuService extends IService<Menu> {
|
||||
*
|
||||
* @param menuSet /
|
||||
*/
|
||||
void deleteMenuByIds(Set<Menu> menuSet);
|
||||
void removeMenuByIds(Set<Menu> menuSet);
|
||||
|
||||
/**
|
||||
* 导出
|
||||
|
||||
+2
-2
@@ -53,7 +53,7 @@ public interface RoleService extends IService<Role> {
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
void createRole(CreateRoleRequest resources);
|
||||
void saveRole(CreateRoleRequest resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
@@ -74,7 +74,7 @@ public interface RoleService extends IService<Role> {
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteRoleByIds(Set<Long> ids);
|
||||
void removeRoleByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ public interface UserService extends IService<User> {
|
||||
*
|
||||
* @param resources /
|
||||
*/
|
||||
void createUser(User resources);
|
||||
void saveUser(User resources);
|
||||
|
||||
/**
|
||||
* 编辑用户
|
||||
@@ -42,7 +42,7 @@ public interface UserService extends IService<User> {
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteUserByIds(Set<Long> ids);
|
||||
void removeUserByIds(Set<Long> ids);
|
||||
|
||||
/**
|
||||
* 根据用户名查询
|
||||
|
||||
+2
-2
@@ -103,7 +103,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createDept(CreateDeptRequest resources) {
|
||||
public void saveDept(CreateDeptRequest resources) {
|
||||
save(BeanUtil.copyProperties(resources, Dept.class));
|
||||
// 清理缓存
|
||||
updateSubCnt(resources.getPid());
|
||||
@@ -132,7 +132,7 @@ public class DeptServiceImpl extends ServiceImpl<DeptMapper, Dept> implements De
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDeptByIds(Set<Dept> deptSet) {
|
||||
public void removeDeptByIds(Set<Dept> deptSet) {
|
||||
for (Dept dept : deptSet) {
|
||||
// 清理缓存
|
||||
delCaches(dept.getId());
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public class DictDetailServiceImpl extends ServiceImpl<DictDetailMapper, DictDet
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDictDetailById(Long id) {
|
||||
public void removeDictDetailById(Long id) {
|
||||
DictDetail dictDetail = getById(id);
|
||||
removeById(id);
|
||||
// 清理缓存
|
||||
|
||||
+2
-2
@@ -48,7 +48,7 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createDict(CreateDictRequest resources) {
|
||||
public void saveDict(CreateDictRequest resources) {
|
||||
save(BeanUtil.copyProperties(resources, Dict.class));
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class DictServiceImpl extends ServiceImpl<DictMapper, Dict> implements Di
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteDictByIds(Set<Long> ids) {
|
||||
public void removeDictByIds(Set<Long> ids) {
|
||||
// 清理缓存
|
||||
List<Dict> dicts = dictMapper.selectByIds(ids);
|
||||
for (Dict dict : dicts) {
|
||||
|
||||
+2
-2
@@ -58,7 +58,7 @@ public class JobServiceImpl extends ServiceImpl<JobMapper, Job> implements JobSe
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createJob(CreateJobRequest resources) {
|
||||
public void saveJob(CreateJobRequest resources) {
|
||||
Job job = jobMapper.getJobByName(resources.getName());
|
||||
if (job != null) {
|
||||
throw new EntityExistException(Job.class, "name", resources.getName());
|
||||
@@ -82,7 +82,7 @@ public class JobServiceImpl extends ServiceImpl<JobMapper, Job> implements JobSe
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteJobByIds(Set<Long> ids) {
|
||||
public void removeJobByIds(Set<Long> ids) {
|
||||
removeBatchByIds(ids);
|
||||
// 删除缓存
|
||||
ids.forEach(this::delCaches);
|
||||
|
||||
+2
-2
@@ -106,7 +106,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createMenu(Menu resources) {
|
||||
public void saveMenu(Menu resources) {
|
||||
if (menuMapper.getMenuByTitle(resources.getTitle()) != null) {
|
||||
throw new EntityExistException(Menu.class, "title", resources.getTitle());
|
||||
}
|
||||
@@ -196,7 +196,7 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteMenuByIds(Set<Menu> menuSet) {
|
||||
public void removeMenuByIds(Set<Menu> menuSet) {
|
||||
for (Menu menu : menuSet) {
|
||||
// 清理缓存
|
||||
delCaches(menu.getId());
|
||||
|
||||
+2
-2
@@ -81,7 +81,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createRole(CreateRoleRequest resources) {
|
||||
public void saveRole(CreateRoleRequest resources) {
|
||||
if (roleMapper.getRoleByName(resources.getName()) != null) {
|
||||
throw new EntityExistException(Role.class, "name", resources.getName());
|
||||
}
|
||||
@@ -132,7 +132,7 @@ public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements Ro
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteRoleByIds(Set<Long> ids) {
|
||||
public void removeRoleByIds(Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
// 更新相关缓存
|
||||
delCaches(id, null);
|
||||
|
||||
+2
-2
@@ -79,7 +79,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createUser(User resources) {
|
||||
public void saveUser(User resources) {
|
||||
resources.setDeptId(resources.getDept().getId());
|
||||
if (userMapper.getUserByUsername(resources.getUsername()) != null) {
|
||||
throw new EntityExistException(User.class, "username", resources.getUsername());
|
||||
@@ -167,7 +167,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteUserByIds(Set<Long> ids) {
|
||||
public void removeUserByIds(Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
// 清理缓存
|
||||
User user = getById(id);
|
||||
|
||||
+4
-4
@@ -25,14 +25,14 @@ public class EmailController {
|
||||
private final EmailService emailService;
|
||||
|
||||
@ApiOperation("查询配置")
|
||||
@PostMapping(value = "/queryEmailConfig")
|
||||
public ResponseEntity<EmailConfig> queryEmailConfig() {
|
||||
@PostMapping(value = "/describeEmailConfig")
|
||||
public ResponseEntity<EmailConfig> describeEmailConfig() {
|
||||
return new ResponseEntity<>(emailService.describeEmailConfig(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("配置邮件")
|
||||
@PostMapping(value = "/updateEmailConfig")
|
||||
public ResponseEntity<Object> updateEmailConfig(@Validated @RequestBody EmailConfig emailConfig) throws Exception {
|
||||
@PostMapping(value = "/modifyEmailConfig")
|
||||
public ResponseEntity<Object> modifyEmailConfig(@Validated @RequestBody EmailConfig emailConfig) throws Exception {
|
||||
emailService.modifyEmailConfigOnPassChange(emailConfig);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
+8
-10
@@ -15,10 +15,8 @@ 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.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@@ -50,15 +48,15 @@ public class LocalStorageController {
|
||||
}
|
||||
|
||||
@ApiOperation("上传文件")
|
||||
@PostMapping
|
||||
@PostMapping(value = "/uploadFile")
|
||||
@PreAuthorize("@el.check('storage:add')")
|
||||
public ResponseEntity<Object> createFile(@RequestParam String name, @RequestParam("file") MultipartFile file) {
|
||||
public ResponseEntity<Object> uploadFile(@RequestParam String name, @RequestParam("file") MultipartFile file) {
|
||||
localStorageService.uploadFile(name, file);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
|
||||
@ApiOperation("上传图片")
|
||||
@PostMapping("/pictures")
|
||||
@PostMapping("/uploadPicture")
|
||||
public ResponseEntity<LocalStorage> uploadPicture(@RequestParam MultipartFile file) {
|
||||
// 判断文件是否为图片
|
||||
String suffix = FileUtil.getSuffix(file.getOriginalFilename());
|
||||
@@ -70,17 +68,17 @@ public class LocalStorageController {
|
||||
}
|
||||
|
||||
@ApiOperation("修改文件")
|
||||
@PutMapping
|
||||
@PostMapping(value = "/modifyLocalStorageById")
|
||||
@PreAuthorize("@el.check('storage:edit')")
|
||||
public ResponseEntity<Object> updateFile(@Validated @RequestBody LocalStorage resources) {
|
||||
public ResponseEntity<Object> modifyLocalStorageById(@Validated @RequestBody LocalStorage resources) {
|
||||
localStorageService.modifyLocalStorageById(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@ApiOperation("多选删除")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> deleteFile(@RequestBody Long[] ids) {
|
||||
localStorageService.deleteFileByIds(ids);
|
||||
@PostMapping(value = "/removeFileByIds")
|
||||
public ResponseEntity<Object> deleteFileByIds(@RequestBody Long[] ids) {
|
||||
localStorageService.removeFileByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
+8
-8
@@ -41,14 +41,14 @@ public class QiniuController {
|
||||
private final QiNiuConfigService qiNiuConfigService;
|
||||
|
||||
@ApiOperation("查询七牛云存储配置")
|
||||
@PostMapping(value = "/queryQiNiuConfig")
|
||||
public ResponseEntity<QiniuConfig> queryQiNiuConfig() {
|
||||
@PostMapping(value = "/describeQiniuConfig")
|
||||
public ResponseEntity<QiniuConfig> describeQiniuConfig() {
|
||||
return new ResponseEntity<>(qiNiuConfigService.describeQiniuConfig(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("配置七牛云存储")
|
||||
@PostMapping(value = "/updateQiNiuConfig")
|
||||
public ResponseEntity<Object> updateQiNiuConfig(@Validated @RequestBody QiniuConfig qiniuConfig) {
|
||||
@PostMapping(value = "/modifyQiniuConfig")
|
||||
public ResponseEntity<Object> modifyQiniuConfig(@Validated @RequestBody QiniuConfig qiniuConfig) {
|
||||
qiNiuConfigService.saveQiniuConfig(qiniuConfig);
|
||||
qiNiuConfigService.modifyQiniuConfigType(qiniuConfig.getType());
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
@@ -86,8 +86,8 @@ public class QiniuController {
|
||||
}
|
||||
|
||||
@ApiOperation("下载文件")
|
||||
@GetMapping(value = "/download/{id}")
|
||||
public ResponseEntity<Object> downloadQiNiu(@PathVariable Long id) {
|
||||
@GetMapping(value = "/createFilePreviewUrl/{id}")
|
||||
public ResponseEntity<Object> createFilePreviewUrl(@PathVariable Long id) {
|
||||
Map<String, Object> map = new HashMap<>(1);
|
||||
map.put("url", qiniuContentService.createFilePreviewUrl(qiniuContentService.getById(id)));
|
||||
return new ResponseEntity<>(map, HttpStatus.OK);
|
||||
@@ -96,14 +96,14 @@ public class QiniuController {
|
||||
@ApiOperation("删除文件")
|
||||
@DeleteMapping(value = "/{id}")
|
||||
public ResponseEntity<Object> deleteQiNiu(@PathVariable Long id) {
|
||||
qiniuContentService.deleteFileById(id);
|
||||
qiniuContentService.removeFileById(id);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("删除多张图片")
|
||||
@DeleteMapping
|
||||
public ResponseEntity<Object> deleteAllQiNiu(@RequestBody Long[] ids) {
|
||||
qiniuContentService.deleteFileByIds(ids);
|
||||
qiniuContentService.removeFileByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
-8
@@ -29,12 +29,4 @@ public interface EmailService extends IService<EmailConfig> {
|
||||
* @param sendEmailRequest 邮件发送的内容
|
||||
*/
|
||||
void sendEmail(SendEmailRequest sendEmailRequest);
|
||||
|
||||
/**
|
||||
* 发送邮件验证码
|
||||
*
|
||||
* @param email 邮箱地址
|
||||
* @param key 类型
|
||||
*/
|
||||
void sendEmailCaptcha(String email, String key);
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public interface LocalStorageService extends IService<LocalStorage> {
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteFileByIds(Long[] ids);
|
||||
void removeFileByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
|
||||
+2
-2
@@ -56,7 +56,7 @@ public interface QiniuContentService extends IService<QiniuContent> {
|
||||
*
|
||||
* @param ids 文件ID数组
|
||||
*/
|
||||
void deleteFileByIds(Long[] ids);
|
||||
void removeFileByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 导出数据
|
||||
@@ -72,5 +72,5 @@ public interface QiniuContentService extends IService<QiniuContent> {
|
||||
*
|
||||
* @param id 文件id
|
||||
*/
|
||||
void deleteFileById(Long id);
|
||||
void removeFileById(Long id);
|
||||
}
|
||||
|
||||
-6
@@ -5,7 +5,6 @@ import cn.hutool.extra.mail.MailAccount;
|
||||
import cn.odboy.application.tools.mapper.EmailConfigMapper;
|
||||
import cn.odboy.application.tools.service.CaptchaService;
|
||||
import cn.odboy.application.tools.service.EmailService;
|
||||
import cn.odboy.constant.CodeEnum;
|
||||
import cn.odboy.exception.BadRequestException;
|
||||
import cn.odboy.model.tools.domain.EmailConfig;
|
||||
import cn.odboy.model.tools.request.SendEmailRequest;
|
||||
@@ -93,9 +92,4 @@ public class EmailServiceImpl extends ServiceImpl<EmailConfigMapper, EmailConfig
|
||||
throw new BadRequestException("邮件发送失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendEmailCaptcha(String email, String key) {
|
||||
emailService.sendEmail(captchaService.renderCodeTemplate(email, CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey()));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ public class LocalStorageServiceImpl extends ServiceImpl<LocalStorageMapper, Loc
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteFileByIds(Long[] ids) {
|
||||
public void removeFileByIds(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
LocalStorage storage = getById(id);
|
||||
FileUtil.del(storage.getPath());
|
||||
|
||||
+3
-3
@@ -113,7 +113,7 @@ public class QiniuContentServiceImpl extends ServiceImpl<QiniuContentMapper, Qin
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteFileById(Long id) {
|
||||
public void removeFileById(Long id) {
|
||||
QiniuConfig qiniuConfig = qiNiuConfigService.describeQiniuConfig();
|
||||
QiniuContent qiniuContent = qiniuContentMapper.selectById(id);
|
||||
if (qiniuContent == null) {
|
||||
@@ -174,11 +174,11 @@ public class QiniuContentServiceImpl extends ServiceImpl<QiniuContentMapper, Qin
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteFileByIds(Long[] ids) {
|
||||
public void removeFileByIds(Long[] ids) {
|
||||
for (Long id : ids) {
|
||||
QiniuContent qiniuContent = getById(id);
|
||||
if (qiniuContent != null) {
|
||||
deleteFileById(id);
|
||||
removeFileById(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user