From 5da4d8e5768cdfbc26316cec4b93b428c435bbce Mon Sep 17 00:00:00 2001 From: xiao-fajia <1665375861@qq.com> Date: Wed, 18 Sep 2024 20:00:50 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/CompanyController.java | 31 ++++++++ .../admin/DlRepairStController.java | 74 +++++-------------- .../stockTransfer/entity/DlRepairSt.java | 5 ++ .../stockTransfer/entity/DlRepairSti.java | 5 -- .../service/DlRepairStService.java | 9 +++ .../service/impl/DlRepairStServiceImpl.java | 35 +++++++++ .../stockTransfer/vo/DlRepairStRespVO.java | 6 ++ .../mapper/stockTransfer/DlRepairStMapper.xml | 32 ++++---- .../stockTransfer/DlRepairStiMapper.xml | 4 +- 9 files changed, 123 insertions(+), 78 deletions(-) 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' From 2086924387d271cf589fac4fb0dee8f29e89133f Mon Sep 17 00:00:00 2001 From: nyoung <12190070+nyoungo@user.noreply.gitee.com> Date: Wed, 18 Sep 2024 20:46:13 +0800 Subject: [PATCH 2/5] 1 --- dl-module-rescue/pom.xml | 8 +- .../controller/admin/SysLoginController.java | 81 +++++++++++++------ .../admin/user/vo/user/UserSaveReqVO.java | 2 + 3 files changed, 66 insertions(+), 25 deletions(-) diff --git a/dl-module-rescue/pom.xml b/dl-module-rescue/pom.xml index a49ff772..ded3b762 100644 --- a/dl-module-rescue/pom.xml +++ b/dl-module-rescue/pom.xml @@ -26,10 +26,16 @@ yudao-module-system-biz ${revision} + + cn.iocoder.boot + dl-module-inspection + 2.1.0-jdk8-snapshot + compile + 8 8 - \ No newline at end of file + diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java index 8d2286d1..6726c6ae 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java @@ -15,6 +15,11 @@ import cn.iocoder.yudao.module.rescue.domain.LoginBody; import cn.iocoder.yudao.module.rescue.domain.WxLoginBody; import cn.iocoder.yudao.module.rescue.service.IDriverInfoService; import cn.iocoder.yudao.module.rescue.utils.RescueSysLoginService; +import cn.iocoder.yudao.module.shop.entity.ShopConfig; +import cn.iocoder.yudao.module.shop.entity.UserBalance; +import cn.iocoder.yudao.module.shop.service.IShopConfigService; +import cn.iocoder.yudao.module.shop.service.IUserBalanceService; +import cn.iocoder.yudao.module.system.controller.admin.user.vo.user.UserSaveReqVO; import cn.iocoder.yudao.util.WechatPayConfig; import cn.iocoder.yudao.module.system.api.dict.DictDataApi; import cn.iocoder.yudao.module.system.api.permission.PermissionApi; @@ -98,14 +103,14 @@ public class SysLoginController { @Resource private SecurityProperties securityProperties; -// @Autowired -// private IUserBalanceService balanceService; + @Resource + private IUserBalanceService balanceService; // @Autowired // private IShopMallPartnersService partnersService; // @Autowired // private IPartnerWorkerService jcWorkerService; -// @Autowired -// private IShopConfigService configService; + @Resource + private IShopConfigService configService; @Resource private IDriverInfoService driverInfoService; // @Autowired @@ -333,33 +338,61 @@ public class SysLoginController { AdminUserDO user = userService.getUser(loginUser.getId()); List roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId()); List roleList = roleService.getRoleList(roleIdsByUserId); - // 角色集合 -// Set roles = roleList.stream().map(RoleDO::getCode).collect(Collectors.toSet()); -// UserBalance userBalance = balanceService.selectShopUserBalanceByUserId(NamedObject.user.getUserId()); -// if (ObjectUtil.isNotEmpty(userBalance)) { -// sysUser.setBalance(userBalance.getBalance()); -// } else { -// //新增用户积分表信息 -// userBalance=new UserBalance(); -// userBalance.setUserId(NamedObject.user.getUserId()); -// userBalance.setAllBalance(0L); -// userBalance.setBalance(0L); -// userBalance.setFrozenBalance(0L); -// balanceService.insertShopUserBalance(userBalance); -// sysUser.setBalance(0L); -// } Map ajax = new HashMap<>(); ajax.put("user", user); ajax.put("role", roleList); -// ShopConfig shopConfig = configService.selectShopConfigById(1L); -// if (StringUtils.isEmpty(shopConfig.getOpenRz())||shopConfig.getOpenRz().equals("0")){ -// ajax.put("openRz", "0"); -// }else { + ShopConfig shopConfig = configService.selectShopConfigById(1L); + if (StringUtils.isEmpty(shopConfig.getOpenRz())||shopConfig.getOpenRz().equals("0")){ ajax.put("openRz", "0"); -// } + }else { + ajax.put("openRz", "0"); + } return CommonResult.success(ajax); } + /** + * 获取App用户信息 + * + * @return 用户信息 + */ + @GetMapping("/getJcAppInfo") + @TenantIgnore + public CommonResult getJcAppInfo() + { + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + AdminUserDO user = userService.getUser(loginUser.getId()); + List roleIdsByUserId = permissionApi.getRoleIdsByUserId(user.getId()); + List roleList = roleService.getRoleList(roleIdsByUserId); + // 角色集合 + UserSaveReqVO userSaveReqVO = new UserSaveReqVO(); + UserBalance userBalance = balanceService.selectShopUserBalanceByUserId(loginUser.getId()); + if (ObjectUtil.isNotEmpty(userBalance)) { + userSaveReqVO.setBalance(userBalance.getBalance()); + } else { + //新增用户积分表信息 + userBalance=new UserBalance(); + userBalance.setUserId(loginUser.getId()); + userBalance.setAllBalance(0L); + userBalance.setBalance(0L); + userBalance.setFrozenBalance(0L); + balanceService.insertShopUserBalance(userBalance); + userSaveReqVO.setBalance(0L); + } + userService.updateUser(userSaveReqVO); + Map ajax = new HashMap<>(); + ajax.put("user", user); + ajax.put("role", roleList); + ShopConfig shopConfig = configService.selectShopConfigById(1L); + if (StringUtils.isEmpty(shopConfig.getOpenRz())||shopConfig.getOpenRz().equals("0")){ + ajax.put("openRz", "0"); + }else { + ajax.put("openRz", "0"); + } + return CommonResult.success(ajax); + } + + + /** * 获取App用户信息 * diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSaveReqVO.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSaveReqVO.java index dc371a93..62044204 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSaveReqVO.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/user/vo/user/UserSaveReqVO.java @@ -101,4 +101,6 @@ public class UserSaveReqVO { private Long tenantId; + private Long balance; + } From edf50e1b78bbd8908f692342b25a602086faecbf Mon Sep 17 00:00:00 2001 From: nyoung <12190070+nyoungo@user.noreply.gitee.com> Date: Thu, 19 Sep 2024 09:53:23 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=A4=9A=E7=A7=9F=E6=88=B7=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/tenant/TenantController.java | 11 +++++++++++ .../module/system/service/tenant/TenantService.java | 1 + .../system/service/tenant/TenantServiceImpl.java | 8 ++++++++ 3 files changed, 20 insertions(+) diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.java index eeb9a074..cc2dc493 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.java @@ -54,6 +54,17 @@ public class TenantController { return success(tenant != null ? tenant.getId() : null); } + + @GetMapping("/getListByWebsite") + @PermitAll + @Operation(summary = "使用域名,获得租户信息", description = "登录界面,根据用户的域名,获得租户信息") + @Parameter(name = "website", description = "域名", required = true, example = "www.iocoder.cn") + public CommonResult getListByWebsite(@RequestParam("website") String website) { + List tenants = tenantService.getListByWebsite(website); + return success(tenants); + } + + @PostMapping("/create") @Operation(summary = "创建租户") @PreAuthorize("@ss.hasPermission('system:tenant:create')") diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java index 29332c65..fc33ec0e 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java @@ -135,4 +135,5 @@ public interface TenantService { */ void validTenant(Long id); + List getListByWebsite(String website); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java index ae61d9b4..fae34c76 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java @@ -39,6 +39,7 @@ import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler; import cn.iocoder.yudao.module.system.service.user.AdminUserService; import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; @@ -106,6 +107,13 @@ public class TenantServiceImpl implements TenantService { } } + @Override + public List getListByWebsite(String website) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("website", website); + return tenantMapper.selectList(queryWrapper); + } + @Override @DSTransactional // 多数据源,使用 @DSTransactional 保证本地事务,以及数据源的切换 public Long createTenant(TenantSaveReqVO createReqVO) { From 8b91ce834e6ae64beb2c11a5e3ee370bbc296b97 Mon Sep 17 00:00:00 2001 From: xiao-fajia <1665375861@qq.com> Date: Thu, 19 Sep 2024 15:26:11 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/CompanyController.java | 6 ++ .../admin/DlRepairStController.java | 27 ++++++- .../admin/DlRepairStiController.java | 81 ++++++------------- .../stockTransfer/entity/DlRepairSt.java | 4 + .../mapper/DlRepairStMapper.java | 12 +++ .../mapper/DlRepairStiMapper.java | 12 +++ .../service/DlRepairStService.java | 12 +++ .../service/DlRepairStiService.java | 11 +++ .../service/impl/DlRepairStServiceImpl.java | 15 ++++ .../service/impl/DlRepairStiServiceImpl.java | 15 ++++ .../mapper/stockTransfer/DlRepairStMapper.xml | 10 +++ .../stockTransfer/DlRepairStiMapper.xml | 4 + .../src/main/resources/application.yaml | 2 +- 13 files changed, 151 insertions(+), 60 deletions(-) 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 6b11660b..26837fe7 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 @@ -11,6 +11,8 @@ 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 cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import cn.iocoder.yudao.module.company.vo.CompanyReqVO; @@ -56,6 +58,10 @@ public class CompanyController { @Lazy private DeptApi deptApi; + @Resource + @Lazy + private AdminUserApi adminUserApi; + @Autowired private CompanyService companyService; 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 49ae9c31..37958197 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 @@ -2,16 +2,18 @@ package cn.iocoder.yudao.module.stockTransfer.controller.admin; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt; import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStService; +import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStReqVO; import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStRespVO; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + /** * 调拨单(DlRepairSt)表控制层 * @author 小李 @@ -40,5 +42,22 @@ public class DlRepairStController{ return CommonResult.ok(); } + /** + * 调拨单(出库、入库) 分页 + * + * @author 小李 + * @date 9:20 2024/9/19 + * @param repairStReqVO 查询对象 + * @param pageNo 页码 + * @param pageSize 条数 + **/ + @GetMapping("/page") + @Operation(summary = "调拨单(出库、入库) 分页") + public CommonResult getStPage(DlRepairStReqVO repairStReqVO, + @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize){ + Page page = new Page<>(pageNo, pageSize); + return success(dlRepairStService.getStPage(repairStReqVO, page)); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStiController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStiController.java index 7e0ca9f2..9e63ffcc 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStiController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStiController.java @@ -1,12 +1,21 @@ package cn.iocoder.yudao.module.stockTransfer.controller.admin; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSti; import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStiService; +import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStiReqVO; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import io.swagger.v3.oas.annotations.Operation; +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 javax.annotation.Resource; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + /** * 调拨单子表(DlRepairSti)表控制层 * @author 小李 @@ -21,60 +30,22 @@ public class DlRepairStiController{ @Resource private DlRepairStiService dlRepairStiService; -// /** -// * 分页查询所有数据 -// * -// * @param page 分页对象 -// * @param dlRepairSti 查询实体 -// * @return 所有数据 -// */ -// @GetMapping -// public R selectAll(Page page, DlRepairSti dlRepairSti) { -// return success(this.dlRepairStiService.page(page, new QueryWrapper<>(dlRepairSti))); -// } -// -// /** -// * 通过主键查询单条数据 -// * -// * @param id 主键 -// * @return 单条数据 -// */ -// @GetMapping("{id}") -// public R selectOne(@PathVariable Serializable id) { -// return success(this.dlRepairStiService.getById(id)); -// } -// -// /** -// * 新增数据 -// * -// * @param dlRepairSti 实体对象 -// * @return 新增结果 -// */ -// @PostMapping -// public R insert(@RequestBody DlRepairSti dlRepairSti) { -// return success(this.dlRepairStiService.save(dlRepairSti)); -// } -// -// /** -// * 修改数据 -// * -// * @param dlRepairSti 实体对象 -// * @return 修改结果 -// */ -// @PutMapping -// public R update(@RequestBody DlRepairSti dlRepairSti) { -// return success(this.dlRepairStiService.updateById(dlRepairSti)); -// } -// -// /** -// * 删除数据 -// * -// * @param idList 主键结合 -// * @return 删除结果 -// */ -// @DeleteMapping -// public R delete(@RequestParam("idList") List idList) { -// return success(this.dlRepairStiService.removeByIds(idList)); -// } + /** + * 调拨单子表 分页 + * + * @author 小李 + * @date 14:48 2024/9/19 + * @param repairStiReqVO 查询对象 + * @param pageNo 页码 + * @param pageSize 条数 + **/ + @GetMapping("/page") + @Operation(summary = "调拨单子表 分页") + public CommonResult getStiPage(DlRepairStiReqVO repairStiReqVO, + @RequestParam(value = "pageNo", defaultValue = "1")Integer pageNo, + @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize){ + Page page = new Page<>(pageNo, pageSize); + return success(dlRepairStiService.getStiPage(repairStiReqVO, page)); + } } 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 39011f1e..d5edab79 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 @@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; +import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; import java.math.BigDecimal; @@ -85,6 +87,8 @@ public class DlRepairSt extends TenantBaseDO { /** * 调拔时间 */ + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd") private Date stTime; /** diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/mapper/DlRepairStMapper.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/mapper/DlRepairStMapper.java index 45eaefb7..1d3efea2 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/mapper/DlRepairStMapper.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/mapper/DlRepairStMapper.java @@ -1,8 +1,12 @@ package cn.iocoder.yudao.module.stockTransfer.mapper; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt; +import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStReqVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 针对表【dl_repair_st(调拨单)】的数据库操作Mapper @@ -13,6 +17,14 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface DlRepairStMapper extends BaseMapper { + /** + * 调拨单(出库、入库) 分页 + * + * @author 小李 + * @date 9:20 2024/9/19 + * @param repairStReqVO 查询对象 + **/ + IPage getStPage(@Param("map") DlRepairStReqVO repairStReqVO, Page page); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/mapper/DlRepairStiMapper.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/mapper/DlRepairStiMapper.java index 996f94e5..ebb8c2dd 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/mapper/DlRepairStiMapper.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/mapper/DlRepairStiMapper.java @@ -1,8 +1,12 @@ package cn.iocoder.yudao.module.stockTransfer.mapper; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSti; +import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStiReqVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** * 针对表【dl_repair_sti(调拨单子表)】的数据库操作Mapper @@ -13,6 +17,14 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface DlRepairStiMapper extends BaseMapper { + /** + * 调拨单子表 分页 + * + * @author 小李 + * @date 14:48 2024/9/19 + * @param repairStiReqVO 查询对象 + **/ + IPage getStiPage(@Param("map") DlRepairStiReqVO repairStiReqVO, Page page); } 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 495b8baa..ba59fcc0 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,7 +1,10 @@ package cn.iocoder.yudao.module.stockTransfer.service; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt; +import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStReqVO; import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStRespVO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; /** @@ -20,4 +23,13 @@ public interface DlRepairStService extends IService { * @param repairStRespVO 新增对象 **/ void createSt(DlRepairStRespVO repairStRespVO); + + /** + * 调拨单(出库、入库) 分页 + * + * @author 小李 + * @date 9:20 2024/9/19 + * @param repairStReqVO 查询对象 + **/ + IPage getStPage(DlRepairStReqVO repairStReqVO, Page page); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/DlRepairStiService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/DlRepairStiService.java index a47980d6..711ae2e2 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/DlRepairStiService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/DlRepairStiService.java @@ -1,6 +1,9 @@ package cn.iocoder.yudao.module.stockTransfer.service; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSti; +import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStiReqVO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; /** @@ -10,4 +13,12 @@ import com.baomidou.mybatisplus.extension.service.IService; **/ public interface DlRepairStiService extends IService { + /** + * 调拨单子表 分页 + * + * @author 小李 + * @date 14:48 2024/9/19 + * @param repairStiReqVO 查询对象 + **/ + IPage getStiPage(DlRepairStiReqVO repairStiReqVO, Page page); } 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 f0e5318b..c83ed130 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 @@ -5,8 +5,11 @@ 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.DlRepairStReqVO; import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStRespVO; import com.baomidou.dynamic.datasource.annotation.DSTransactional; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStService; import cn.iocoder.yudao.module.stockTransfer.mapper.DlRepairStMapper; @@ -51,6 +54,18 @@ public class DlRepairStServiceImpl extends ServiceImpl item.setStId(repairStRespVO.getId())); repairStiService.saveBatch(repairStRespVO.getGoodsList()); } + + /** + * 调拨单(出库、入库) 分页 + * + * @author 小李 + * @date 9:20 2024/9/19 + * @param repairStReqVO 查询对象 + **/ + @Override + public IPage getStPage(DlRepairStReqVO repairStReqVO, Page page){ + return baseMapper.getStPage(repairStReqVO, page); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/impl/DlRepairStiServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/impl/DlRepairStiServiceImpl.java index 7572dea3..1821acce 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/impl/DlRepairStiServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/service/impl/DlRepairStiServiceImpl.java @@ -3,6 +3,9 @@ package cn.iocoder.yudao.module.stockTransfer.service.impl; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSti; import cn.iocoder.yudao.module.stockTransfer.mapper.DlRepairStiMapper; import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStiService; +import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStiReqVO; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; @@ -16,6 +19,18 @@ import org.springframework.stereotype.Service; public class DlRepairStiServiceImpl extends ServiceImpl implements DlRepairStiService { + /** + * 调拨单子表 分页 + * + * @author 小李 + * @date 14:48 2024/9/19 + * @param repairStiReqVO 查询对象 + **/ + @Override + public IPage getStiPage(DlRepairStiReqVO repairStiReqVO, Page page){ + return baseMapper.getStiPage(repairStiReqVO, page); + } + } 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 b738bc4a..6ca9c49a 100644 --- a/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStMapper.xml @@ -41,4 +41,14 @@ 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 0f81bd7f..690e277c 100644 --- a/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStiMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/stockTransfer/DlRepairStiMapper.xml @@ -23,4 +23,8 @@ from dl_repair_sti sti where sti.deleted = '0' + + diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index 607d412d..5f80c4fc 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -68,7 +68,7 @@ flowable: mybatis-plus: configuration: map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl +# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl global-config: db-config: id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 From 221eb5c7aeaa7f7f2fa0e15d154424c3f69311fe Mon Sep 17 00:00:00 2001 From: nyoung <12190070+nyoungo@user.noreply.gitee.com> Date: Thu, 19 Sep 2024 15:54:03 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=B1=BD=E4=BF=AE=E7=99=BB=E5=BD=95=20?= =?UTF-8?q?=E6=B3=A8=E5=86=8C=20=E9=AA=8C=E8=AF=81=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/SysLoginController.java | 78 ++++++++++++++++++- .../yudao/module/rescue/vo/RegisterVO.java | 10 +++ .../src/main/resources/application.yaml | 2 + 3 files changed, 87 insertions(+), 3 deletions(-) create mode 100644 dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/vo/RegisterVO.java diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java index 6726c6ae..8c3d1e2a 100644 --- a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/app/controller/admin/SysLoginController.java @@ -15,6 +15,8 @@ import cn.iocoder.yudao.module.rescue.domain.LoginBody; import cn.iocoder.yudao.module.rescue.domain.WxLoginBody; import cn.iocoder.yudao.module.rescue.service.IDriverInfoService; import cn.iocoder.yudao.module.rescue.utils.RescueSysLoginService; +import cn.iocoder.yudao.module.rescue.utils.SendSmsUtil; +import cn.iocoder.yudao.module.rescue.vo.RegisterVO; import cn.iocoder.yudao.module.shop.entity.ShopConfig; import cn.iocoder.yudao.module.shop.entity.UserBalance; import cn.iocoder.yudao.module.shop.service.IShopConfigService; @@ -39,6 +41,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import io.swagger.v3.oas.annotations.Operation; import lombok.extern.slf4j.Slf4j; import com.sun.org.apache.xerces.internal.impl.dv.util.Base64; +import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.client.RestTemplate; @@ -50,12 +53,13 @@ import javax.crypto.spec.SecretKeySpec; import javax.servlet.http.HttpServletRequest; import java.security.spec.AlgorithmParameterSpec; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.error; -import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.*; +import static cn.iocoder.yudao.module.rescue.utils.RescueSysLoginService.generateVerificationCode; /** * 登录验证 @@ -77,7 +81,8 @@ public class SysLoginController { @Resource private PermissionApi permissionApi; - + @Resource + private PasswordEncoder passwordEncoder; @Resource private RoleApi roleApi; @@ -190,6 +195,73 @@ public class SysLoginController { } + /** + * 汽修小程序登录方法 + * + * @param loginBody 登录信息 + * @return 结果 + */ + @PostMapping("/loginQx") + @TenantIgnore + public CommonResult loginQx(@RequestBody LoginBody loginBody) throws Exception { + String userName = loginBody.getUsername(); + AdminUserDO user = userService.getUserByUsername(userName); + if (ObjectUtil.isEmpty(user)) { + return error(CommonErrorCodeConstants.LOGIN_ACCOUNT_NOT_EXIST); + } + AuthLoginReqVO authLoginReqVO = new AuthLoginReqVO(); + authLoginReqVO.setUsername(loginBody.getUsername()); + authLoginReqVO.setPassword(loginBody.getPassword()); + return success(loginService.login(authLoginReqVO)); + } + + /** + * 发送验证码 + * @param phone + * @return + */ + @GetMapping("/sendSmsQx") + @TenantIgnore + public CommonResult sendSmsQx(@RequestParam("phone") String phone) { + String msgCode = generateVerificationCode(); + redisCache2.setCacheObject(phone+"-registerCode",msgCode,300, TimeUnit.SECONDS); + SendSmsUtil.sendMsg(msgCode,phone,"1400852709","机动车管家小程序","1917285"); + return ok(); + } + + /** + * 汽修小程序注册方法 + * + * @param registerVO 登录信息 + * @return 结果 + */ + @PostMapping("/registerQx") + @TenantIgnore + public CommonResult registerQx(@RequestBody RegisterVO registerVO){ + if(org.apache.commons.lang3.StringUtils.isEmpty(registerVO.getPhone())){ + return error(500,"手机号不能为空"); + } + if(org.apache.commons.lang3.StringUtils.isEmpty(registerVO.getPassword())){ + return error(500,"密码不能为空"); + } + if(org.apache.commons.lang3.StringUtils.isEmpty(registerVO.getCode())){ + return error(500,"验证码不能为空"); + } + Object registerCode = redisCache2.getCacheObject(registerVO.getPhone() + "-registerCode"); + if(null==registerCode || !registerCode.equals(registerVO.getCode())){ + return error(500,"验证码错误"); + } + redisCache2.deleteObject(registerVO.getPhone() + "-registerCode"); + + UserSaveReqVO userSaveReqVO = new UserSaveReqVO(); + userSaveReqVO.setUsername(registerVO.getPhone()); + userSaveReqVO.setPassword(passwordEncoder.encode(registerVO.getPassword())); + userSaveReqVO.setMobile(registerVO.getPhone()); + userService.createUser(userSaveReqVO); + return success("注册成功"); + } + + /** * 司机登录方法 * diff --git a/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/vo/RegisterVO.java b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/vo/RegisterVO.java new file mode 100644 index 00000000..09fb9c10 --- /dev/null +++ b/dl-module-rescue/src/main/java/cn/iocoder/yudao/module/rescue/vo/RegisterVO.java @@ -0,0 +1,10 @@ +package cn.iocoder.yudao.module.rescue.vo; + +import lombok.Data; + +@Data +public class RegisterVO { + private String phone; + private String password; + private String code; +} diff --git a/yudao-server/src/main/resources/application.yaml b/yudao-server/src/main/resources/application.yaml index 5f80c4fc..f7c67f32 100644 --- a/yudao-server/src/main/resources/application.yaml +++ b/yudao-server/src/main/resources/application.yaml @@ -225,6 +225,7 @@ yudao: - /admin-api/rescue/wxLoginRescue - /admin-api/rescue/wxLoginJc - /admin-api/rescue/loginJcApp + - /admin-api/system/tenant/getListByWebsite websocket: enable: true # websocket的开关 path: /infra/ws # 路径 @@ -274,6 +275,7 @@ yudao: - /admin-api/appInspection/goods/canLedCouponPlatform - /admin-api/rescue/loginApp - /admin-api/rescue/loginJcApp + - /admin-api/system/tenant/getListByWebsite ignore-tables: - system_tenant - system_tenant_package