-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b5c973
commit 1645af8
Showing
84 changed files
with
3,070 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/admin/AdminAccount.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package cn.chenyunlong.qing.domain.auth.admin; | ||
|
||
import cn.chenyunlong.codegen.annotation.*; | ||
import cn.chenyunlong.common.annotation.FieldDesc; | ||
import cn.chenyunlong.common.constants.ValidStatus; | ||
import cn.chenyunlong.jpa.support.BaseJpaAggregate; | ||
import cn.chenyunlong.jpa.support.converter.ValidStatusConverter; | ||
import cn.hutool.core.util.IdUtil; | ||
import jakarta.persistence.Column; | ||
import jakarta.persistence.Convert; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Table; | ||
import jakarta.validation.constraints.NotBlank; | ||
import lombok.*; | ||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; | ||
|
||
@EqualsAndHashCode(callSuper = false) | ||
@Getter | ||
@Setter | ||
@ToString | ||
@GenVo | ||
@GenCreator | ||
@GenUpdater | ||
@GenQuery | ||
@GenCreateRequest | ||
@GenUpdateRequest | ||
@GenQueryRequest | ||
@GenResponse | ||
@GenRepository | ||
@GenService | ||
@GenServiceImpl | ||
@GenFeign(serverName = "stanic") | ||
@GenController | ||
@GenMapper | ||
@Entity | ||
@Table(name = "admin_account") | ||
@Data | ||
public class AdminAccount extends BaseJpaAggregate { | ||
|
||
@FieldDesc(name = "手机号") | ||
@NotBlank(message = "手机号不能为空") | ||
private String phone; | ||
|
||
@FieldDesc(name = "密码") | ||
@IgnoreVo | ||
@NotBlank(message = "密码不能为空") | ||
private String password; | ||
|
||
@FieldDesc(name = "用户名") | ||
private String username; | ||
|
||
private String uid; | ||
|
||
private String realName; | ||
|
||
@FieldDesc(name = "部门ID") | ||
private Long departmentId; | ||
|
||
@FieldDesc(name = "额外信息") | ||
@Column(columnDefinition = "text") | ||
private String extInfo; | ||
|
||
@Convert(converter = ValidStatusConverter.class) | ||
@IgnoreUpdater | ||
@IgnoreCreator | ||
private ValidStatus validStatus; | ||
|
||
public void init() { | ||
setValidStatus(ValidStatus.VALID); | ||
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(); | ||
setPassword(encoder.encode(getPassword())); | ||
setUid(IdUtil.randomUUID().replaceAll("-", "")); | ||
} | ||
|
||
public void valid() { | ||
setValidStatus(ValidStatus.VALID); | ||
} | ||
|
||
public void invalid() { | ||
setValidStatus(ValidStatus.INVALID); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/admin/AdminAccountPlatformRel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package cn.chenyunlong.qing.domain.auth.admin; | ||
|
||
import cn.chenyunlong.codegen.annotation.GenRepository; | ||
import cn.chenyunlong.jpa.support.BaseJpaAggregate; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Table; | ||
import lombok.*; | ||
|
||
|
||
@GenRepository | ||
@Entity | ||
@Table(name = "admin_account_platform_rel") | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@EqualsAndHashCode(callSuper = false) | ||
public class AdminAccountPlatformRel extends BaseJpaAggregate { | ||
|
||
private Long adminAccountId; | ||
|
||
private Long platformId; | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
qing-domain/src/main/java/cn/chenyunlong/qing/domain/auth/admin/AdminAccountRoleRel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package cn.chenyunlong.qing.domain.auth.admin; | ||
|
||
import cn.chenyunlong.codegen.annotation.GenRepository; | ||
import cn.chenyunlong.jpa.support.BaseJpaAggregate; | ||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Table; | ||
import lombok.*; | ||
|
||
@EqualsAndHashCode(callSuper = false) | ||
@GenRepository | ||
@Entity | ||
@Table(name = "admin_account_role_rel") | ||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class AdminAccountRoleRel extends BaseJpaAggregate { | ||
|
||
private Long adminAccountId; | ||
|
||
private Long roleId; | ||
|
||
} |
116 changes: 116 additions & 0 deletions
116
...rc/main/java/cn/chenyunlong/qing/domain/auth/admin/controller/AdminAccountController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
package cn.chenyunlong.qing.domain.auth.admin.controller; | ||
|
||
import cn.chenyunlong.common.constants.CodeEnum; | ||
import cn.chenyunlong.common.model.JsonResult; | ||
import cn.chenyunlong.common.model.PageRequestWrapper; | ||
import cn.chenyunlong.common.model.PageResult; | ||
import cn.chenyunlong.qing.domain.auth.admin.dto.creator.AdminAccountCreator; | ||
import cn.chenyunlong.qing.domain.auth.admin.dto.query.AdminAccountQuery; | ||
import cn.chenyunlong.qing.domain.auth.admin.dto.request.*; | ||
import cn.chenyunlong.qing.domain.auth.admin.dto.response.AdminAccountResponse; | ||
import cn.chenyunlong.qing.domain.auth.admin.dto.updater.AdminAccountUpdater; | ||
import cn.chenyunlong.qing.domain.auth.admin.dto.vo.AdminAccountVO; | ||
import cn.chenyunlong.qing.domain.auth.admin.mapper.AdminAccountMapper; | ||
import cn.chenyunlong.qing.domain.auth.admin.service.IAdminAccountService; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.data.domain.Page; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.stream.Collectors; | ||
|
||
@RestController | ||
@Slf4j | ||
@RequestMapping("api/v1/admin-account") | ||
@RequiredArgsConstructor | ||
public class AdminAccountController { | ||
private final IAdminAccountService adminAccountService; | ||
|
||
/** | ||
* createRequest | ||
*/ | ||
@PostMapping | ||
public JsonResult<Long> createAdminAccount(@RequestBody AdminAccountCreateRequest request) { | ||
AdminAccountCreator creator = AdminAccountMapper.INSTANCE.request2Dto(request); | ||
return JsonResult.success(adminAccountService.createAdminAccount(creator)); | ||
} | ||
|
||
/** | ||
* update request | ||
*/ | ||
@PostMapping("updateAdminAccount") | ||
public JsonResult<String> updateAdminAccount(@RequestBody AdminAccountUpdateRequest request) { | ||
AdminAccountUpdater updater = AdminAccountMapper.INSTANCE.request2Updater(request); | ||
adminAccountService.updateAdminAccount(updater); | ||
return JsonResult.success(CodeEnum.Success.getName()); | ||
} | ||
|
||
/** | ||
* valid | ||
*/ | ||
@PostMapping("valid/{id}") | ||
public JsonResult<String> validAdminAccount(@PathVariable Long id) { | ||
adminAccountService.validAdminAccount(id); | ||
return JsonResult.success(CodeEnum.Success.getName()); | ||
} | ||
|
||
/** | ||
* invalid | ||
*/ | ||
@PostMapping("invalid/{id}") | ||
public JsonResult<String> invalidAdminAccount(@PathVariable Long id) { | ||
adminAccountService.invalidAdminAccount(id); | ||
return JsonResult.success(CodeEnum.Success.getName()); | ||
} | ||
|
||
/** | ||
* 为用户分配角色 | ||
*/ | ||
@PostMapping(value = "assignRolesToUser") | ||
public JsonResult<String> assignRolesToUser(@RequestBody UserRolesRequest request) { | ||
adminAccountService.assignRolesToUser(request.getAccountId(), request.getRoleIds()); | ||
return JsonResult.success(CodeEnum.Success.getName()); | ||
} | ||
|
||
/** | ||
* 为用户分配平台 | ||
*/ | ||
@PostMapping("assignPlatformsToUser") | ||
public JsonResult<String> assignPlatformsToUser(@RequestBody UserAuthPlatformsRequest request) { | ||
adminAccountService.assignPlatformsToUser(request.getPlatformIds(), request.getAccountId()); | ||
return JsonResult.success(CodeEnum.Success.getName()); | ||
} | ||
|
||
/** | ||
* findById | ||
*/ | ||
@GetMapping("findById/{id}") | ||
public JsonResult<AdminAccountResponse> findById(@PathVariable Long id) { | ||
AdminAccountVO vo = adminAccountService.findById(id); | ||
AdminAccountResponse response = AdminAccountMapper.INSTANCE.vo2CustomResponse(vo); | ||
return JsonResult.success(response); | ||
} | ||
|
||
/** | ||
* findByPage request | ||
*/ | ||
@PostMapping("page") | ||
public JsonResult<PageResult<AdminAccountResponse>> page( | ||
@RequestBody PageRequestWrapper<AdminAccountQueryRequest> request) { | ||
PageRequestWrapper<AdminAccountQuery> wrapper = new PageRequestWrapper<>(); | ||
wrapper.setBean(AdminAccountMapper.INSTANCE.request2Query(request.getBean())); | ||
wrapper.setSorts(request.getSorts()); | ||
wrapper.setPageSize(request.getPageSize()); | ||
wrapper.setPage(request.getPage()); | ||
Page<AdminAccountVO> page = adminAccountService.findByPage(wrapper); | ||
return JsonResult.success( | ||
PageResult.of( | ||
page.getContent().stream() | ||
.map(AdminAccountMapper.INSTANCE::vo2CustomResponse) | ||
.collect(Collectors.toList()), | ||
page.getTotalElements(), | ||
page.getSize(), | ||
page.getNumber()) | ||
); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
.../src/main/java/cn/chenyunlong/qing/domain/auth/admin/dto/creator/AdminAccountCreator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package cn.chenyunlong.qing.domain.auth.admin.dto.creator; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
|
||
import java.lang.Long; | ||
import java.lang.String; | ||
|
||
import lombok.Data; | ||
|
||
@Schema | ||
@Data | ||
public class AdminAccountCreator { | ||
@Schema( | ||
title = "phone", | ||
description = "phone" | ||
) | ||
private String phone; | ||
|
||
@Schema( | ||
title = "password", | ||
description = "password" | ||
) | ||
private String password; | ||
|
||
@Schema( | ||
title = "username", | ||
description = "username" | ||
) | ||
private String username; | ||
|
||
@Schema( | ||
title = "uid", | ||
description = "uid" | ||
) | ||
private String uid; | ||
|
||
@Schema( | ||
title = "realName", | ||
description = "realName" | ||
) | ||
private String realName; | ||
|
||
@Schema( | ||
title = "departmentId", | ||
description = "departmentId" | ||
) | ||
private Long departmentId; | ||
|
||
@Schema( | ||
title = "extInfo", | ||
description = "extInfo" | ||
) | ||
private String extInfo; | ||
} |
9 changes: 9 additions & 0 deletions
9
...main/src/main/java/cn/chenyunlong/qing/domain/auth/admin/dto/query/AdminAccountQuery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package cn.chenyunlong.qing.domain.auth.admin.dto.query; | ||
|
||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Schema | ||
@Data | ||
public class AdminAccountQuery { | ||
} |
51 changes: 51 additions & 0 deletions
51
...ain/java/cn/chenyunlong/qing/domain/auth/admin/dto/request/AdminAccountCreateRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package cn.chenyunlong.qing.domain.auth.admin.dto.request; | ||
|
||
import cn.chenyunlong.common.model.Request; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Schema | ||
@Data | ||
public class AdminAccountCreateRequest implements Request { | ||
@Schema( | ||
title = "phone", | ||
description = "phone" | ||
) | ||
private String phone; | ||
|
||
@Schema( | ||
title = "password", | ||
description = "password" | ||
) | ||
private String password; | ||
|
||
@Schema( | ||
title = "username", | ||
description = "username" | ||
) | ||
private String username; | ||
|
||
@Schema( | ||
title = "uid", | ||
description = "uid" | ||
) | ||
private String uid; | ||
|
||
@Schema( | ||
title = "realName", | ||
description = "realName" | ||
) | ||
private String realName; | ||
|
||
@Schema( | ||
title = "departmentId", | ||
description = "departmentId" | ||
) | ||
private Long departmentId; | ||
|
||
@Schema( | ||
title = "extInfo", | ||
description = "extInfo" | ||
) | ||
private String extInfo; | ||
} |
10 changes: 10 additions & 0 deletions
10
...main/java/cn/chenyunlong/qing/domain/auth/admin/dto/request/AdminAccountQueryRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package cn.chenyunlong.qing.domain.auth.admin.dto.request; | ||
|
||
import cn.chenyunlong.common.model.Request; | ||
import io.swagger.v3.oas.annotations.media.Schema; | ||
import lombok.Data; | ||
|
||
@Schema | ||
@Data | ||
public class AdminAccountQueryRequest implements Request { | ||
} |
Oops, something went wrong.