diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/controller/admin/CompanyController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/controller/admin/CompanyController.java index f27c6dbd..6b11660b 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/controller/admin/CompanyController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/controller/admin/CompanyController.java @@ -1,16 +1,22 @@ package cn.iocoder.yudao.module.company.controller.admin; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.common.CommonErrorCodeConstants; import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.company.entity.Company; import cn.iocoder.yudao.module.company.vo.CompanyRespVO; +import cn.iocoder.yudao.module.system.api.dept.DeptApi; +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import cn.iocoder.yudao.module.company.vo.CompanyReqVO; import io.swagger.v3.oas.annotations.Parameter; import org.apache.commons.lang3.StringUtils; +import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.*; import org.springframework.validation.annotation.Validated; import org.springframework.security.access.prepost.PreAuthorize; @@ -20,11 +26,13 @@ import io.swagger.v3.oas.annotations.Operation; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import org.springframework.beans.factory.annotation.Autowired; import cn.iocoder.yudao.module.company.service.CompanyService; +import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.Arrays; @@ -43,6 +51,11 @@ import java.util.Map; @Tag(name = "管理后台 - BASE 企业管理") @Validated public class CompanyController { + + @Resource + @Lazy + private DeptApi deptApi; + @Autowired private CompanyService companyService; @@ -160,4 +173,22 @@ public class CompanyController { public CommonResult> getCompanyList(){ return success(companyService.list()); } + + /** + * 当前登录用户的门店信息 + * + * @author 小李 + * @date 15:41 2024/9/18 + **/ + @GetMapping("/now") + @Operation(summary = "企业信息表 当前登录用户的") + public CommonResult getNowCompany(){ + Long deptId = SecurityFrameworkUtils.getLoginUserDeptId(); + DeptRespDTO dept = deptApi.getDept(deptId); + // 这里可能出现查不到的情况,直接抛个系统错误先,不能影响后续操作 + if (ObjectUtil.isEmpty(dept)){ + throw exception(CommonErrorCodeConstants.SYSTEM_ERROR); + } + return success(companyService.getById(dept.getCorpId())); + } } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStController.java index 129b4eaf..49ae9c31 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStController.java @@ -1,7 +1,12 @@ package cn.iocoder.yudao.module.stockTransfer.controller.admin; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStService; +import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStRespVO; +import io.swagger.v3.oas.annotations.Operation; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -21,60 +26,19 @@ public class DlRepairStController{ @Resource private DlRepairStService dlRepairStService; -// /** -// * 分页查询所有数据 -// * -// * @param page 分页对象 -// * @param dlRepairSt 查询实体 -// * @return 所有数据 -// */ -// @GetMapping -// public R selectAll(Page page, DlRepairSt dlRepairSt) { -// return success(this.dlRepairStService.page(page, new QueryWrapper<>(dlRepairSt))); -// } -// -// /** -// * 通过主键查询单条数据 -// * -// * @param id 主键 -// * @return 单条数据 -// */ -// @GetMapping("{id}") -// public R selectOne(@PathVariable Serializable id) { -// return success(this.dlRepairStService.getById(id)); -// } -// -// /** -// * 新增数据 -// * -// * @param dlRepairSt 实体对象 -// * @return 新增结果 -// */ -// @PostMapping -// public R insert(@RequestBody DlRepairSt dlRepairSt) { -// return success(this.dlRepairStService.save(dlRepairSt)); -// } -// -// /** -// * 修改数据 -// * -// * @param dlRepairSt 实体对象 -// * @return 修改结果 -// */ -// @PutMapping -// public R update(@RequestBody DlRepairSt dlRepairSt) { -// return success(this.dlRepairStService.updateById(dlRepairSt)); -// } -// -// /** -// * 删除数据 -// * -// * @param idList 主键结合 -// * @return 删除结果 -// */ -// @DeleteMapping -// public R delete(@RequestParam("idList") List idList) { -// return success(this.dlRepairStService.removeByIds(idList)); -// } + /** + * 调拨单 新增 + * + * @author 小李 + * @date 19:06 2024/9/18 + * @param repairStRespVO 新增对象 + **/ + @PostMapping("/create") + @Operation(summary = "调拨单 新增") + public CommonResult createSt(@RequestBody DlRepairStRespVO repairStRespVO){ + dlRepairStService.createSt(repairStRespVO); + return CommonResult.ok(); + } + } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/entity/DlRepairSt.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/entity/DlRepairSt.java index fcdd69d4..39011f1e 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/entity/DlRepairSt.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/entity/DlRepairSt.java @@ -91,4 +91,9 @@ public class DlRepairSt extends TenantBaseDO { * 备注 */ private String remark; + + /** + * 部门ID(system_dept表的ID) + */ + private Long deptId; } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/entity/DlRepairSti.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/entity/DlRepairSti.java index caeb31d5..2f9d16b5 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/entity/DlRepairSti.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/entity/DlRepairSti.java @@ -48,9 +48,4 @@ public class DlRepairSti extends TenantBaseDO { * 备注 */ private String remark; - - /** - * 部门ID(system_dept表的ID) - */ - private Long deptId; } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/DlRepairStService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/DlRepairStService.java index a6284141..495b8baa 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/DlRepairStService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/DlRepairStService.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.stockTransfer.service; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt; +import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStRespVO; import com.baomidou.mybatisplus.extension.service.IService; /** @@ -11,4 +12,12 @@ import com.baomidou.mybatisplus.extension.service.IService; **/ public interface DlRepairStService extends IService { + /** + * 调拨单 新增 + * + * @author 小李 + * @date 19:06 2024/9/18 + * @param repairStRespVO 新增对象 + **/ + void createSt(DlRepairStRespVO repairStRespVO); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/impl/DlRepairStServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/impl/DlRepairStServiceImpl.java index 6bb108d3..f0e5318b 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/impl/DlRepairStServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/impl/DlRepairStServiceImpl.java @@ -1,11 +1,21 @@ package cn.iocoder.yudao.module.stockTransfer.service.impl; +import cn.hutool.core.collection.CollectionUtil; +import cn.iocoder.yudao.common.RepairErrorCodeConstants; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt; +import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStiService; +import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStRespVO; +import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStService; import cn.iocoder.yudao.module.stockTransfer.mapper.DlRepairStMapper; import org.springframework.stereotype.Service; +import javax.annotation.Resource; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; + /** * 针对表【dl_repair_st(调拨单)】的数据库操作Service实现 * @@ -16,6 +26,31 @@ import org.springframework.stereotype.Service; public class DlRepairStServiceImpl extends ServiceImpl implements DlRepairStService { + @Resource + private DlRepairStiService repairStiService; + + /** + * 调拨单 新增 + * + * @param repairStRespVO 新增对象 + * @author 小李 + * @date 19:06 2024/9/18 + **/ + @Override + @DSTransactional + public void createSt(DlRepairStRespVO repairStRespVO) { + // 获取当前登录用户的部门ID + Long deptId = SecurityFrameworkUtils.getLoginUserDeptId(); + repairStRespVO.setDeptId(deptId); + // 新增调拨单 + baseMapper.insert(repairStRespVO); + // 新增调拨单子表 + if (CollectionUtil.isEmpty(repairStRespVO.getGoodsList())) { + throw exception(RepairErrorCodeConstants.GOODS_IS_EMPTY); + } + repairStRespVO.getGoodsList().forEach(item -> item.setStId(repairStRespVO.getId())); + repairStiService.saveBatch(repairStRespVO.getGoodsList()); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/vo/DlRepairStRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/vo/DlRepairStRespVO.java index c94ca09a..48fc27b4 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/vo/DlRepairStRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/vo/DlRepairStRespVO.java @@ -1,8 +1,11 @@ package cn.iocoder.yudao.module.stockTransfer.vo; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt; +import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSti; import lombok.Data; +import java.util.List; + /** * 调拨单 响应VO * @author 小李 @@ -10,4 +13,7 @@ import lombok.Data; **/ @Data public class DlRepairStRespVO extends DlRepairSt { + + // 商品列表 + private List goodsList; } diff --git a/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStMapper.xml b/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStMapper.xml index 4daa1e4e..b738bc4a 100644 --- a/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStMapper.xml @@ -5,20 +5,21 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + @@ -35,7 +36,8 @@ this_debt, st_status, st_time, - remark + remark, + dept_id from dl_repair_st st where st.deleted = '0' diff --git a/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStiMapper.xml b/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStiMapper.xml index f71d84de..0f81bd7f 100644 --- a/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStiMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStiMapper.xml @@ -11,7 +11,6 @@ - @@ -20,8 +19,7 @@ goods_id, goods_count, goods_price, - remark, - dept_id + remark from dl_repair_sti sti where sti.deleted = '0'