diff --git a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileMerchantInfoController.java b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileMerchantInfoController.java index 9ad7e4e44..7de832f47 100644 --- a/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileMerchantInfoController.java +++ b/jsowell-admin/src/main/java/com/jsowell/web/controller/pile/PileMerchantInfoController.java @@ -7,6 +7,7 @@ import com.jsowell.common.core.page.TableDataInfo; import com.jsowell.common.enums.BusinessType; import com.jsowell.common.util.poi.ExcelUtil; import com.jsowell.pile.domain.PileMerchantInfo; +import com.jsowell.pile.dto.CreateMerchantDTO; import com.jsowell.pile.service.IPileMerchantInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.access.prepost.PreAuthorize; @@ -77,7 +78,7 @@ public class PileMerchantInfoController extends BaseController { @PreAuthorize("@ss.hasPermi('pile:merchant:add')") @Log(title = "充电桩运营商信息", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody PileMerchantInfo pileMerchantInfo) { + public AjaxResult add(@RequestBody CreateMerchantDTO pileMerchantInfo) { return toAjax(pileMerchantInfoService.insertPileMerchantInfo(pileMerchantInfo)); } diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/dto/CreateMerchantDTO.java b/jsowell-pile/src/main/java/com/jsowell/pile/dto/CreateMerchantDTO.java new file mode 100644 index 000000000..a9548ca72 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/pile/dto/CreateMerchantDTO.java @@ -0,0 +1,69 @@ +package com.jsowell.pile.dto; + +import lombok.Getter; +import lombok.Setter; + +/** + * 创建运营商DTO + */ +@Getter +@Setter +public class CreateMerchantDTO { + private Long id; + + /** + * 运营商名称 + */ + private String merchantName; + + /** + * 地址 + */ + private String address; + + /** + * 状态 + * 0-失效;1-生效 + */ + private String status; + + /** + * 组织机构代码 + */ + private String organizationCode; + + /** + * 负责人姓名 + */ + private String managerName; + + /** + * 负责人电话号码 + */ + private String managerPhone; + + /** + * 客服电话号码 + */ + private String servicePhone; + + /** + * logo + */ + private String logoUrl; + + /** + * 运营商的小程序appId + */ + private String appId; + + /** + * 部门id + */ + private String deptId; + + private String userName; + + private String password; + +} diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileMerchantInfoService.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileMerchantInfoService.java index f1ee27a32..91e0b0c82 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileMerchantInfoService.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/IPileMerchantInfoService.java @@ -1,6 +1,7 @@ package com.jsowell.pile.service; import com.jsowell.pile.domain.PileMerchantInfo; +import com.jsowell.pile.dto.CreateMerchantDTO; import com.jsowell.pile.vo.base.MerchantInfoVO; import java.util.List; @@ -34,7 +35,7 @@ public interface IPileMerchantInfoService { * @param pileMerchantInfo 充电桩运营商信息 * @return 结果 */ - public int insertPileMerchantInfo(PileMerchantInfo pileMerchantInfo); + public int insertPileMerchantInfo(CreateMerchantDTO pileMerchantInfo); /** * 修改充电桩运营商信息 diff --git a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileMerchantInfoServiceImpl.java b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileMerchantInfoServiceImpl.java index c548e0660..491d0e285 100644 --- a/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileMerchantInfoServiceImpl.java +++ b/jsowell-pile/src/main/java/com/jsowell/pile/service/impl/PileMerchantInfoServiceImpl.java @@ -3,19 +3,22 @@ package com.jsowell.pile.service.impl; import com.google.common.collect.Lists; import com.jsowell.common.constant.Constants; import com.jsowell.common.core.domain.entity.SysDept; +import com.jsowell.common.core.domain.entity.SysUser; import com.jsowell.common.core.domain.vo.AuthorizedDeptVO; import com.jsowell.common.util.DateUtils; import com.jsowell.common.util.DictUtils; import com.jsowell.common.util.SecurityUtils; import com.jsowell.common.util.StringUtils; import com.jsowell.pile.domain.PileMerchantInfo; +import com.jsowell.pile.dto.CreateMerchantDTO; import com.jsowell.pile.mapper.PileMerchantInfoMapper; import com.jsowell.pile.service.IPileMerchantInfoService; import com.jsowell.pile.vo.base.MerchantInfoVO; import com.jsowell.system.service.SysDeptService; +import com.jsowell.system.service.SysUserService; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -37,8 +40,8 @@ public class PileMerchantInfoServiceImpl implements IPileMerchantInfoService { @Autowired private SysDeptService sysDeptService; - @Value("${weixin.login.appid}") - private String appid; + @Autowired + private SysUserService userService; /** * 查询充电桩运营商信息 @@ -82,35 +85,46 @@ public class PileMerchantInfoServiceImpl implements IPileMerchantInfoService { /** * 新增充电桩运营商信息 * - * @param pileMerchantInfo 充电桩运营商信息 + * @param dto 充电桩运营商信息 * @return 结果 */ @Override @Transactional - public int insertPileMerchantInfo(PileMerchantInfo pileMerchantInfo) { + public int insertPileMerchantInfo(CreateMerchantDTO dto) { // 1. 新增sys_dept SysDept dept = new SysDept(); dept.setParentId(100L); dept.setOrderNum(0); - dept.setDeptName(pileMerchantInfo.getMerchantName()); - dept.setLeader(pileMerchantInfo.getManagerName()); - dept.setPhone(pileMerchantInfo.getManagerPhone()); + dept.setDeptName(dto.getMerchantName()); + dept.setLeader(dto.getManagerName()); + dept.setPhone(dto.getManagerPhone()); dept.setStatus("0"); sysDeptService.insertDept(dept); // 2. 新增pile_merchant_info Long deptId = dept.getDeptId(); - // pileMerchantInfo.setId(deptId); - pileMerchantInfo.setDeptId(String.valueOf(deptId)); - pileMerchantInfo.setStatus(Constants.ONE); - // String appId = StringUtils.isBlank(pileMerchantInfo.getAppId()) + // dto.setId(deptId); + dto.setDeptId(String.valueOf(deptId)); + dto.setStatus(Constants.ONE); + // String appId = StringUtils.isBlank(dto.getAppId()) // ? appid - // : pileMerchantInfo.getAppId(); - pileMerchantInfo.setAppId(pileMerchantInfo.getAppId()); + // : dto.getAppId(); + dto.setAppId(dto.getAppId()); + + PileMerchantInfo pileMerchantInfo = new PileMerchantInfo(); + BeanUtils.copyProperties(dto, pileMerchantInfo); int i = pileMerchantInfoMapper.insertPileMerchantInfo(pileMerchantInfo); // 3 创建运营商管理员 - + SysUser user = new SysUser(); + user.setDeptId(deptId); + user.setUserName(dto.getUserName()); + user.setNickName(dto.getMerchantName()); + user.setPassword(dto.getPassword()); + user.setStatus(Constants.ZERO); + user.setPostIds(new Long[]{}); + user.setRoleIds(new Long[]{}); + userService.createUser(user); return i; }