content: package me.flyray.rbac.controller;
  
  import java.util.List;
  import java.util.Map;
  
  import org.apache.shiro.authz.annotation.RequiresPermissions;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.web.bind.annotation.PathVariable;
  import org.springframework.web.bind.annotation.RequestBody;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestParam;
  import org.springframework.web.bind.annotation.RestController;
  
  import me.flyray.rbac.annotation.SysLog;
  import me.flyray.rbac.entity.SysConfigEntity;
  import me.flyray.rbac.service.SysConfigService;
  import me.flyray.rbac.utils.PageUtils;
  import me.flyray.rbac.utils.Query;
  import me.flyray.rbac.utils.R;
  import me.flyray.rbac.validator.ValidatorUtils;
  
  /**
   * 系统配置信息
   * 
   * @author chenshun
   * @email sunlightcs@gmail.com
   * @date 2016年12月4日 下午6:55:53
   */
  @RestController
  @RequestMapping("/sys/config")
  public class SysConfigController extends AbstractController {
  	@Autowired
  	private SysConfigService sysConfigService;
  	
  	/**
  	 * 所有配置列表
  	 */
  	@RequestMapping("/list")
  	@RequiresPermissions("sys:config:list")
  	public R list(@RequestParam Map<String, Object> params){
  		//查询列表数据
  		Query query = new Query(params);
  		List<SysConfigEntity> configList = sysConfigService.queryList(query);
  		int total = sysConfigService.queryTotal(query);
  		
  		PageUtils pageUtil = new PageUtils(configList, total, query.getLimit(), query.getPage());
  		
  		return R.ok().put("page", pageUtil);
  	}
  	
  	
  	/**
  	 * 配置信息
  	 */
  	@RequestMapping("/info/{id}")
  	@RequiresPermissions("sys:config:info")
  	public R info(@PathVariable("id") Long id){
  		SysConfigEntity config = sysConfigService.queryObject(id);
  		
  		return R.ok().put("config", config);
  	}
  	
  	/**
  	 * 保存配置
  	 */
  	@SysLog("保存配置")
  	@RequestMapping("/save")
  	@RequiresPermissions("sys:config:save")
  	public R save(@RequestBody SysConfigEntity config){
  		ValidatorUtils.validateEntity(config);
  
  		sysConfigService.save(config);
  		
  		return R.ok();
  	}
  	
  	/**
  	 * 修改配置
  	 */
  	@SysLog("修改配置")
  	@RequestMapping("/update")
  	@RequiresPermissions("sys:config:update")
  	public R update(@RequestBody SysConfigEntity config){
  		ValidatorUtils.validateEntity(config);
  		
  		sysConfigService.update(config);
  		
  		return R.ok();
  	}
  	
  	/**
  	 * 删除配置
  	 */
  	@SysLog("删除配置")
  	@RequestMapping("/delete")
  	@RequiresPermissions("sys:config:delete")
  	public R delete(@RequestBody Long[] ids){
  		sysConfigService.deleteBatch(ids);
  		
  		return R.ok();
  	}
  
  }
  