| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.wcs.common.annotation.OperationLog; |
| | | import com.zy.asrs.wcs.common.domain.BaseParam; |
| | | import com.zy.asrs.wcs.common.domain.KeyValVo; |
| | | import com.zy.asrs.wcs.common.domain.PageParam; |
| | | import com.zy.asrs.wcs.system.entity.Host; |
| | | import com.zy.asrs.wcs.system.service.HostService; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | 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.ArrayList; |
| | | import java.util.List; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * Created by vincent on 2/16/2024 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | public class HostController extends BaseController { |
| | |
| | | @Autowired |
| | | private HostService hostService; |
| | | |
| | | @PreAuthorize("hasAuthority('sys:host:list')") |
| | | @PostMapping("/hostId/query") |
| | | @PreAuthorize("hasAuthority('system:host:list')") |
| | | @PostMapping("/host/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<Host, BaseParam> pageParam = new PageParam<>(baseParam, Host.class); |
| | | return R.ok().add(hostService.page(pageParam, pageParam.buildWrapper(true))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:host:list')") |
| | | @PostMapping("/host/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(hostService.list()); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:host:list')") |
| | | @GetMapping("/host/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(hostService.getById(id)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:host:save')") |
| | | @OperationLog("添加机构") |
| | | @PostMapping("/host/save") |
| | | public R save(@RequestBody Host host) { |
| | | host.setCreateTime(new Date()); |
| | | host.setUpdateTime(new Date()); |
| | | if (!hostService.save(host)) { |
| | | return R.error("添加失败"); |
| | | } |
| | | return R.ok("添加成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:host:update')") |
| | | @OperationLog("修改机构") |
| | | @PostMapping("/host/update") |
| | | public R update(@RequestBody Host host) { |
| | | host.setUpdateTime(new Date()); |
| | | if (!hostService.updateById(host)) { |
| | | return R.error("修改失败"); |
| | | } |
| | | return R.ok("修改成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:host:remove')") |
| | | @OperationLog("删除机构") |
| | | @PostMapping("/host/remove/{ids}") |
| | | public R remove(@PathVariable Long[] ids) { |
| | | if (!hostService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("删除失败"); |
| | | } |
| | | return R.ok("删除成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:host:list')") |
| | | @PostMapping("/host/query") |
| | | public R query(@RequestParam(required = false) String condition) { |
| | | List<KeyValVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<Host> wrapper = new LambdaQueryWrapper<>(); |
| | |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('system:host:list')") |
| | | @PostMapping("/host/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(hostService.list(), Host.class), response); |
| | | } |
| | | |
| | | } |