/** * Copyright 2018 人人开源 https://www.renren.io *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package com.epmet.controller; import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.AssertUtils; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.dto.IcResiDemandDictDTO; import com.epmet.service.IcResiDemandDictService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; /** * 居民需求字典表 * * @author generator generator@elink-cn.com * @since v1.0.0 2021-10-27 */ @RestController @RequestMapping("icresidemanddict") public class IcResiDemandDictController { @Autowired private IcResiDemandDictService icResiDemandDictService; @GetMapping("page") public Result> page(@RequestParam Map params){ PageData page = icResiDemandDictService.page(params); return new Result>().ok(page); } @GetMapping("{id}") public Result get(@PathVariable("id") String id){ IcResiDemandDictDTO data = icResiDemandDictService.get(id); return new Result().ok(data); } @PostMapping public Result save(@RequestBody IcResiDemandDictDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); icResiDemandDictService.save(dto); return new Result(); } @PutMapping public Result update(@RequestBody IcResiDemandDictDTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); icResiDemandDictService.update(dto); return new Result(); } @DeleteMapping public Result delete(@RequestBody String[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); icResiDemandDictService.delete(ids); return new Result(); } @PostMapping("demandoption") public Result> getDemandOptions(@LoginUser TokenDto tokenDto) { return new Result>().ok(icResiDemandDictService.getDemandOptions(tokenDto.getCustomerId())); } }