|
|
@@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
+import com.goafanti.common.constant.ErrorConstants;
|
|
|
import com.goafanti.common.controller.BaseApiController;
|
|
|
import com.goafanti.common.dao.PermissionMapper;
|
|
|
import com.goafanti.common.model.Permission;
|
|
|
@@ -45,4 +46,46 @@ public class NewPermissionApiController extends BaseApiController {
|
|
|
res.setData(permissionService.insertn(record));
|
|
|
return res;
|
|
|
}
|
|
|
+ /**新增上级名称自动生成 **/
|
|
|
+ @RequestMapping(value = "/selectSuperIdById" , method = RequestMethod.POST)
|
|
|
+ public Permission selectSuperIdById(String id ){
|
|
|
+ return permissionService.selectSuperIdById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**权限管理新增 **/
|
|
|
+ @RequestMapping(value = "/addPermission" , method = RequestMethod.POST)
|
|
|
+ public Result addPermission(Permission record ){
|
|
|
+ Result res = new Result();
|
|
|
+ if(StringUtils.isBlank(record.getName())|| StringUtils.isBlank(record.getUrl())
|
|
|
+ || StringUtils.isBlank(record.getSuperId())){
|
|
|
+ res.getError().add(buildError("","名称、路径、上级不能为空"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ String aut=permissionMapper.selectAutNoByName(record.getName());
|
|
|
+ if(aut!=null){
|
|
|
+ res.getError().add(buildError("","权限已存在"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res.setData(permissionService.insertSubordinate(record));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**删除列表信息**/
|
|
|
+ @RequestMapping(value = "/deleteById" , method = RequestMethod.POST)
|
|
|
+ public Result deleteById(String id){
|
|
|
+ Result res = new Result();
|
|
|
+ if(StringUtils.isBlank(id)){
|
|
|
+ res.getError().add(buildError(ErrorConstants.PARAM_EMPTY_ERROR, "id"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ Permission permission=permissionMapper.selectAllById(id);
|
|
|
+ String superId=permission.getName();
|
|
|
+ int subordinate=permissionMapper.selectCountBySuperId(superId);
|
|
|
+ if(subordinate>0){
|
|
|
+ res.getError().add(buildError("","存在下级权限不能删除"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+ res.setData(permissionService.deleteById(id));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
}
|