Commit 02e4fc17 authored by Quxl's avatar Quxl

管理员组和组权限

parent 72ece12a
...@@ -3,6 +3,8 @@ package com.egolm.film.api.admin; ...@@ -3,6 +3,8 @@ package com.egolm.film.api.admin;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
...@@ -12,6 +14,7 @@ import org.springframework.web.bind.annotation.ResponseBody; ...@@ -12,6 +14,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.egolm.common.FileUtil; import com.egolm.common.FileUtil;
import com.egolm.common.bean.Rjx; import com.egolm.common.bean.Rjx;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.admin.service.AdminAuthService; import com.egolm.film.api.admin.service.AdminAuthService;
import com.egolm.film.bean.Fc_admin_group; import com.egolm.film.bean.Fc_admin_group;
import com.egolm.film.config.WebMvcConfig; import com.egolm.film.config.WebMvcConfig;
...@@ -46,7 +49,6 @@ public class AdminAuthController { ...@@ -46,7 +49,6 @@ public class AdminAuthController {
@RequestMapping("adminDilabled") @RequestMapping("adminDilabled")
@ApiOperation("禁用管理员") @ApiOperation("禁用管理员")
public Object adminDilabled(String[] adminid) { public Object adminDilabled(String[] adminid) {
return Rjx.jsonOk(); return Rjx.jsonOk();
} }
...@@ -54,8 +56,11 @@ public class AdminAuthController { ...@@ -54,8 +56,11 @@ public class AdminAuthController {
@RequestMapping("groupList") @RequestMapping("groupList")
@ApiOperation("管理员分组,分页查询") @ApiOperation("管理员分组,分页查询")
public Object groupList(String keyword, Long index, Long limit) { public Object groupList(String keyword, Long index, Long limit) {
index = index == null ? 1 : index;
return Rjx.jsonOk(); limit = limit == null ? 20 : limit;
Page page = new Page(index, limit);
List<Map<String, Object>> datas = service.queryGroupList(keyword, page);
return Rjx.jsonOk().setData(datas);
} }
@ResponseBody @ResponseBody
...@@ -79,6 +84,7 @@ public class AdminAuthController { ...@@ -79,6 +84,7 @@ public class AdminAuthController {
group.setCreate_ip(remoteIp); group.setCreate_ip(remoteIp);
group.setCreate_time(System.currentTimeMillis()); group.setCreate_time(System.currentTimeMillis());
group.setGroup_power(group_power); group.setGroup_power(group_power);
service.saveOrUpdateGroup(group);
return Rjx.jsonOk(); return Rjx.jsonOk();
} }
......
package com.egolm.film.api.admin.service; package com.egolm.film.api.admin.service;
import java.util.List;
import java.util.Map;
import com.egolm.common.jdbc.Page;
import com.egolm.film.bean.Fc_admin_group;
public interface AdminAuthService { public interface AdminAuthService {
void saveOrUpdateGroup(Fc_admin_group group);
List<Map<String, Object>> queryGroupList(String keyword, Page page);
} }
package com.egolm.film.api.admin.service.impl; package com.egolm.film.api.admin.service.impl;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.egolm.common.StringUtil;
import com.egolm.common.jdbc.JdbcTemplate; import com.egolm.common.jdbc.JdbcTemplate;
import com.egolm.common.jdbc.Page;
import com.egolm.film.api.admin.service.AdminAuthService; import com.egolm.film.api.admin.service.AdminAuthService;
import com.egolm.film.bean.Fc_admin_group;
import com.egolm.film.util.SqlWhere;
@Service @Service
public class AdminAuthServiceImpl implements AdminAuthService { public class AdminAuthServiceImpl implements AdminAuthService {
@Autowired @Autowired
JdbcTemplate jdbcTemplate; JdbcTemplate jdbcTemplate;
@Override
public void saveOrUpdateGroup(Fc_admin_group group) {
if(group.getGroup_id() == null) {
group.setUser_num(0);
}
jdbcTemplate.merge(group);
}
@Override
public List<Map<String, Object>> queryGroupList(String keyword, Page page) {
SqlWhere argEdit = new SqlWhere().like("group_name", keyword);
String sql = "select * from" + StringUtil.join(" and ", " where ", "", "", argEdit.getArgs());
return jdbcTemplate.limitAll(sql, page, argEdit.getObjs());
}
} }
...@@ -45,6 +45,11 @@ public class Fc_admin_group implements java.io.Serializable { ...@@ -45,6 +45,11 @@ public class Fc_admin_group implements java.io.Serializable {
*/ */
private Integer state; private Integer state;
/**
* 成员数量
*/
private Integer user_num;
/** /**
* 群组权限 * 群组权限
*/ */
...@@ -66,15 +71,17 @@ public class Fc_admin_group implements java.io.Serializable { ...@@ -66,15 +71,17 @@ public class Fc_admin_group implements java.io.Serializable {
* @param create_ip 创建者ip * @param create_ip 创建者ip
* @param adminid 创建者uid * @param adminid 创建者uid
* @param state 小组状态 * @param state 小组状态
* @param user_num 成员数量
* @param group_power 群组权限 * @param group_power 群组权限
*/ */
public Fc_admin_group(Integer group_id, String group_name, Long create_time, String create_ip, Integer adminid, Integer state, String group_power) { public Fc_admin_group(Integer group_id, String group_name, Long create_time, String create_ip, Integer adminid, Integer state, Integer user_num, String group_power) {
this.group_id = group_id; this.group_id = group_id;
this.group_name = group_name; this.group_name = group_name;
this.create_time = create_time; this.create_time = create_time;
this.create_ip = create_ip; this.create_ip = create_ip;
this.adminid = adminid; this.adminid = adminid;
this.state = state; this.state = state;
this.user_num = user_num;
this.group_power = group_power; this.group_power = group_power;
} }
...@@ -126,6 +133,14 @@ public class Fc_admin_group implements java.io.Serializable { ...@@ -126,6 +133,14 @@ public class Fc_admin_group implements java.io.Serializable {
return state; return state;
} }
public void setUser_num(Integer user_num) {
this.user_num = user_num;
}
public Integer getUser_num() {
return user_num;
}
public void setGroup_power(String group_power) { public void setGroup_power(String group_power) {
this.group_power = group_power; this.group_power = group_power;
} }
......
...@@ -14,7 +14,7 @@ public class DBUtil { ...@@ -14,7 +14,7 @@ public class DBUtil {
"film_new", "film_new",
"root", "root",
"egolm#2018"); "egolm#2018");
mysqlTo.execute(); mysqlTo.execute("fc_admin_group");
} }
} }
package com.egolm.film.util;
import java.util.List;
import com.egolm.common.StringUtil;
public class SqlWhere {
private List<String> args;
private List<Object> objs;
public SqlWhere eq(String name, Object obj) {
if(StringUtil.isNotBlank(obj)) {
this.args.add(name + " = ?");
this.objs.add(obj);
}
return this;
}
public SqlWhere gt(String name, Object obj) {
if(StringUtil.isNotBlank(obj)) {
this.args.add(name + " > ?");
this.objs.add(obj);
}
return this;
}
public SqlWhere lt(String name, Object obj) {
if(StringUtil.isNotBlank(obj)) {
this.args.add(name + " < ?");
this.objs.add(obj);
}
return this;
}
public SqlWhere gtq(String name, Object obj) {
if(StringUtil.isNotBlank(obj)) {
this.args.add(name + " >= ?");
this.objs.add(obj);
}
return this;
}
public SqlWhere ltq(String name, Object obj) {
if(StringUtil.isNotBlank(obj)) {
this.args.add(name + " <= ?");
this.objs.add(obj);
}
return this;
}
public SqlWhere like(String name, Object obj) {
if(StringUtil.isNotBlank(obj)) {
this.args.add(name + " like ?");
this.objs.add("%" + obj + "%");
}
return this;
}
public SqlWhere rlike(String name, Object obj) {
if(StringUtil.isNotBlank(obj)) {
this.args.add(name + " like ?");
this.objs.add(obj + "%");
}
return this;
}
public SqlWhere llike(String name, Object obj) {
if(StringUtil.isNotBlank(obj)) {
this.args.add(name + " like ?");
this.objs.add("%" + obj);
}
return this;
}
public SqlWhere in(String name, Object[] obj) {
if(obj != null && obj.length > 0) {
String str = name + " in (";
for(int i = 0; i < obj.length; i++) {
if(i > 0) {
str += ", ";
}
str += "?";
this.objs.add(obj[i]);
}
str += ")";
this.args.add(name + " in (" + str + ")");
}
return this;
}
public List<String> getArgs() {
return args;
}
public List<Object> getObjs() {
return objs;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment