12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- package com.huaxu.controller;
- import com.huaxu.entity.WaterPropertyEntity;
- import com.huaxu.model.AjaxMessage;
- import com.huaxu.model.LoginUser;
- import com.huaxu.model.ResultStatus;
- import com.huaxu.service.WaterPropertyService;
- import com.huaxu.util.UserUtil;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import io.swagger.annotations.ApiParam;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.web.bind.annotation.*;
- import java.util.List;
- /**
- * 用水性质控制层
- *
- * @author yjy
- * @since 2021-5-31
- */
- @RestController
- @RequestMapping("/waterProperty")
- @Api(tags = "用水性质")
- public class WaterPropertyController {
- /**
- * 服务对象
- */
- @Autowired
- private WaterPropertyService waterPropertyService;
- @RequestMapping(value = "insert", method = RequestMethod.POST)
- @ApiOperation(value = "增加用水性质信息")
- public AjaxMessage<Boolean> insert(@ApiParam(value = "用水性质", required = true) @RequestBody WaterPropertyEntity waterPropertyEntity) {
- LoginUser currentUser = UserUtil.getCurrentUser();
- waterPropertyEntity.setTenantId(currentUser.getTenantId());
- waterPropertyEntity.setCreateBy(currentUser.getUsername());
- waterPropertyEntity.setStatus(1);
- return new AjaxMessage<>(ResultStatus.OK, waterPropertyService.insert(waterPropertyEntity));
- }
- @RequestMapping(value = "delete", method = RequestMethod.GET)
- @ApiOperation(value = "删除用水性质信息")
- public AjaxMessage<Boolean> delete(@ApiParam(value = "用水性质id", required = true) @RequestParam Integer id) {
- return new AjaxMessage<>(ResultStatus.OK, waterPropertyService.delete(id));
- }
- @RequestMapping(value = "update", method = RequestMethod.POST)
- @ApiOperation(value = "修改用水性质信息")
- public AjaxMessage<Boolean> update(@ApiParam(value = "用水性质", required = true) @RequestBody WaterPropertyEntity waterPropertyEntity) {
- LoginUser currentUser = UserUtil.getCurrentUser();
- waterPropertyEntity.setUpdateBy(currentUser.getUsername());
- return new AjaxMessage<>(ResultStatus.OK, waterPropertyService.update(waterPropertyEntity));
- }
- @RequestMapping(value = "select", method = RequestMethod.GET)
- @ApiOperation(value = "查询用水性质信息")
- public AjaxMessage<List<WaterPropertyEntity>> select(@ApiParam(value = "所属公司id", required = true) @RequestParam Integer companyOrgId) {
- if(companyOrgId==null){
- LoginUser currentUser = UserUtil.getCurrentUser();
- companyOrgId=currentUser.getCompanyId();
- }
- return new AjaxMessage<>(ResultStatus.OK, waterPropertyService.select(companyOrgId));
- }
- @RequestMapping(value = "save", method = RequestMethod.POST)
- @ApiOperation(value = "批量保存用水性质列表")
- public AjaxMessage<Boolean> insert(@ApiParam(value = "用水性质列表", required = true) @RequestBody List<WaterPropertyEntity> waterPropertyList) {
- LoginUser currentUser = UserUtil.getCurrentUser();
- for(WaterPropertyEntity waterPropertyEntity:waterPropertyList){
- waterPropertyEntity.setTenantId(currentUser.getTenantId());
- waterPropertyEntity.setCreateBy(currentUser.getUsername());
- waterPropertyEntity.setStatus(1);
- }
- return new AjaxMessage<>(ResultStatus.OK, waterPropertyService.save(waterPropertyList));
- }
- }
|