| | |
| | | import com.example.jz.modle.entity.*; |
| | | import com.example.jz.service.*; |
| | | import com.example.jz.utils.Md5Utils; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | |
| | | @GetMapping("/status") |
| | | @ApiOperation("禁用/启用用户") |
| | | public R updateStatus(Integer id,Integer status){ |
| | | public R updateStatus(Integer id, Integer status) { |
| | | int newStatus = 0; |
| | | if(status!=null){ |
| | | if(status==1){ |
| | | newStatus=0; |
| | | }else{ |
| | | newStatus=1; |
| | | if (status != null) { |
| | | if (status == 1) { |
| | | newStatus = 0; |
| | | } else { |
| | | newStatus = 1; |
| | | } |
| | | } |
| | | userService.update(new UpdateWrapper<User>().set("status", newStatus).eq("id",id)); |
| | | userService.update(new UpdateWrapper<User>().set("status", newStatus).eq("id", id)); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | user.setLoginPassword(Md5Utils.md5(user.getUserIdcard().substring(user.getUserIdcard().length() - 6))); |
| | | return R.ok(userService.updateById(user)); |
| | | } |
| | | |
| | | /** |
| | | * 转为管理员 |
| | | * |
| | | * @param id 用户id |
| | | * @return |
| | | */ |
| | | @GetMapping("/toManager/{id}") |
| | | @ApiOperation("转为管理员") |
| | | public R toManager(@PathVariable Serializable id) { |
| | | User user = userService.getById(id); |
| | | user.setRole(1); |
| | | return R.ok(userService.updateById(user)); |
| | | } |
| | | } |