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.HashMap; 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.SysFieldvalue; import com.landtool.lanbase.modules.sys.entity.SysSysteminfo; import com.landtool.lanbase.modules.org.entity.OrgUser; import com.landtool.lanbase.modules.sys.service.SysFieldvalueService; import com.alibaba.fastjson.JSONObject; import com.landtool.lanbase.common.annotation.LogAction; import com.landtool.lanbase.common.annotation.SysLog; 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 16:14:16 */ @RestController @RequestMapping("/sys/fieldvalue") @Api(value = "", tags = {"系统字典字段值"}) public class SysFieldvalueController extends AbstractController{ @Autowired private SysFieldvalueService fieldvalueService; /** * 列表 */ @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 params){ //查询列表数据 Query query = new Query(params); List fieldvalueList = fieldvalueService.queryList(query); int total = fieldvalueService.queryTotal(query); PageUtils pageUtil = new PageUtils(fieldvalueList, total, query.getLimit(), query.getPage()); return Result.ok().put("page", pageUtil); } /** * 信息 */ @GetMapping("/info/{valueid}") // @RequiresPermissions("sys:field:list") @RequiresPermissions(value = {"sys:field:list","sys:field:edit"}, logical = Logical.OR) @ApiOperation( value = "系统字典字段值列表", notes = "" ) public Result info(@ApiParam(name="valueid",value="字段Id",required=true)@PathVariable("valueid") Long valueid){ SysFieldvalue fieldvalue = fieldvalueService.queryObject(valueid); return Result.ok().put("fieldvalue", fieldvalue); } /** * 保存 */ @LogAction("平台管理,字典管理>字典明细,字典管理>字典字段值列表新增,新增") @PostMapping("/save") @RequiresPermissions("sys:field:edit") @ApiOperation( value = "保存字典字段值信息", notes = "" ) public Result save(@ApiParam(name="字典字段值对象",value="传入json格式",required=true)@RequestBody SysFieldvalue fieldvalue){ if(fieldvalue.getVcode() == null || fieldvalue.getVcode().length() == 0 || fieldvalue.getVtext() == null || fieldvalue.getVtext().length() == 0){ return Result.error("保存失败,存在特殊字符,请重新输入!"); } Long userid=((OrgUser) SecurityUtils.getSubject().getPrincipal()).getUserid(); fieldvalue.setRcreateuser(userid); int rorder = fieldvalueService.queryMaxRorder(fieldvalue.getFkey())+1; fieldvalue.setRorder((long)rorder); fieldvalueService.save(fieldvalue); int valueid = fieldvalueService.queryFieldValueWithSEQ(); return Result.ok().put("valueid",valueid); } /** * 修改 */ @LogAction("平台管理,字典管理>字典明细,字典管理>字典字段值列表修改,修改") @PostMapping("/update") @RequiresPermissions("sys:field:edit") @ApiOperation( value = "修改字典字段值信息", notes = "" ) public Result update(@ApiParam(name="字典字段值对象",value="传入json格式",required=true)@RequestBody SysFieldvalue fieldvalue){ if(fieldvalue.getVcode() == null || fieldvalue.getVcode().length() == 0 || fieldvalue.getVtext() == null || fieldvalue.getVtext().length() == 0){ return Result.error("保存失败,存在特殊字符,请重新输入!"); } fieldvalueService.update(fieldvalue); return Result.ok(); } /** * 删除 */ @LogAction("平台管理,字典管理>字典明细,字典管理>字典字段值列表删除,删除") @PostMapping("/delete") @RequiresPermissions("sys:field:edit") @ApiOperation( value = "删除字段值信息", notes = "" ) public Result delete(@ApiParam(name="valueid",value="字段值Id",required=true)@RequestBody Long[] valueids){ fieldvalueService.deleteBatch(valueids); return Result.ok(); } /** * 根据key值获取对应的应用字段值 */ @SysLog("根据key值获取对应的应用字段值") @GetMapping("/queryListByKey") @ApiOperation( value = "根据key值获取对应的应用字段值", notes = "" ) public Map queryListByKey(@ApiParam(name="key",value="应用字段Key",required=true)@RequestParam String key){ Map map = new HashMap(); List sysFieldList = fieldvalueService.queryListByKey(key); map.put("sysFieldList", sysFieldList); return map; } /** * 根据key值获取对应的应用字段值 */ @SysLog("根据key值获取对应的应用字段值") @RequestMapping(value="/queryAllListByFkey",method ={RequestMethod.POST, RequestMethod.GET}) // @RequiresPermissions("sys:field:list") @RequiresPermissions(value = {"sys:field:list","sys:field:edit"}, logical = Logical.OR) @ApiOperation( value = "系统字典字段值列表", notes = "系统字典字段值" ) public Result queryAllListByFkey(@ApiParam(name="key",value="应用字段Key",required=true)@RequestParam String fkey){ List fieldvalueList = fieldvalueService.queryAllListByFkey(fkey); return Result.ok().put("fieldvalueList", fieldvalueList); } /** * 修改排序 */ @LogAction("平台管理,字典管理>字典明细,字典管理>字典字段值列表修改排序,修改") @PostMapping("/updateRorder") @RequiresPermissions("sys:field:edit") @ApiOperation( value = "修改字典字段值排序", notes = "" ) public Result updateRorder(@ApiParam(name="复合对象",value="传入json格式",required=true)@RequestBody JSONObject json){ String valueids = json.getString("valueids"); // String sorts = json.getString("sorts"); String[] valueidList = valueids.split(","); // String[] sortList=sorts.split(","); for(int i =0;i