package com.landtool.lanbase.modules.sys.controller;
|
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
|
import java.util.List;
|
import java.util.Map;
|
|
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.authz.annotation.Logical;
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
|
import com.landtool.lanbase.modules.sys.entity.SysField;
|
import com.landtool.lanbase.modules.org.entity.OrgUser;
|
import com.landtool.lanbase.modules.sys.service.SysFieldService;
|
import com.landtool.lanbase.common.annotation.LogAction;
|
import com.landtool.lanbase.common.annotation.LogLogininfo;
|
import com.landtool.lanbase.common.utils.PageUtils;
|
import com.landtool.lanbase.common.utils.Query;
|
import com.landtool.lanbase.common.utils.Result;
|
|
/**
|
* @author lanbase
|
* @Description: TODO(系统字典字段)
|
* @date 2018-01-15 15:11:51
|
*/
|
@RestController
|
@RequestMapping("/sys/field")
|
@Api(value = "", tags = {"系统字典管理"})
|
public class SysFieldController extends AbstractController{
|
|
@Autowired
|
private SysFieldService fieldService;
|
/**
|
* 列表
|
*/
|
@RequestMapping(value="/list", method ={RequestMethod.POST, RequestMethod.GET})
|
// @RequiresPermissions("sys:field:list")
|
@RequiresPermissions(value = {"sys:field:list","sys:field:edit"}, logical = Logical.OR)
|
@ApiOperation(
|
value = "系统字典列表",
|
notes = ""
|
)
|
@LogAction("平台管理,字典管理,字典查询,查询")
|
public Result list(@ApiParam(name="params",value="",required=true)@RequestParam Map<String, Object> params){
|
//查询列表数据
|
Query query = new Query(params);
|
System.out.println(query);
|
List<SysField> fieldList = fieldService.queryList(query);
|
int total = fieldService.queryTotal(query);
|
|
PageUtils pageUtil = new PageUtils(fieldList, total, query.getLimit(), query.getPage());
|
|
return Result.ok().put("page", pageUtil);
|
}
|
|
|
/**
|
* 信息
|
*/
|
@GetMapping("/info/{fkey}")
|
// @RequiresPermissions("sys:field:list")
|
@RequiresPermissions(value = {"sys:field:list","sys:field:edit"}, logical = Logical.OR)
|
@ApiOperation(
|
value = "字段信息",
|
notes = ""
|
)
|
public Result info(@ApiParam(name="fkey",value="fkey",required=true)@PathVariable("fkey") String fkey){
|
SysField field = fieldService.queryObject(fkey);
|
|
return Result.ok().put("field", field);
|
}
|
|
/**
|
* 保存
|
*/
|
@LogAction("平台管理,字典管理,字典新增,新增")
|
@PostMapping("/save")
|
@RequiresPermissions("sys:field:edit")
|
@ApiOperation(
|
value = "保存字典字段",
|
notes = ""
|
)
|
public Result save(@ApiParam(name="字典字段对象",value="传入json格式",required=true)@RequestBody SysField field){
|
if(field.getFkey() == null || field.getFkey().length() == 0 || field.getCname() == null || field.getCname().length() == 0){
|
return Result.error("保存失败,存在特殊字符,请重新输入!");
|
}
|
Long userid =((OrgUser) SecurityUtils.getSubject().getPrincipal()).getUserid();
|
field.setRcreateuser(userid);
|
fieldService.save(field);
|
|
return Result.ok().put("key",field.getFkey());
|
}
|
|
/**
|
* 修改
|
*/
|
// @LogLogininfo("修改")
|
@LogAction("平台管理,字典管理,字典修改,修改")
|
@PostMapping("/update")
|
@RequiresPermissions("sys:field:edit")
|
@ApiOperation(
|
value = "修改字典字段",
|
notes = ""
|
)
|
public Result update(@ApiParam(name="字典字段对象",value="传入json格式",required=true)@RequestBody SysField field){
|
if(field.getFkey() == null || field.getFkey().length() == 0 || field.getCname() == null || field.getCname().length() == 0){
|
return Result.error("保存失败,存在特殊字符,请重新输入!");
|
}
|
fieldService.update(field);
|
|
return Result.ok();
|
}
|
|
/**
|
* 删除
|
*/
|
//@LogLogininfo("删除")
|
@LogAction("平台管理,字典管理,字典删除,删除")
|
@PostMapping("/delete")
|
@RequiresPermissions("sys:field:edit")
|
@ApiOperation(
|
value = "删除字典字段",
|
notes = ""
|
)
|
|
public Result delete(@ApiParam(name="fkey",value="fkey",required=true)@RequestBody String[] fkeys){
|
fieldService.deleteBatch(fkeys);
|
|
return Result.ok();
|
}
|
|
|
}
|