mirror of
https://github.com/dqjdda/Aurora.git
synced 2018-11-06 05:33:29 +00:00
新增字典管理,代码优化
This commit is contained in:
@@ -15,7 +15,7 @@ public class CommonController {
|
||||
|
||||
@Log("访问swagger页面")
|
||||
@GetMapping(value = "/swagger/index")
|
||||
public ModelAndView swaggerIndex(){
|
||||
public ModelAndView index(){
|
||||
return new ModelAndView("/system/api/index");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
package me.aurora.app.rest.system;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.aurora.annotation.Log;
|
||||
import me.aurora.domain.Dict;
|
||||
import me.aurora.domain.ResponseEntity;
|
||||
import me.aurora.repository.spec.DictSpce;
|
||||
import me.aurora.service.DictService;
|
||||
import me.aurora.util.HttpContextUtils;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 郑杰
|
||||
* @date 2018/10/05 12:11:05
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("dict")
|
||||
public class DictController {
|
||||
|
||||
@Autowired
|
||||
private DictService dictService;
|
||||
|
||||
/**
|
||||
* 跳转到列表页面
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/index")
|
||||
public ModelAndView index(){
|
||||
return new ModelAndView("/system/dict/index");
|
||||
}
|
||||
|
||||
@Log("查询所有字典")
|
||||
@RequiresPermissions(value={"admin", "dict:all","dict:select"}, logical= Logical.OR)
|
||||
@GetMapping(value = "/getDictsInfo")
|
||||
public Map getDictsInfo(@RequestParam(value = "tableName",required = false) String tableName,
|
||||
@RequestParam(value = "fieldName",required = false) String fieldName,
|
||||
@RequestParam(value = "fieldValue",required = false) String fieldValue,
|
||||
@RequestParam(value = "fieldDetail",required = false) String fieldDetail,
|
||||
@RequestParam(value = "page",defaultValue = "1")Integer page,
|
||||
@RequestParam(value = "limit",defaultValue = "10")Integer limit){
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"id");
|
||||
Pageable pageable = PageRequest.of(page-1,limit,sort);
|
||||
return dictService.getDictInfo(new DictSpce(tableName,fieldName,fieldValue,fieldDetail),pageable);
|
||||
}
|
||||
|
||||
/**
|
||||
* 去新增页面
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions (value={"admin", "dict:all","dict:add"}, logical= Logical.OR)
|
||||
@GetMapping(value = "/toAddPage")
|
||||
public ModelAndView toAddPage(){
|
||||
return new ModelAndView("/system/dict/add");
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param dict
|
||||
* @return
|
||||
*/
|
||||
@Log("新增字典")
|
||||
@RequiresPermissions (value={"admin", "dict:all","dict:add"}, logical= Logical.OR)
|
||||
@PostMapping(value = "/insert")
|
||||
public ResponseEntity insert(@Validated(Dict.New.class) @RequestBody Dict dict){
|
||||
log.warn("REST request to insert Dict : {}"+dict);
|
||||
dictService.insert(dict);
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 去编辑页面
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions (value={"admin", "dict:all","dict:update"}, logical= Logical.OR)
|
||||
@GetMapping(value = "/toUpdatePage")
|
||||
public ModelAndView toUpdatePage(@RequestParam Long id){
|
||||
Dict dict = dictService.findById(id);
|
||||
// 获取request
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
request.setAttribute("dict",dict);
|
||||
return new ModelAndView("/system/dict/update");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param dict
|
||||
* @return
|
||||
*/
|
||||
@Log("更新字典")
|
||||
@RequiresPermissions (value={"admin", "dict:all","dict:update"}, logical= Logical.OR)
|
||||
@PutMapping(value = "/update")
|
||||
public ResponseEntity update(@Validated(Dict.Update.class) @RequestBody Dict dict) {
|
||||
log.warn("REST request to update Dict : {}" +dict);
|
||||
dictService.update(dictService.findById(dict.getId()),dict);
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Log("删除字典")
|
||||
@RequiresPermissions (value={"admin", "dict:all","dict:delete"}, logical= Logical.OR)
|
||||
@DeleteMapping(value = "/delete")
|
||||
public ResponseEntity delete(@RequestParam Long id){
|
||||
log.warn("REST request to delete Dict : {}" + id);
|
||||
dictService.delete(dictService.findById(id));
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class MenuController {
|
||||
* 构建前端路由
|
||||
*/
|
||||
@GetMapping(value = "/buildMenuUrl")
|
||||
public Object buildMenuUrl(HttpServletRequest request){
|
||||
public Object buildMenuUrl(){
|
||||
//查询出所有子菜单
|
||||
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
||||
user = userService.findById(user.getId());
|
||||
@@ -63,7 +63,7 @@ public class MenuController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到权限列表页面
|
||||
* 跳转到列表页面
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/index")
|
||||
@@ -86,7 +86,6 @@ public class MenuController {
|
||||
@RequestParam(value = "name",required = false) String name,
|
||||
@RequestParam(value = "page",defaultValue = "1")Integer page,
|
||||
@RequestParam(value = "limit",defaultValue = "10")Integer limit){
|
||||
log.warn("REST request to findAll MenusInfo");
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"id");
|
||||
Pageable pageable = PageRequest.of(page-1,2000,sort);
|
||||
return menuService.getMenuInfo(new MenuSpec(id,name),pageable);
|
||||
@@ -100,7 +99,6 @@ public class MenuController {
|
||||
@RequiresPermissions (value={"admin", "menu:all","menu:add"}, logical= Logical.OR)
|
||||
@GetMapping(value = "/toAddPage")
|
||||
public ModelAndView toAddPage(){
|
||||
log.warn("REST request to addPage");
|
||||
List<Menu> menus = menuService.findAllMenus();
|
||||
// 获取request
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
@@ -115,15 +113,14 @@ public class MenuController {
|
||||
*/
|
||||
@Log("新增菜单")
|
||||
@RequiresPermissions (value={"admin", "menu:all","menu:add"}, logical= Logical.OR)
|
||||
@PostMapping(value = "/inster")
|
||||
public ResponseEntity inster(@Validated(Menu.New.class) @RequestBody Menu menu, @RequestParam String roles){
|
||||
log.warn("REST request to inster menu");
|
||||
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
||||
@PostMapping(value = "/insert")
|
||||
public ResponseEntity insert(@Validated(Menu.New.class) @RequestBody Menu menu, @RequestParam String roles){
|
||||
log.warn("REST request to insert Menu : {} " + menu);
|
||||
Menu topMenu = null;
|
||||
if(menu.getPid() != 0){
|
||||
topMenu = menuService.findByPId(menu.getPid());
|
||||
}
|
||||
menuService.inster(menu,topMenu,roles);
|
||||
menuService.insert(menu,topMenu,roles);
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -134,11 +131,7 @@ public class MenuController {
|
||||
@RequiresPermissions (value={"admin", "menu:all","menu:update"}, logical= Logical.OR)
|
||||
@GetMapping(value = "/toUpdatePage")
|
||||
public ModelAndView toUpdatePage(@RequestParam Long id){
|
||||
log.warn("REST request to toUpdatePage");
|
||||
Menu menu = menuService.findById(id);
|
||||
if(menu == null){
|
||||
return new ModelAndView("/exception/404");
|
||||
}
|
||||
List<Menu> menus = menuService.findAllMenus();
|
||||
// 获取request
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
@@ -157,7 +150,7 @@ public class MenuController {
|
||||
@RequiresPermissions (value={"admin", "menu:all","menu:update"}, logical= Logical.OR)
|
||||
@PutMapping(value = "/update")
|
||||
public ResponseEntity update(@Validated(Menu.Update.class) @RequestBody Menu menu,@RequestParam String roles) {
|
||||
log.warn("REST request to update");
|
||||
log.warn("REST request to update Menu : {} " + menu);
|
||||
menuService.update(menu,menuService.findById(menu.getId()),roles);
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
@@ -171,7 +164,7 @@ public class MenuController {
|
||||
@RequiresPermissions (value={"admin", "menu:all","menu:delete"}, logical= Logical.OR)
|
||||
@DeleteMapping(value = "/delete")
|
||||
public ResponseEntity delete(@RequestParam Long id){
|
||||
log.warn("REST request to delete menu");
|
||||
log.warn("REST request to delete Menu : {}" +id);
|
||||
menuService.delete(menuService.findById(id));
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class PermissionController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到权限列表页面
|
||||
* 跳转到权限列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/index")
|
||||
@@ -68,7 +68,6 @@ public class PermissionController {
|
||||
@RequestParam(value = "remark",required = false) String remark,
|
||||
@RequestParam(value = "page",defaultValue = "1")Integer page,
|
||||
@RequestParam(value = "limit",defaultValue = "2000")Integer limit){
|
||||
log.warn("REST request to findAll Permission");
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"id");
|
||||
Pageable pageable = PageRequest.of(page-1,2000,sort);
|
||||
return permissionService.getPermissionInfo(new PermissionSpec(id,perms,remark),pageable);
|
||||
@@ -81,7 +80,6 @@ public class PermissionController {
|
||||
@RequiresPermissions (value={"admin", "permission:all","permission:add"}, logical= Logical.OR)
|
||||
@GetMapping(value = "/toAddPage")
|
||||
public ModelAndView toAddPage(){
|
||||
log.warn("REST request to addPage");
|
||||
List<Permission> permissionList = permissionService.findByPid(0);
|
||||
// 获取request
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
@@ -96,10 +94,10 @@ public class PermissionController {
|
||||
*/
|
||||
@Log("新增权限")
|
||||
@RequiresPermissions (value={"admin", "permission:all","permission:add"}, logical= Logical.OR)
|
||||
@PostMapping(value = "/inster")
|
||||
public ResponseEntity inster(@Validated(Permission.New.class) @RequestBody Permission permission) {
|
||||
log.warn("REST request to insterPermission");
|
||||
permissionService.inster(permission);
|
||||
@PostMapping(value = "/insert")
|
||||
public ResponseEntity insert(@Validated(Permission.New.class) @RequestBody Permission permission) {
|
||||
log.warn("REST request to insert Permission : {}"+permission);
|
||||
permissionService.insert(permission);
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -110,11 +108,7 @@ public class PermissionController {
|
||||
@RequiresPermissions (value={"admin", "permission:all","permission:update"}, logical= Logical.OR)
|
||||
@GetMapping(value = "/toUpdatePage")
|
||||
public ModelAndView toUpdatePage(@RequestParam Long id){
|
||||
log.warn("REST request to toUpdatePage");
|
||||
Permission permission = permissionService.findById(id);
|
||||
if(permission == null){
|
||||
return new ModelAndView("/exception/404");
|
||||
}
|
||||
// 获取request
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
List<Permission> permissionList = permissionService.findByPid(0);
|
||||
@@ -132,8 +126,8 @@ public class PermissionController {
|
||||
@RequiresPermissions (value={"admin", "permission:all","permission:update"}, logical= Logical.OR)
|
||||
@PutMapping(value = "/update")
|
||||
public ResponseEntity update(@Validated(Permission.New.class) @RequestBody Permission permission) {
|
||||
log.warn("REST request to insterUser");
|
||||
permissionService.update(permission);
|
||||
log.warn("REST request to update Permission : {}"+permission);
|
||||
permissionService.update(permissionService.findById(permission.getId()),permission);
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -146,7 +140,7 @@ public class PermissionController {
|
||||
@RequiresPermissions (value={"admin", "permission:all","permission:delete"}, logical= Logical.OR)
|
||||
@DeleteMapping(value = "/delete")
|
||||
public ResponseEntity delete(@RequestParam Long id) {
|
||||
log.warn("REST request to deletePermission");
|
||||
log.warn("REST request to delete Permission : {}" +id);
|
||||
permissionService.delete(permissionService.findById(id));
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.aurora.app.rest.system;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.aurora.annotation.Log;
|
||||
import me.aurora.domain.ResponseEntity;
|
||||
import me.aurora.service.RedisService;
|
||||
@@ -17,6 +18,7 @@ import java.util.Set;
|
||||
* @author 郑杰
|
||||
* @date 2018/09/22 10:48:11
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("redis")
|
||||
public class RedisController {
|
||||
@@ -28,7 +30,7 @@ public class RedisController {
|
||||
|
||||
@GetMapping("terminal")
|
||||
@RequiresPermissions (value={"admin", "redis:all","redis:terminal"}, logical= Logical.OR)
|
||||
public ModelAndView redisTerminal(Model model) {
|
||||
public ModelAndView terminal(Model model) {
|
||||
String osName = System.getProperty("os.name");
|
||||
model.addAttribute("osName", osName);
|
||||
return new ModelAndView("/system/redis/terminal");
|
||||
@@ -37,6 +39,7 @@ public class RedisController {
|
||||
@Log("执行Redis keys命令")
|
||||
@GetMapping("keys")
|
||||
public ResponseEntity keys(String arg) {
|
||||
log.warn("REST request to keys Redis : {}" +arg);
|
||||
try {
|
||||
Set<String> set = this.redisService.getKeys(arg);
|
||||
return ResponseEntity.ok(set);
|
||||
@@ -48,6 +51,7 @@ public class RedisController {
|
||||
@Log("执行Redis get命令")
|
||||
@GetMapping("get")
|
||||
public ResponseEntity get(String arg) {
|
||||
log.warn("REST request to get Redis : {}" +arg);
|
||||
try {
|
||||
String result = this.redisService.get(arg);
|
||||
return ResponseEntity.ok(result == null ? "" : result);
|
||||
@@ -59,6 +63,7 @@ public class RedisController {
|
||||
@Log("执行Redis set命令")
|
||||
@GetMapping("set")
|
||||
public ResponseEntity set(String arg) {
|
||||
log.warn("REST request to set Redis : {}" +arg);
|
||||
try {
|
||||
String[] args = arg.split(",");
|
||||
if (args.length == 1){
|
||||
@@ -76,6 +81,7 @@ public class RedisController {
|
||||
@Log("执行Redis del命令")
|
||||
@GetMapping("del")
|
||||
public ResponseEntity del(String arg) {
|
||||
log.warn("REST request to del Redis : {}" +arg);
|
||||
try {
|
||||
String[] args = arg.split(",");
|
||||
Long result = this.redisService.del(args);
|
||||
@@ -88,6 +94,7 @@ public class RedisController {
|
||||
@Log("执行Redis exists命令")
|
||||
@GetMapping("exists")
|
||||
public ResponseEntity exists(String arg) {
|
||||
log.warn("REST request to exists Redis : {}" +arg);
|
||||
try {
|
||||
int count = 0;
|
||||
String[] arr = arg.split(",");
|
||||
@@ -105,6 +112,7 @@ public class RedisController {
|
||||
@Log("执行Redis pttl命令")
|
||||
@GetMapping("pttl")
|
||||
public ResponseEntity pttl(String arg) {
|
||||
log.warn("REST request to pttl Redis : {}" +arg);
|
||||
try {
|
||||
return ResponseEntity.ok(INTEGER_PREFIX + this.redisService.pttl(arg));
|
||||
} catch (Exception e) {
|
||||
@@ -115,6 +123,7 @@ public class RedisController {
|
||||
@Log("执行Redis pexpire命令")
|
||||
@GetMapping("pexpire")
|
||||
public ResponseEntity pexpire(String arg) {
|
||||
log.warn("REST request to pexpire Redis : {}" +arg);
|
||||
try {
|
||||
String[] arr = arg.split(",");
|
||||
if (arr.length != 2 || !isValidLong(arr[1])) {
|
||||
@@ -129,6 +138,7 @@ public class RedisController {
|
||||
@Log("执行flushdb命令")
|
||||
@GetMapping("flushdb")
|
||||
public ResponseEntity flushdb() {
|
||||
log.warn("REST request to flushdb Redis : {}");
|
||||
try {
|
||||
return ResponseEntity.ok(INTEGER_PREFIX + this.redisService.flushdb());
|
||||
} catch (Exception e) {
|
||||
@@ -139,6 +149,7 @@ public class RedisController {
|
||||
@Log("执行flushall命令")
|
||||
@GetMapping("flushall")
|
||||
public ResponseEntity flushall() {
|
||||
log.warn("REST request to flushall Redis : {}");
|
||||
try {
|
||||
return ResponseEntity.ok(INTEGER_PREFIX + this.redisService.flushall());
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class RoleController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到角色列表页面
|
||||
* 跳转到角色列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/index")
|
||||
@@ -68,7 +68,6 @@ public class RoleController {
|
||||
@RequestParam(value = "remark",required = false) String remark,
|
||||
@RequestParam(value = "page",defaultValue = "1")Integer page,
|
||||
@RequestParam(value = "limit",defaultValue = "10")Integer limit){
|
||||
log.warn("REST request to findAll roles");
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"id");
|
||||
Pageable pageable = PageRequest.of(page-1,limit,sort);
|
||||
return roleService.getRoleInfo(new RoleSpec(id,name,remark),pageable);
|
||||
@@ -93,10 +92,10 @@ public class RoleController {
|
||||
*/
|
||||
@Log("新增角色")
|
||||
@RequiresPermissions (value={"admin", "role:all","role:add"}, logical= Logical.OR)
|
||||
@PostMapping(value = "/inster")
|
||||
public ResponseEntity inster(@Validated(Role.New.class) @RequestBody Role role, @RequestParam String permissions) {
|
||||
log.warn("REST request to insterRoles");
|
||||
roleService.inster(role,permissions);
|
||||
@PostMapping(value = "/insert")
|
||||
public ResponseEntity insert(@Validated(Role.New.class) @RequestBody Role role, @RequestParam String permissions) {
|
||||
log.warn("REST request to insert Role : {}" +role);
|
||||
roleService.insert(role,permissions);
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -107,12 +106,8 @@ public class RoleController {
|
||||
@RequiresPermissions (value={"admin", "role:all","role:update"}, logical= Logical.OR)
|
||||
@GetMapping(value = "/toUpdatePage")
|
||||
public ModelAndView toUpdatePage(@RequestParam Long id){
|
||||
log.warn("REST request to toUpdatePage");
|
||||
Role role = roleService.findById(id);
|
||||
String permissionSelect = roleService.getPermissions(role.getPermissions());
|
||||
if(role == null){
|
||||
return new ModelAndView("/exception/404");
|
||||
}
|
||||
// 获取request
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
request.setAttribute("role", roleMapper.toDto(role));
|
||||
@@ -130,8 +125,8 @@ public class RoleController {
|
||||
@RequiresPermissions (value={"admin", "role:all","role:update"}, logical= Logical.OR)
|
||||
@PutMapping(value = "/update")
|
||||
public ResponseEntity update(@Validated(Role.Update.class) @RequestBody Role role,@RequestParam String permissions) {
|
||||
log.warn("REST request to insterUser");
|
||||
roleService.update(role,permissions);
|
||||
log.warn("REST request to update Role : {}" +role);
|
||||
roleService.update(roleService.findById(role.getId()),role,permissions);
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -144,7 +139,7 @@ public class RoleController {
|
||||
@RequiresPermissions (value={"admin", "role:all","role:delete"}, logical= Logical.OR)
|
||||
@DeleteMapping(value = "/delete")
|
||||
public ResponseEntity delete(@RequestParam Long id) {
|
||||
log.warn("REST request to deleteRole");
|
||||
log.warn("REST request to delete Role : {}" +id);
|
||||
roleService.delete(roleService.findById(id));
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public class SessionController {
|
||||
@RequiresPermissions(value={"admin", "user:all","user:logout"}, logical= Logical.OR)
|
||||
@DeleteMapping("/forceLogout")
|
||||
public ResponseEntity forceLogout(String id) {
|
||||
log.warn("REST request to forceLogout User : {}" +id);
|
||||
sessionService.forceLogout(id);
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package me.aurora.app.rest.system;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.aurora.repository.spec.LogSpec;
|
||||
import me.aurora.service.SysLogService;
|
||||
import org.apache.shiro.authz.annotation.Logical;
|
||||
@@ -17,7 +16,6 @@ import java.util.Map;
|
||||
* @author 郑杰
|
||||
* @date 2018/08/23 9:57:14
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("sysLog")
|
||||
public class SysLogController {
|
||||
@@ -31,7 +29,6 @@ public class SysLogController {
|
||||
*/
|
||||
@GetMapping(value = "/index")
|
||||
public ModelAndView index(){
|
||||
log.warn("REST request to toLogPage");
|
||||
return new ModelAndView("/system/log/index");
|
||||
}
|
||||
|
||||
@@ -53,7 +50,6 @@ public class SysLogController {
|
||||
@RequestParam(value = "location",required = false) String location,
|
||||
@RequestParam(value = "page",defaultValue = "1")Integer page,
|
||||
@RequestParam(value = "limit",defaultValue = "10")Integer limit){
|
||||
log.warn("REST request to findAll Log");
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"createTime");
|
||||
Pageable pageable = PageRequest.of(page-1,limit,sort);
|
||||
return sysLogService.getLogInfo(new LogSpec(username,method,operation,location),pageable);
|
||||
|
||||
@@ -70,7 +70,6 @@ public class UserController {
|
||||
@RequestParam(value = "enabled",required = false) Long enabled,
|
||||
@RequestParam(value = "page",defaultValue = "1")Integer page,
|
||||
@RequestParam(value = "limit",defaultValue = "10")Integer limit){
|
||||
log.warn("REST request to findAll User");
|
||||
Sort sort = new Sort(Sort.Direction.ASC,"id");
|
||||
Pageable pageable = PageRequest.of(page-1,limit,sort);
|
||||
return userService.getUsersInfo(new UserSpec(username,email,enabled,id),pageable);
|
||||
@@ -83,7 +82,6 @@ public class UserController {
|
||||
@RequiresPermissions (value={"admin", "user:all","user:add"}, logical= Logical.OR)
|
||||
@GetMapping(value = "/toAddPage")
|
||||
public ModelAndView toAddPage(){
|
||||
log.warn("REST request to addPage");
|
||||
return new ModelAndView("/user/add");
|
||||
}
|
||||
|
||||
@@ -95,13 +93,13 @@ public class UserController {
|
||||
*/
|
||||
@Log("新增用户")
|
||||
@RequiresPermissions (value={"admin", "user:all","user:add"}, logical= Logical.OR)
|
||||
@PostMapping(value = "/inster")
|
||||
public ResponseEntity inster(@Validated(User.New.class) @RequestBody User user, @RequestParam String roles) {
|
||||
log.warn("REST request to insterUser");
|
||||
@PostMapping(value = "/insert")
|
||||
public ResponseEntity insert(@Validated(User.New.class) @RequestBody User user, @RequestParam String roles) {
|
||||
log.warn("REST request to insert User : {}" +user);
|
||||
if(StrUtil.hasEmpty(roles)){
|
||||
return ResponseEntity.error(HttpStatus.HTTP_NOT_FOUND,"角色为空,请至少为其分配一个角色");
|
||||
}
|
||||
userService.inster(user,roles);
|
||||
userService.insert(user,roles);
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -112,11 +110,7 @@ public class UserController {
|
||||
@RequiresPermissions (value={"admin", "user:all","user:update"}, logical= Logical.OR)
|
||||
@GetMapping(value = "/toUpdatePage")
|
||||
public ModelAndView toUpdatePage(@RequestParam Long id){
|
||||
log.warn("REST request to toUpdatePage");
|
||||
User user = userService.findById(id);
|
||||
if(user == null){
|
||||
return new ModelAndView("/exception/404");
|
||||
}
|
||||
// 获取request
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
String rolesSelect = roleService.getRoles(user.getRoles());
|
||||
@@ -134,7 +128,7 @@ public class UserController {
|
||||
@RequiresPermissions (value={"admin", "user:all","user:update"}, logical= Logical.OR)
|
||||
@PutMapping(value = "/update")
|
||||
public ResponseEntity update(@Validated(User.Update.class) @RequestBody User user, @RequestParam String roles) {
|
||||
log.warn("REST request to insterUser");
|
||||
log.warn("REST request to update User : {}" +user);
|
||||
if(StrUtil.hasEmpty(roles)){
|
||||
return ResponseEntity.error(HttpStatus.HTTP_NOT_FOUND,"角色为空,请至少为其分配一个角色");
|
||||
}
|
||||
@@ -151,7 +145,7 @@ public class UserController {
|
||||
@RequiresPermissions (value={"admin", "user:all","user:lock"}, logical= Logical.OR)
|
||||
@PutMapping(value = "/updateEnabled")
|
||||
public ResponseEntity updateEnabled(@RequestParam Long id){
|
||||
log.warn("REST request to updateEnabled");
|
||||
log.warn("REST request to updateEnabled User : {}" +id);
|
||||
userService.updateEnabled(userService.findById(id));
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
@@ -165,7 +159,7 @@ public class UserController {
|
||||
@RequiresPermissions (value={"admin", "user:all","user:delete"}, logical= Logical.OR)
|
||||
@DeleteMapping(value = "/delete")
|
||||
public ResponseEntity delete(@RequestParam Long id) {
|
||||
log.warn("REST request to deleteUser");
|
||||
log.warn("REST request to delete User : {}" +id);
|
||||
userService.delete(userService.findById(id));
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class UserSecurityController {
|
||||
@Log("用户登录")
|
||||
@PostMapping(value = "/login")
|
||||
public ResponseEntity login(@RequestParam String username, @RequestParam String password, @RequestParam Boolean rememberMe){
|
||||
log.warn("REST request to login User: "+username);
|
||||
log.warn("REST request to login User : {}"+username);
|
||||
password = EncryptHelper.encrypt(password);
|
||||
UsernamePasswordToken token = new UsernamePasswordToken(username, password, rememberMe);
|
||||
Subject subject = SecurityUtils.getSubject();
|
||||
@@ -54,6 +54,7 @@ public class UserSecurityController {
|
||||
|
||||
@GetMapping("/index")
|
||||
public ModelAndView index() {
|
||||
log.warn("REST request to index User : {}");
|
||||
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
||||
user = userService.findById(user.getId());
|
||||
// 获取request
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package me.aurora.app.rest.utils;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.aurora.annotation.Log;
|
||||
import me.aurora.domain.ResponseEntity;
|
||||
import me.aurora.domain.utils.AlipayConfig;
|
||||
@@ -22,6 +23,7 @@ import java.util.Map;
|
||||
* @author zhengjie
|
||||
* @date 2018/07/27 13:41:41
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/aliPay")
|
||||
public class AliPayController {
|
||||
@@ -37,7 +39,7 @@ public class AliPayController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/index")
|
||||
public ModelAndView emailIndex(){
|
||||
public ModelAndView index(){
|
||||
AlipayConfig alipay = alipayService.findById(1L);
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
request.setAttribute("alipay",alipay);
|
||||
@@ -49,7 +51,8 @@ public class AliPayController {
|
||||
|
||||
@Log("配置支付宝参数")
|
||||
@PostMapping(value = "/config")
|
||||
public ResponseEntity emailConfig(@Validated(AlipayConfig.New.class) @RequestBody AlipayConfig alipayConfig){
|
||||
public ResponseEntity payConfig(@Validated(AlipayConfig.New.class) @RequestBody AlipayConfig alipayConfig){
|
||||
log.warn("REST request to payConfig AlipayConfig : {}" +alipayConfig);
|
||||
alipayConfig.setId(1L);
|
||||
alipayService.updateConfig(alipayConfig);
|
||||
return ResponseEntity.ok();
|
||||
@@ -59,6 +62,7 @@ public class AliPayController {
|
||||
@ApiOperation(value = "PC网页支付")
|
||||
@PostMapping(value = "/toPayAsPC")
|
||||
public ResponseEntity toPayAsPC(@Validated(TradeVo.New.class) @RequestBody TradeVo trade) throws Exception{
|
||||
log.warn("REST request to toPayAsPC Trade : {}" +trade);
|
||||
AlipayConfig alipay = alipayService.findById(1L);
|
||||
trade.setOutTradeNo(alipayUtils.getOrderCode());
|
||||
String payUrl = alipayService.toPayAsPC(alipay,trade);
|
||||
@@ -69,6 +73,7 @@ public class AliPayController {
|
||||
@ApiOperation(value = "手机网页支付")
|
||||
@PostMapping(value = "/toPayAsWeb")
|
||||
public ResponseEntity toPayAsWeb(@Validated(TradeVo.New.class) @RequestBody TradeVo trade) throws Exception{
|
||||
log.warn("REST request to toPayAsWeb Trade : {}" +trade);
|
||||
AlipayConfig alipay = alipayService.findById(1L);
|
||||
trade.setOutTradeNo(alipayUtils.getOrderCode());
|
||||
String payUrl = alipayService.toPayAsWeb(alipay,trade);
|
||||
@@ -98,7 +103,7 @@ public class AliPayController {
|
||||
/**
|
||||
* 根据业务需要返回数据
|
||||
*/
|
||||
return ResponseEntity.ok();
|
||||
return ResponseEntity.error();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package me.aurora.app.rest.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.aurora.annotation.Log;
|
||||
import me.aurora.domain.ResponseEntity;
|
||||
import me.aurora.domain.utils.EmailConfig;
|
||||
@@ -17,6 +18,7 @@ import javax.servlet.http.HttpServletRequest;
|
||||
* @author 郑杰
|
||||
* @date 2018/09/28 6:55:53
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("email")
|
||||
public class EmailController {
|
||||
@@ -25,7 +27,7 @@ public class EmailController {
|
||||
private EmailService emailService;
|
||||
|
||||
@GetMapping(value = "/index")
|
||||
public ModelAndView emailIndex(){
|
||||
public ModelAndView index(){
|
||||
EmailConfig emailConfig = emailService.findById(1L);
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
request.setAttribute("email",emailConfig);
|
||||
@@ -38,6 +40,7 @@ public class EmailController {
|
||||
@Log("配置邮件")
|
||||
@PostMapping(value = "/config")
|
||||
public ResponseEntity emailConfig(@RequestBody @Validated(EmailConfig.Update.class) EmailConfig emailConfig){
|
||||
log.warn("REST request to emailConfig EmailConfig : {}" +emailConfig);
|
||||
emailConfig.setId(1L);
|
||||
emailService.updateConfig(emailConfig,emailService.findById(1L));
|
||||
return ResponseEntity.ok();
|
||||
@@ -46,6 +49,7 @@ public class EmailController {
|
||||
@Log("发送邮件")
|
||||
@PostMapping(value = "send")
|
||||
public ResponseEntity send(@Validated(EmailVo.New.class) @RequestBody EmailVo emailVo) throws Exception {
|
||||
log.warn("REST request to send Email : {}" +emailVo);
|
||||
emailService.send(emailVo,emailService.findById(1L));
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ public class PictureController {
|
||||
*/
|
||||
@GetMapping(value = "/index")
|
||||
public ModelAndView index(){
|
||||
log.warn("REST request to PicturePage");
|
||||
return new ModelAndView("/utils/picture/index");
|
||||
}
|
||||
|
||||
@@ -58,8 +57,6 @@ public class PictureController {
|
||||
@RequestParam(value = "endTime",required = false) Timestamp endTime,
|
||||
@RequestParam(value = "page",defaultValue = "1")Integer page,
|
||||
@RequestParam(value = "limit",defaultValue = "10")Integer limit){
|
||||
|
||||
log.warn("REST request to findAll Log");
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"createTime");
|
||||
Pageable pageable = PageRequest.of(page-1,limit,sort);
|
||||
return pictureService.getPictureInfo(new PictureSpec(username,createTime,endTime),pageable);
|
||||
@@ -72,7 +69,6 @@ public class PictureController {
|
||||
@RequiresPermissions (value={"admin", "picture:all","picture:upload"}, logical= Logical.OR)
|
||||
@GetMapping(value = "/toAddPage")
|
||||
public ModelAndView toAddPage(){
|
||||
log.warn("REST request to addPicturePage");
|
||||
return new ModelAndView("/utils/picture/add");
|
||||
}
|
||||
|
||||
@@ -85,7 +81,8 @@ public class PictureController {
|
||||
@Log("上传图片")
|
||||
@RequiresPermissions (value={"admin", "picture:all","picture:upload"}, logical= Logical.OR)
|
||||
@PostMapping(value = "/upload")
|
||||
public ResponseEntity upload(@RequestParam MultipartFile file) throws Exception {
|
||||
public ResponseEntity upload(@RequestParam MultipartFile file){
|
||||
log.warn("REST request to upload Picture : {}" +file.getOriginalFilename());
|
||||
User user = (User) SecurityUtils.getSubject().getPrincipal();
|
||||
pictureService.upload(file,user);
|
||||
return ResponseEntity.ok();
|
||||
@@ -100,7 +97,7 @@ public class PictureController {
|
||||
@RequiresPermissions (value={"admin", "picture:all","picture:delete"}, logical= Logical.OR)
|
||||
@DeleteMapping(value = "/delete")
|
||||
public ResponseEntity delete(@RequestParam Long id) {
|
||||
log.warn("REST request to delete picture");
|
||||
log.warn("REST request to delete Picture : {}" +id);
|
||||
pictureService.delete(pictureService.findById(id));
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class QiniuController {
|
||||
private QiNiuService qiNiuService;
|
||||
|
||||
@GetMapping(value = "/index")
|
||||
public ModelAndView emailIndex(){
|
||||
public ModelAndView index(){
|
||||
QiniuConfig qiniuConfig = qiNiuService.findById(1L);
|
||||
HttpServletRequest request = HttpContextUtils.getHttpServletRequest();
|
||||
request.setAttribute("qiniuConfig",qiniuConfig);
|
||||
@@ -55,7 +55,6 @@ public class QiniuController {
|
||||
public Map getContentInfo(@RequestParam(value = "name",required = false) String name,
|
||||
@RequestParam(value = "page",defaultValue = "1")Integer page,
|
||||
@RequestParam(value = "limit",defaultValue = "10")Integer limit){
|
||||
log.warn("REST request to findAll Log");
|
||||
Sort sort = new Sort(Sort.Direction.DESC,"updateTime");
|
||||
Pageable pageable = PageRequest.of(page-1,limit,sort);
|
||||
QiniuConfig qiniuConfig = qiNiuService.findById(1L);
|
||||
@@ -67,7 +66,8 @@ public class QiniuController {
|
||||
|
||||
@Log("配置七牛对象存储")
|
||||
@PostMapping(value = "/config")
|
||||
public ResponseEntity emailConfig(@RequestBody @Validated(QiniuConfig.Update.class) QiniuConfig qiniuConfig){
|
||||
public ResponseEntity qiNiuConfig(@RequestBody @Validated(QiniuConfig.Update.class) QiniuConfig qiniuConfig){
|
||||
log.warn("REST request to qiNiuConfig QiniuConfig : {}" +qiniuConfig);
|
||||
qiniuConfig.setId(1L);
|
||||
qiNiuService.updateConfig(qiniuConfig);
|
||||
return ResponseEntity.ok();
|
||||
@@ -79,7 +79,6 @@ public class QiniuController {
|
||||
*/
|
||||
@GetMapping(value = "/toAddPage")
|
||||
public ModelAndView toAddPage(){
|
||||
log.warn("REST request to addPage");
|
||||
return new ModelAndView("/utils/qiNiu/add");
|
||||
}
|
||||
|
||||
@@ -91,6 +90,7 @@ public class QiniuController {
|
||||
@Log("上传文件到七牛云")
|
||||
@PostMapping(value = "/upload")
|
||||
public ResponseEntity upload(@RequestParam MultipartFile file){
|
||||
log.warn("REST request to upload qiNiu : {}" +file.getOriginalFilename());
|
||||
qiNiuService.upload(file,qiNiuService.findById(1L));
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
@@ -101,6 +101,7 @@ public class QiniuController {
|
||||
@Log("同步七牛云数据到数据库")
|
||||
@PostMapping(value = "/synchronize")
|
||||
public ResponseEntity synchronize(){
|
||||
log.warn("REST request to synchronize qiNiu : {}");
|
||||
qiNiuService.synchronize(qiNiuService.findById(1L));
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
@@ -114,6 +115,7 @@ public class QiniuController {
|
||||
@Log("下载七牛云文件")
|
||||
@PostMapping(value = "/download")
|
||||
public ResponseEntity download(@RequestParam Long id) throws UnsupportedEncodingException {
|
||||
log.warn("REST request to download qiNiu : {}" +id);
|
||||
return qiNiuService.download(qiNiuService.findByContentId(id),qiNiuService.findById(1L));
|
||||
}
|
||||
|
||||
@@ -126,6 +128,7 @@ public class QiniuController {
|
||||
@Log("删除七牛云文件")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public ResponseEntity delete(@RequestParam Long id) throws UnsupportedEncodingException {
|
||||
log.warn("REST request to delete qiNiu : {}" +id);
|
||||
qiNiuService.delete(qiNiuService.findByContentId(id),qiNiuService.findById(1L));
|
||||
return ResponseEntity.ok();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package me.aurora.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
/**
|
||||
* 字典表
|
||||
* @author 郑杰
|
||||
* @date 2018/10/05 12:08:24
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "zj_dict")
|
||||
public class Dict implements Serializable {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@NotBlank(groups = {Menu.New.class, Menu.Update.class})
|
||||
@Column(name = "table_name",nullable = false)
|
||||
private String tableName;
|
||||
|
||||
@NotBlank(groups = {Menu.New.class, Menu.Update.class})
|
||||
@Column(name = "fteld_name",nullable = false)
|
||||
private String fieldName;
|
||||
|
||||
@NotBlank(groups = {Menu.New.class, Menu.Update.class})
|
||||
@Column(name = "field_value",nullable = false)
|
||||
private String fieldValue;
|
||||
|
||||
@Column(name = "field_detail",nullable = false)
|
||||
@NotBlank(groups = {Menu.New.class, Menu.Update.class})
|
||||
private String fieldDetail;
|
||||
|
||||
@CreationTimestamp
|
||||
private Timestamp createTime;
|
||||
|
||||
@UpdateTimestamp
|
||||
private Timestamp updateTime;
|
||||
|
||||
public interface New{};
|
||||
public interface Update{};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package me.aurora.repository;
|
||||
|
||||
import me.aurora.domain.Dict;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @author 郑杰
|
||||
* @date 2018/09/28 7:12:43
|
||||
*/
|
||||
public interface DictRepo extends JpaRepository<Dict,Long>, JpaSpecificationExecutor {
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package me.aurora.repository.spec;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import me.aurora.domain.Dict;
|
||||
import org.springframework.data.jpa.domain.Specification;
|
||||
import javax.persistence.criteria.CriteriaBuilder;
|
||||
import javax.persistence.criteria.CriteriaQuery;
|
||||
import javax.persistence.criteria.Predicate;
|
||||
import javax.persistence.criteria.Root;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author 郑杰
|
||||
* @date 2018/09/01 7:12:01
|
||||
*/
|
||||
public class DictSpce implements Specification<Dict> {
|
||||
|
||||
private String tableName;
|
||||
private String fieldName;
|
||||
private String fieldValue;
|
||||
private String fieldDetail;
|
||||
|
||||
public DictSpce(String tableName, String fieldName, String fieldValue, String fieldDetail) {
|
||||
this.tableName = tableName;
|
||||
this.fieldName = fieldName;
|
||||
this.fieldValue = fieldValue;
|
||||
this.fieldDetail = fieldDetail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Predicate toPredicate(Root<Dict> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder cb) {
|
||||
List<Predicate> list = new ArrayList<Predicate>();
|
||||
|
||||
|
||||
if (!StrUtil.isEmpty(tableName)) {
|
||||
list.add(cb.like(root.get("tableName").as(String.class), "%" + tableName + "%" ));
|
||||
}
|
||||
|
||||
if (!StrUtil.isEmpty(fieldName)) {
|
||||
list.add(cb.like(root.get("method").as(String.class), "%" + fieldName + "%" ));
|
||||
}
|
||||
|
||||
if (!StrUtil.isEmpty(fieldValue)) {
|
||||
list.add(cb.like(root.get("operation").as(String.class), "%" + fieldValue + "%" ));
|
||||
}
|
||||
|
||||
if (!StrUtil.isEmpty(fieldDetail)) {
|
||||
list.add(cb.like(root.get("location").as(String.class), "%" + fieldDetail + "%" ));
|
||||
}
|
||||
|
||||
Predicate[] p = new Predicate[list.size()];
|
||||
return cb.and(list.toArray(p));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DictSpce{" +
|
||||
"tableName='" + tableName + '\'' +
|
||||
", fieldName='" + fieldName + '\'' +
|
||||
", fieldValue='" + fieldValue + '\'' +
|
||||
", fieldDetail='" + fieldDetail + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -37,7 +37,7 @@ public interface AlipayService {
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(key = "#p0")
|
||||
AlipayConfig findById(long id);
|
||||
AlipayConfig findById(Long id);
|
||||
|
||||
/**
|
||||
* 更新配置
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package me.aurora.service;
|
||||
|
||||
import me.aurora.domain.Dict;
|
||||
import me.aurora.repository.spec.DictSpce;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 郑杰
|
||||
* @date 2018/10/05 12:08:53
|
||||
*/
|
||||
@CacheConfig(cacheNames = "dict")
|
||||
public interface DictService {
|
||||
|
||||
/**
|
||||
* 查询全部字典
|
||||
* @param dictSpce
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(keyGenerator = "keyGenerator")
|
||||
Map getDictInfo(DictSpce dictSpce, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
* @param dict
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void insert(Dict dict);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(key = "#p0")
|
||||
Dict findById(Long id);
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param old
|
||||
* @param dict
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void update(Dict old, Dict dict);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param dict
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void delete(Dict dict);
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public interface MenuService {
|
||||
* @param roles
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void inster(Menu menu, Menu topMenu, String roles);
|
||||
void insert(Menu menu, Menu topMenu, String roles);
|
||||
|
||||
/**
|
||||
* 根据PID查询菜单
|
||||
|
||||
@@ -3,7 +3,6 @@ package me.aurora.service;
|
||||
import me.aurora.domain.Permission;
|
||||
import me.aurora.domain.Role;
|
||||
import me.aurora.repository.spec.PermissionSpec;
|
||||
import me.aurora.config.exception.AuroraException;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@@ -34,7 +33,7 @@ public interface PermissionService {
|
||||
* @return
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void inster(Permission permission);
|
||||
void insert(Permission permission);
|
||||
|
||||
/**
|
||||
* 根据id查询权限
|
||||
@@ -46,11 +45,13 @@ public interface PermissionService {
|
||||
|
||||
/**
|
||||
* 更新权限
|
||||
*
|
||||
* @param old
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void update(Permission permission);
|
||||
void update(Permission old, Permission permission);
|
||||
|
||||
/**
|
||||
* 删除权限
|
||||
|
||||
@@ -27,7 +27,7 @@ public interface QiNiuService {
|
||||
* @return
|
||||
*/
|
||||
@Cacheable(key = "#p0")
|
||||
QiniuConfig findById(long id);
|
||||
QiniuConfig findById(Long id);
|
||||
|
||||
/**
|
||||
* 修改配置
|
||||
|
||||
@@ -50,7 +50,7 @@ public interface RoleService {
|
||||
* @return
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void inster(Role role, String permissions);
|
||||
void insert(Role role, String permissions);
|
||||
|
||||
/**
|
||||
* 根据ID查找Role
|
||||
@@ -63,11 +63,12 @@ public interface RoleService {
|
||||
/**
|
||||
* 更新角色
|
||||
* @param role
|
||||
* @param old
|
||||
* @param permissions
|
||||
* @return
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void update(Role role, String permissions);
|
||||
void update(Role old,Role role, String permissions);
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
|
||||
@@ -55,7 +55,7 @@ public interface UserService {
|
||||
* @return
|
||||
*/
|
||||
@CacheEvict(allEntries = true)
|
||||
void inster(User user, String roles);
|
||||
void insert(User user, String roles);
|
||||
|
||||
/**
|
||||
* 更新用户
|
||||
|
||||
@@ -115,7 +115,10 @@ public class AlipayServiceImpl implements AlipayService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlipayConfig findById(long id) {
|
||||
public AlipayConfig findById(Long id) {
|
||||
if(id == null){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"id not exist");
|
||||
}
|
||||
Optional<AlipayConfig> alipayConfig = alipayRepo.findById(1L);
|
||||
if (alipayConfig.isPresent()){
|
||||
return alipayConfig.get();
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package me.aurora.service.impl;
|
||||
|
||||
import cn.hutool.http.HttpStatus;
|
||||
import me.aurora.config.exception.AuroraException;
|
||||
import me.aurora.domain.Dict;
|
||||
import me.aurora.repository.DictRepo;
|
||||
import me.aurora.repository.spec.DictSpce;
|
||||
import me.aurora.service.DictService;
|
||||
import me.aurora.util.PageUtil;
|
||||
import me.aurora.util.ValidationUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* @author 郑杰
|
||||
* @date 2018/10/05 12:09:28
|
||||
*/
|
||||
@Service
|
||||
public class DictServiceImpl implements DictService {
|
||||
|
||||
@Autowired
|
||||
private DictRepo dictRepo;
|
||||
|
||||
@Override
|
||||
public Map getDictInfo(DictSpce dictSpce, Pageable pageable) {
|
||||
Page<Dict> dicts = dictRepo.findAll(dictSpce,pageable);
|
||||
return PageUtil.buildPage(dicts.getContent(),dicts.getTotalElements());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insert(Dict dict) {
|
||||
dictRepo.save(dict);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dict findById(Long id) {
|
||||
if(id == null){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"id not exist");
|
||||
}
|
||||
Optional<Dict> dict = dictRepo.findById(id);
|
||||
ValidationUtil.isNull(dict,"id:"+id+" is not find");
|
||||
return dict.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Dict old, Dict dict) {
|
||||
dict.setCreateTime(old.getCreateTime());
|
||||
dictRepo.save(dict);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delete(Dict dict) {
|
||||
dictRepo.delete(dict);
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,9 @@ public class EmailServiceImpl implements EmailService {
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public EmailConfig findById(Long id) {
|
||||
if(id == null){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"id not exist");
|
||||
}
|
||||
Optional<EmailConfig> emailConfig = emailRepo.findById(id);
|
||||
if(emailConfig.isPresent()){
|
||||
return emailConfig.get();
|
||||
|
||||
@@ -81,6 +81,9 @@ public class MenuServiceImpl implements MenuService {
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Menu findByPId(Integer pid) {
|
||||
if(pid == null){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"pid not exist");
|
||||
}
|
||||
Optional<Menu> menu = menuRepo.findById(pid.longValue());
|
||||
ValidationUtil.isNull(menu,"pid:"+pid+"is not find");
|
||||
return menu.get();
|
||||
@@ -88,7 +91,7 @@ public class MenuServiceImpl implements MenuService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
public void inster(Menu menu, Menu topMenu, String roles) {
|
||||
public void insert(Menu menu, Menu topMenu, String roles) {
|
||||
validation(menu);
|
||||
if(topMenu == null){
|
||||
menu.setLevel(1);
|
||||
@@ -136,6 +139,9 @@ public class MenuServiceImpl implements MenuService {
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Menu findById(Long id) {
|
||||
if(id == null){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"id not exist");
|
||||
}
|
||||
Optional<Menu> menu = menuRepo.findById(id);
|
||||
ValidationUtil.isNull(menu,"id:"+id+"is not find");
|
||||
return menu.get();
|
||||
|
||||
@@ -41,7 +41,7 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inster(Permission permission) throws AuroraException {
|
||||
public void insert(Permission permission) throws AuroraException {
|
||||
if(permissionRepo.findByPerms(permission.getPerms())!=null){
|
||||
throw new AuroraException(HttpStatus.HTTP_BAD_REQUEST,"权限已存在");
|
||||
}
|
||||
@@ -51,20 +51,21 @@ public class PermissionServiceImpl implements PermissionService {
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Permission findById(Long id) {
|
||||
if(id == null){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"id not exist");
|
||||
}
|
||||
Optional<Permission> permission = permissionRepo.findById(id);
|
||||
ValidationUtil.isNull(permission,"id:"+id+"is not find");
|
||||
return permission.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Permission permission) throws AuroraException {
|
||||
if(null == permission.getId()){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"权限ID不能为空");
|
||||
}
|
||||
Permission old = permissionRepo.findByPerms(permission.getPerms());
|
||||
if(old !=null && !old.getId().equals(permission.getId())){
|
||||
public void update(Permission old, Permission permission) throws AuroraException {
|
||||
Permission permission1 = permissionRepo.findByPerms(permission.getPerms());
|
||||
if(permission1 !=null && !permission1.getId().equals(permission.getId())){
|
||||
throw new AuroraException(HttpStatus.HTTP_BAD_REQUEST,"权限已存在");
|
||||
}
|
||||
permission.setCreateTime(old.getCreateTime());
|
||||
permissionRepo.save(permission);
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,9 @@ public class PictureServiceImpl implements PictureService {
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Picture findById(Long id) {
|
||||
if(id == null){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"id not exist");
|
||||
}
|
||||
Optional<Picture> picture = pictureRepo.findById(id);
|
||||
ValidationUtil.isNull(picture,"id:"+id+"is not find");
|
||||
return picture.get();
|
||||
|
||||
@@ -48,7 +48,10 @@ public class QiNiuServiceImpl implements QiNiuService {
|
||||
private final String TYPE = "公开";
|
||||
|
||||
@Override
|
||||
public QiniuConfig findById(long id) {
|
||||
public QiniuConfig findById(Long id) {
|
||||
if(id == null){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"id not exist");
|
||||
}
|
||||
Optional<QiniuConfig> qiniuConfig = qiNiuConfigRepo.findById(id);
|
||||
if(qiniuConfig.isPresent()){
|
||||
return qiniuConfig.get();
|
||||
|
||||
@@ -62,7 +62,7 @@ public class RoleServiceImpl implements RoleService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inster(Role role, String permissions) {
|
||||
public void insert(Role role, String permissions) {
|
||||
if(roleRepo.findByName(role.getName())!=null){
|
||||
throw new AuroraException(HttpStatus.HTTP_BAD_REQUEST,"角色已存在");
|
||||
}
|
||||
@@ -76,21 +76,21 @@ public class RoleServiceImpl implements RoleService {
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Role findById(Long id) {
|
||||
if(id == null){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"id not exist");
|
||||
}
|
||||
Optional<Role> role = roleRepo.findById(id);
|
||||
ValidationUtil.isNull(role,"id:"+id+"is not find");
|
||||
return role.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Role role, String permissions) {
|
||||
public void update(Role old,Role role, String permissions) {
|
||||
if(StrUtil.isEmpty(permissions)){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"请至少为其分配一个权限");
|
||||
}
|
||||
if(role.getId() == null){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"角色ID不能为空");
|
||||
}
|
||||
Role old = roleRepo.findByName(role.getName());
|
||||
if(old!=null && !role.getId().equals(old.getId())){
|
||||
Role role1 = roleRepo.findByName(role.getName());
|
||||
if(role1!=null && !role.getId().equals(role1.getId())){
|
||||
throw new AuroraException(HttpStatus.HTTP_BAD_REQUEST,"角色已存在");
|
||||
}
|
||||
old.setName(role.getName());
|
||||
|
||||
@@ -45,6 +45,9 @@ public class UserServiceImpl implements UserService {
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public User findById(Long id) {
|
||||
if(id == null){
|
||||
throw new AuroraException(HttpStatus.HTTP_NOT_FOUND,"id not exist");
|
||||
}
|
||||
Optional<User> user = userRepo.findById(id);
|
||||
ValidationUtil.isNull(user,"id:"+id+"is not find");
|
||||
return user.get();
|
||||
@@ -75,7 +78,7 @@ public class UserServiceImpl implements UserService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inster(User user, String roles) {
|
||||
public void insert(User user, String roles) {
|
||||
if(userRepo.findByUsername(user.getUsername())!=null){
|
||||
throw new AuroraException(HttpStatus.HTTP_BAD_REQUEST,"用户名已存在");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user