| | |
| | | package com.whyc.controller; |
| | | |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.pojo.db_area.AreaUser; |
| | | import com.whyc.service.AreaInfService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @Api(tags = "区域管理") |
| | |
| | | } |
| | | |
| | | @ApiOperation(value = "修改区域") |
| | | @GetMapping("updateArea") |
| | | public Response updateArea(@RequestParam(required = false) Integer id,@RequestParam String areaName,@RequestParam String uname,@RequestParam(required = false) String areaDescript){ |
| | | return service.updateArea(id,areaName,uname,areaDescript); |
| | | @PostMapping("updateArea") |
| | | public Response updateArea(@RequestParam(required = false) Integer id, @RequestParam String areaName, @RequestBody List<AreaUser> areaUserList, @RequestParam(required = false) String areaDescript){ |
| | | return service.updateArea(id,areaName,areaUserList,areaDescript); |
| | | } |
| | | /*@ApiOperation(value = "查询所在区域下所有用户信息") |
| | | @GetMapping("getUinfById") |
| | |
| | | } |
| | | //修改区域 |
| | | @Transactional |
| | | public Response updateArea(Integer id, String areaName, String uname, String areaDescript) { |
| | | public Response updateArea(Integer id, String areaName, List<AreaUser> areaUserList, String areaDescript) { |
| | | //改区域 |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("id",id); |
| | |
| | | wrapper1.eq("id",id); |
| | | mapper.update(ainf,wrapper1); |
| | | updateAll(id,newPath); |
| | | //改区域管理员(添加新的记录) |
| | | areaUserService.insertArea(id,uname); |
| | | //删除旧的区域对应关系 |
| | | areaUserService.delteAreaUser(id); |
| | | //将新的插入 |
| | | areaUserService.insertAreaUser(id,areaUserList); |
| | | return new Response().set(1,true); |
| | | } |
| | | public void updateAll(Integer id, String newPath) { |
| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.whyc.mapper.AreaUserMapper; |
| | | import com.whyc.mapper.UserInfMapper; |
| | | import com.whyc.pojo.db_area.AreaUser; |
| | |
| | | .collect(Collectors.toList()); // 转换为列表*/ |
| | | return unameList; |
| | | } |
| | | //删除旧的区域对应关系 |
| | | public void delteAreaUser(Integer id) { |
| | | UpdateWrapper wrapper=new UpdateWrapper(); |
| | | wrapper.eq("area_id",id); |
| | | mapper.delete(wrapper); |
| | | } |
| | | //将新的插入 |
| | | public void insertAreaUser(Integer id, List<AreaUser> areaUserList) { |
| | | if(areaUserList!=null){ |
| | | for ( AreaUser areauser:areaUserList) { |
| | | areauser.setAreaId(id); |
| | | } |
| | | mapper.insertBatchSomeColumn(areaUserList); |
| | | } |
| | | } |
| | | } |