|
|
@@ -5,6 +5,7 @@ import java.util.List;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
@@ -14,6 +15,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.goafanti.common.bo.Result;
|
|
|
import com.goafanti.common.controller.BaseApiController;
|
|
|
+import com.goafanti.common.dao.RoleMapper;
|
|
|
import com.goafanti.common.model.Role;
|
|
|
import com.goafanti.permission.bo.RoleBo;
|
|
|
import com.goafanti.permission.service.NewRoleService;
|
|
|
@@ -23,7 +25,8 @@ import com.goafanti.permission.service.NewRoleService;
|
|
|
public class NewRoleApiController extends BaseApiController{
|
|
|
@Resource
|
|
|
private NewRoleService newRoleService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ RoleMapper roleMapper;
|
|
|
|
|
|
@RequestMapping(value = "/roles", method = RequestMethod.POST)
|
|
|
public Result roles(RoleBo role, Integer pageNo,
|
|
|
@@ -62,6 +65,7 @@ public class NewRoleApiController extends BaseApiController{
|
|
|
public Result deleteRole(String data) {
|
|
|
Result res = new Result();
|
|
|
JSONArray ja = (JSONArray) JSON.parse(data);
|
|
|
+
|
|
|
if (ja != null && !ja.isEmpty()) {
|
|
|
List<String> records = new ArrayList<>();
|
|
|
for (int idx = 0; idx < ja.size(); idx++) {
|
|
|
@@ -70,6 +74,11 @@ public class NewRoleApiController extends BaseApiController{
|
|
|
records.add(rid);
|
|
|
}
|
|
|
}
|
|
|
+ int zz=roleMapper.selectCountByRoleId(records);
|
|
|
+ if(zz>0){
|
|
|
+ res.getError().add(buildError("","角色被分配不能删除"));
|
|
|
+ return res;
|
|
|
+ }
|
|
|
res.setData(newRoleService.deleteByPrimaryKeys(records));
|
|
|
} else {
|
|
|
res.getError().add(buildError("", "参数格式不正确"));
|