| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.acs.framework.common.Cools; |
| | | import com.zy.acs.framework.common.R; |
| | | import com.zy.acs.manager.common.utils.ExcelUtil; |
| | | import com.zy.acs.framework.exception.CoolException; |
| | | import com.zy.acs.manager.common.annotation.OperationLog; |
| | | import com.zy.acs.manager.common.domain.BaseParam; |
| | | import com.zy.acs.manager.common.domain.KeyValVo; |
| | | import com.zy.acs.manager.common.domain.PageParam; |
| | | import com.zy.acs.manager.common.utils.ExcelUtil; |
| | | import com.zy.acs.manager.manager.entity.Sta; |
| | | import com.zy.acs.manager.manager.entity.StaReserve; |
| | | import com.zy.acs.manager.manager.service.StaReserveService; |
| | | import com.zy.acs.manager.manager.service.StaService; |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | |
| | | @Autowired |
| | | private StaService staService; |
| | | @Autowired |
| | | private StaReserveService staReserveService; |
| | | |
| | | @PreAuthorize("hasAuthority('manager:sta:list')") |
| | | @PostMapping("/sta/page") |
| | |
| | | @OperationLog("Create Sta") |
| | | @PostMapping("/sta/save") |
| | | public R save(@RequestBody Sta sta) { |
| | | sta.setCreateBy(getLoginUserId()); |
| | | sta.setCreateTime(new Date()); |
| | | sta.setUpdateBy(getLoginUserId()); |
| | | sta.setUpdateTime(new Date()); |
| | | if (staService.count(new LambdaQueryWrapper<Sta>() |
| | | .eq(Sta::getStaNo, sta.getStaNo())) > 0) { |
| | | return R.error("sta No. has already exist !"); |
| | | } |
| | | Long loginUserId = getLoginUserId(); |
| | | Date now = new Date(); |
| | | sta.setCreateBy(loginUserId); |
| | | sta.setCreateTime(now); |
| | | sta.setUpdateBy(loginUserId); |
| | | sta.setUpdateTime(now); |
| | | if (!staService.save(sta)) { |
| | | return R.error("Save Fail"); |
| | | } |
| | |
| | | @OperationLog("Update Sta") |
| | | @PostMapping("/sta/update") |
| | | public R update(@RequestBody Sta sta) { |
| | | // 唯一性校验:只有当 sta No. 非空时才校验(避免空值误判) |
| | | if (!Cools.isEmpty(sta.getStaNo())) { |
| | | boolean exists = staService.count(new LambdaQueryWrapper<Sta>() |
| | | .eq(Sta::getStaNo, sta.getStaNo()) |
| | | .ne(Sta::getId, sta.getId())) > 0; |
| | | if (exists) { |
| | | throw new CoolException("failed to update, because sta No. has already exist !"); |
| | | } |
| | | } |
| | | sta.setUpdateBy(getLoginUserId()); |
| | | sta.setUpdateTime(new Date()); |
| | | if (!staService.updateById(sta)) { |
| | |
| | | @PreAuthorize("hasAuthority('manager:sta:remove')") |
| | | @OperationLog("Delete Sta") |
| | | @PostMapping("/sta/remove/{ids}") |
| | | @Transactional |
| | | public R remove(@PathVariable Long[] ids) { |
| | | if (!staService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("Delete Fail"); |
| | | for (Long id : ids) { |
| | | staReserveService.remove(new LambdaQueryWrapper<StaReserve>().eq(StaReserve::getStaId, id)); |
| | | if (!staService.removeById(id)) { |
| | | throw new CoolException("remove Fail"); |
| | | } |
| | | } |
| | | return R.ok("Delete Success").add(ids); |
| | | } |