| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.tcm.training.admin.common.enums.EnabledStatus; |
| | | import com.tcm.training.admin.common.enums.EnabledStatusEnum; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | |
| | | agent.setAccountHolder(trim(request.getAccountHolder())); |
| | | agent.setBranchName(trim(request.getBranchName())); |
| | | agent.setContactInfo(trim(request.getContactInfo())); |
| | | agent.setStatus(request.getStatus() == null ? EnabledStatus.ENABLED.getValue() : request.getStatus()); |
| | | agent.setStatus(request.getStatus() == null ? EnabledStatusEnum.ENABLED.getValue() : request.getStatus()); |
| | | agent.setAddress(trim(request.getAddress())); |
| | | } |
| | | |
| | |
| | | package com.tcm.training.admin.app.bankcard.service; |
| | | |
| | | import com.tcm.training.admin.app.auth.service.AppAuthSessionService; |
| | | import com.tcm.training.admin.member.enums.UserType; |
| | | import com.tcm.training.admin.member.enums.UserTypeEnum; |
| | | import com.tcm.training.admin.app.bankcard.dto.AppBankCardUpdateRequest; |
| | | import com.tcm.training.admin.app.bankcard.vo.AppBankCardVO; |
| | | import com.tcm.training.admin.live.entity.Clinic; |
| | |
| | | private Clinic requireClinic() { |
| | | AppUser user = userMapper.selectById(sessionService.requireLoginUserId()); |
| | | if (user == null || user.getDeleted() == null || user.getDeleted() != 0) throw new IllegalArgumentException("用户不存在"); |
| | | if (user.getType() == null || user.getType() != UserType.CLINIC.getValue() || user.getClinicId() == null) throw new IllegalArgumentException("当前账号未绑定诊所"); |
| | | if (user.getType() == null || user.getType() != UserTypeEnum.CLINIC.getValue() || user.getClinicId() == null) throw new IllegalArgumentException("当前账号未绑定诊所"); |
| | | Clinic clinic = clinicMapper.selectById(user.getClinicId()); |
| | | if (clinic == null || clinic.getDeleted() == null || clinic.getDeleted() != 0) throw new IllegalArgumentException("诊所不存在"); |
| | | return clinic; |
| | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.tcm.training.admin.member.enums.UserStatus; |
| | | import com.tcm.training.admin.member.enums.UserType; |
| | | import com.tcm.training.admin.member.enums.UserStatusEnum; |
| | | import com.tcm.training.admin.member.enums.UserTypeEnum; |
| | | |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | |
| | | |
| | | AppUser user = new AppUser(); |
| | | user.setPhone(phone); |
| | | user.setType(UserType.DOCTOR.getValue()); |
| | | user.setStatus(UserStatus.ENABLED.getValue()); |
| | | user.setType(UserTypeEnum.DOCTOR.getValue()); |
| | | user.setStatus(UserStatusEnum.ENABLED.getValue()); |
| | | |
| | | // 优先同步海诊通同手机号用户资料,未命中时使用手机号兜底昵称。 |
| | | HztAppUser hztAppUser = findHztAppUserByPhone(phone); |
| | |
| | | clinic.setAddress(trimRequired(request.getDetailAddress(), "请输入详细地址")); |
| | | clinic.setBusinessLicenseUrl(trimToNull(request.getBusinessLicenseUrl())); |
| | | clinic.setInviteCode(generateInviteCode()); |
| | | clinic.setStatus(UserStatus.ENABLED.getValue()); |
| | | clinic.setStatus(UserStatusEnum.ENABLED.getValue()); |
| | | |
| | | clinic.setAgentId(4L); // 绑定到默认的省代上面 |
| | | |
| | |
| | | AppUser user = new AppUser(); |
| | | user.setNickname(clinic.getName()); |
| | | user.setPhone(draft.getPhone()); |
| | | user.setType(UserType.CLINIC.getValue()); |
| | | user.setStatus(UserStatus.ENABLED.getValue()); |
| | | user.setType(UserTypeEnum.CLINIC.getValue()); |
| | | user.setStatus(UserStatusEnum.ENABLED.getValue()); |
| | | user.setClinicId(clinic.getId()); |
| | | userMapper.insert(user); |
| | | |
| | |
| | | import org.springframework.boot.ApplicationRunner; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.stereotype.Component; |
| | | import com.tcm.training.admin.common.enums.EnabledStatus; |
| | | import com.tcm.training.admin.common.enums.EnabledStatusEnum; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | |
| | | user.setUsername("admin"); |
| | | user.setNickname("管理员"); |
| | | user.setRealName("系统管理员"); |
| | | user.setStatus(EnabledStatus.ENABLED.getValue()); |
| | | user.setStatus(EnabledStatusEnum.ENABLED.getValue()); |
| | | user.setDeleted(0); |
| | | user.setPassword(passwordEncoder.encode("Admin@123456")); |
| | | user.setCreatedAt(LocalDateTime.now()); |
| | |
| | | role = new SysRole(); |
| | | role.setRoleName("超级管理员"); |
| | | role.setRoleCode("SUPER_ADMIN"); |
| | | role.setStatus(EnabledStatus.ENABLED.getValue()); |
| | | role.setStatus(EnabledStatusEnum.ENABLED.getValue()); |
| | | role.setDeleted(0); |
| | | role.setRemark("默认拥有全部后台权限"); |
| | | role.setCreatedAt(LocalDateTime.now()); |
| | |
| | | menu.setComponent(component); |
| | | menu.setIcon(icon); |
| | | menu.setSort(sort); |
| | | menu.setStatus(EnabledStatus.ENABLED.getValue()); |
| | | menu.setStatus(EnabledStatusEnum.ENABLED.getValue()); |
| | | menu.setVisible(1); |
| | | menu.setPermissionKey(permissionKey); |
| | | menu.setRemark(remark); |
| New file |
| | |
| | | package com.tcm.training.admin.common.enums; |
| | | |
| | | /** 通用启用状态。 */ |
| | | public enum EnabledStatusEnumEnum { |
| | | DISABLED(0, "禁用"), ENABLED(1, "启用"); |
| | | /** 状态编码。 */ private final int code; |
| | | /** 状态描述。 */ private final String desc; |
| | | EnabledStatusEnumEnum(int code, String desc) { this.code = code; this.desc = desc; } |
| | | public int getCode() { return code; } |
| | | public int getValue() { return code; } |
| | | public String getDesc() { return desc; } |
| | | public static EnabledStatusEnumEnum getByCode(int code) { for (EnabledStatusEnumEnum item : values()) if (item.code == code) return item; return null; } |
| | | } |
| | |
| | | @Getter |
| | | @Setter |
| | | @NoArgsConstructor |
| | | /** 直播间基础配置实体。 */ |
| | | public class LiveRoomSetting { |
| | | /** 首页横幅图片地址。 */ |
| | | @TableField("banner_image_url") |
| | | private String bannerImageUrl; |
| | | |
| | | /** 直播间地址。 */ |
| | | @TableField("live_room_url") |
| | | private String liveRoomUrl; |
| | | } |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import com.tcm.training.admin.common.enums.EnabledStatus; |
| | | import com.tcm.training.admin.common.enums.EnabledStatusEnum; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | |
| | | if (expert == null) { |
| | | throw new IllegalArgumentException("授课专家不存在"); |
| | | } |
| | | if (expert.getStatus() != null && expert.getStatus() != EnabledStatus.ENABLED.getValue()) { |
| | | if (expert.getStatus() != null && expert.getStatus() != EnabledStatusEnum.ENABLED.getValue()) { |
| | | throw new IllegalArgumentException("授课专家已禁用"); |
| | | } |
| | | } |
| New file |
| | |
| | | package com.tcm.training.admin.member.enums; |
| | | |
| | | /** APP 用户状态。 */ |
| | | public enum UserStatusEnumEnum { |
| | | DISABLED(0, "禁用"), ENABLED(1, "启用"); |
| | | /** 状态编码。 */ private final int code; |
| | | /** 状态描述。 */ private final String desc; |
| | | UserStatusEnumEnum(int code, String desc) { this.code = code; this.desc = desc; } |
| | | public int getCode() { return code; } |
| | | public int getValue() { return code; } |
| | | public String getDesc() { return desc; } |
| | | public static UserStatusEnumEnum getByCode(int code) { for (UserStatusEnumEnum item : values()) if (item.code == code) return item; return null; } |
| | | } |
| New file |
| | |
| | | package com.tcm.training.admin.member.enums; |
| | | |
| | | /** APP 用户类型。 */ |
| | | public enum UserTypeEnumEnum { |
| | | DOCTOR(0, "医生"), CLINIC(1, "诊所"); |
| | | /** 类型编码。 */ private final int code; |
| | | /** 类型描述。 */ private final String desc; |
| | | UserTypeEnumEnum(int code, String desc) { this.code = code; this.desc = desc; } |
| | | public int getCode() { return code; } |
| | | public int getValue() { return code; } |
| | | public String getDesc() { return desc; } |
| | | public static UserTypeEnumEnum getByCode(int code) { for (UserTypeEnumEnum item : values()) if (item.code == code) return item; return null; } |
| | | } |
| | |
| | | .doWrite(Collections.emptyList()); |
| | | } |
| | | |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importAgentBindings(MultipartFile file) throws IOException { |
| | | if (file == null || file.isEmpty()) { |
| | | throw new IllegalArgumentException("请选择导入文件"); |
| | |
| | | return vo; |
| | | } |
| | | |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public UserDetailVO update(Long id, UserUpdateRequest req) { |
| | | AppUser user = requireUser(id); |
| | | if (req.getClinicId() != null) { |
| | |
| | | return detail(id); |
| | | } |
| | | |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public UserStatusVO patchStatus(Long id, UserStatusRequest req) { |
| | | AppUser user = requireUser(id); |
| | | user.setStatus(req.getStatus()); |
| | |
| | | return new UserStatusVO(id, req.getStatus()); |
| | | } |
| | | |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void resetPassword(Long id, UserResetPasswordRequest req) { |
| | | AppUser user = requireUser(id); |
| | | if (!req.getNewPassword().equals(req.getConfirmPassword())) { |
| | |
| | | userMapper.updateById(user); |
| | | } |
| | | |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void delete(Long id) { |
| | | requireUser(id); |
| | | userMapper.deleteById(id); |
| | | } |
| | | |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public UserDetailVO unbindWechat(Long id) { |
| | | requireUser(id); |
| | | userMapper.update(null, new LambdaUpdateWrapper<AppUser>() |
| | |
| | | return detail(id); |
| | | } |
| | | |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void batchUpdateClinic(UserBatchClinicUpdateRequest req) { |
| | | Clinic clinic = clinicMapper.selectById(req.getClinicId()); |
| | | if (clinic == null || Integer.valueOf(1).equals(clinic.getDeleted())) { |
| | |
| | | public UserStatisticsVO statistics(String type, LocalDate dateFrom, LocalDate dateTo) { |
| | | DateRange range = normalizeRange(dateFrom, dateTo); |
| | | String normalizedType = normalizeType(type); |
| | | String mapperUserType = resolveUserType(normalizedType); |
| | | String mapperUserTypeEnum = resolveUserTypeEnum(normalizedType); |
| | | LocalDateTime startTime = range.getStart().atStartOfDay(); |
| | | LocalDateTime endTime = LocalDateTime.of(range.getEnd(), LocalTime.MAX); |
| | | |
| | | UserStatisticsOverviewRow overviewRow = userStatisticsMapper.selectOverview(mapperUserType, startTime, endTime); |
| | | List<UserStatisticsRegisterTrendRow> registerRows = userStatisticsMapper.selectRegisterTrend(mapperUserType, startTime, endTime); |
| | | List<UserStatisticsActiveTrendRow> activeRows = userStatisticsMapper.selectActiveTrend(mapperUserType, startTime, endTime); |
| | | UserStatisticsCompositionRow compositionRow = userStatisticsMapper.selectMemberComposition(mapperUserType, startTime, endTime); |
| | | UserStatisticsOverviewRow overviewRow = userStatisticsMapper.selectOverview(mapperUserTypeEnum, startTime, endTime); |
| | | List<UserStatisticsRegisterTrendRow> registerRows = userStatisticsMapper.selectRegisterTrend(mapperUserTypeEnum, startTime, endTime); |
| | | List<UserStatisticsActiveTrendRow> activeRows = userStatisticsMapper.selectActiveTrend(mapperUserTypeEnum, startTime, endTime); |
| | | UserStatisticsCompositionRow compositionRow = userStatisticsMapper.selectMemberComposition(mapperUserTypeEnum, startTime, endTime); |
| | | |
| | | UserStatisticsVO result = new UserStatisticsVO(); |
| | | result.setOverview(buildOverview(overviewRow)); |
| | |
| | | throw new IllegalArgumentException("用户类型不合法"); |
| | | } |
| | | |
| | | private String resolveUserType(String normalizedType) { |
| | | private String resolveUserTypeEnum(String normalizedType) { |
| | | if (FILTER_ALL.equals(normalizedType)) { |
| | | return null; |
| | | } |
| | |
| | | return toDetailVO(requireItem(id)); |
| | | } |
| | | |
| | | @Transactional |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AppVersionDetailVO create(AppVersionCreateRequest request) { |
| | | AppVersionConfig latest = latest(); |
| | | String androidFileUrl = normalizeOptionalText(request.getAndroidFileUrl()); |