权限管理功能增加
This commit is contained in:
parent
8418ac8d35
commit
7ce6421b66
5
sql/20210519-zhangsai.sql
Normal file
5
sql/20210519-zhangsai.sql
Normal file
@ -0,0 +1,5 @@
|
||||
ALTER TABLE `permission_distribute`
|
||||
ADD COLUMN `creator_id` bigint NULL AFTER `from_user_permission_id`;
|
||||
|
||||
alter table user_permission
|
||||
add create_time datetime default current_timestamp not null;
|
@ -91,7 +91,7 @@ public class PermissionDistributeController {
|
||||
@ApiOperation(value = "回收权限分发到用户权限中")
|
||||
@PutMapping(path = "/{id}/restore")
|
||||
public void restore(@PathVariable Long id) {
|
||||
this.permissionDistributeService.restoreDistributeToUserPermission(id);
|
||||
this.permissionDistributeService.return2UserPermission(id);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询权限分发包详情")
|
||||
@ -108,4 +108,11 @@ public class PermissionDistributeController {
|
||||
return permissionDistributeService.createAllMapDistribute(project, num, user);
|
||||
}
|
||||
|
||||
@Role(RoleEnum.SuperAdmin)
|
||||
@ApiOperation("收回从该权限分发获取的用户权限")
|
||||
@PutMapping("/{id}/back")
|
||||
public void takeBack(@PathVariable Long id) {
|
||||
permissionDistributeService.takeBack(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -107,4 +107,11 @@ public class UserController {
|
||||
public List<UserVO> querySellers(){
|
||||
return iSysUserService.querySellers();
|
||||
}
|
||||
|
||||
@Role({RoleEnum.Admin, RoleEnum.SuperAdmin})
|
||||
@ApiOperation("查询管理和超管")
|
||||
@GetMapping("/adminAndSuperAdmin")
|
||||
public List<UserVO> queryAdminsAndSuperAdmins() {
|
||||
return iSysUserService.queryAdminsAndSuperAdmins();
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,18 @@
|
||||
package club.joylink.rtss.controller.user;
|
||||
|
||||
import club.joylink.rtss.constants.RoleEnum;
|
||||
import club.joylink.rtss.controller.advice.Role;
|
||||
import club.joylink.rtss.services.IUserPermissionService;
|
||||
import club.joylink.rtss.vo.UserVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.permission.DistributeSelectVO;
|
||||
import club.joylink.rtss.vo.client.permission.PermissionQueryVO;
|
||||
import club.joylink.rtss.vo.client.permission.UserPermissionQueryVO;
|
||||
import club.joylink.rtss.vo.client.userPermission.UserPermissionVO;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
@ -58,19 +62,12 @@ public class UserPermissionController {
|
||||
return iUserPermissionService.userPermissionStatistic(queryVO);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "用户权限转增归属")
|
||||
@GetMapping(path = "/gotUserList")
|
||||
public PageVO<UserPermissionVO> distributeTo(PermissionQueryVO queryVO) {
|
||||
return iUserPermissionService.distributeTo(queryVO);
|
||||
}
|
||||
// @ApiOperation(value = "用户权限转增归属")
|
||||
// @GetMapping(path = "/gotUserList")
|
||||
// public PageVO<UserPermissionVO> distributeTo(PermissionQueryVO queryVO) {
|
||||
// return iUserPermissionService.distributeTo(queryVO);
|
||||
// }
|
||||
|
||||
@ApiOperation(value = "回收用户权限到权限分发中")
|
||||
@PutMapping(path = "/{id}/back")
|
||||
public void restorePermissionToDistribute(@PathVariable Long id) {
|
||||
iUserPermissionService.restorePermissionToDistribute(id);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "")
|
||||
@GetMapping(path = "/personal")
|
||||
public List<UserPermissionVO> queryPersonalUserPermission(@RequestAttribute @ApiIgnore UserVO user) {
|
||||
return iUserPermissionService.queryPersonalUserPermission(user);
|
||||
@ -82,4 +79,32 @@ public class UserPermissionController {
|
||||
iUserPermissionService.getPermissions4Map(mapId, count, user);
|
||||
}
|
||||
|
||||
@Role({RoleEnum.Admin, RoleEnum.SuperAdmin})
|
||||
@ApiOperation(value = "将用户权限退回到权限分发中")
|
||||
@PutMapping(path = "/{id}/back")
|
||||
public void return2Distribute(@PathVariable Long id) {
|
||||
iUserPermissionService.return2Distribute(id);
|
||||
}
|
||||
|
||||
@Role({RoleEnum.Admin, RoleEnum.SuperAdmin})
|
||||
@ApiOperation("将用户权限(专用)退回到用户权限中")
|
||||
@PutMapping("/{id}/back/up")
|
||||
public void return2UserPermission(@PathVariable Long id) {
|
||||
iUserPermissionService.return2UserPermission(id);
|
||||
}
|
||||
|
||||
@Role({RoleEnum.Admin, RoleEnum.SuperAdmin})
|
||||
@ApiOperation("查询从该用户权限流向的用户权限")
|
||||
@GetMapping("/ups/fromThisUP")
|
||||
public PageVO<UserPermissionVO> queryUPsFromThisUP(@Validated UserPermissionQueryVO queryVO) {
|
||||
return iUserPermissionService.queryUPsFromThisUP(queryVO);
|
||||
}
|
||||
|
||||
@Role({RoleEnum.Admin, RoleEnum.SuperAdmin})
|
||||
@ApiOperation("收回从该用户权限流出的所有权限(权限分发及用户权限)")
|
||||
@PutMapping("/{id}/takeBack/all")
|
||||
public void takeBackAll(@PathVariable long id) {
|
||||
iUserPermissionService.takeBack(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,7 +33,8 @@ public interface UserPermissionDAO extends MyBatisBaseDao<UserPermission, Long,
|
||||
"up.end_time AS endTime, " +
|
||||
"up.distribute_id AS distributeId, " +
|
||||
"up.can_distribute AS canDistribute, " +
|
||||
"up.owner_id AS ownerId " +
|
||||
"up.owner_id AS ownerId," +
|
||||
"up.create_time AS createTime " +
|
||||
"FROM " +
|
||||
"user_permission up " +
|
||||
"JOIN sys_user u ON up.user_id = u.id " +
|
||||
@ -76,4 +77,4 @@ public interface UserPermissionDAO extends MyBatisBaseDao<UserPermission, Long,
|
||||
"WHERE " +
|
||||
"distribute_id = #{distributeId}")
|
||||
void updateInvalidByDistributeId(Long distributeId);
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* permission_distribute
|
||||
* @author
|
||||
* 权限分发
|
||||
*/
|
||||
public class PermissionDistribute implements Serializable {
|
||||
private Long id;
|
||||
@ -90,6 +90,8 @@ public class PermissionDistribute implements Serializable {
|
||||
*/
|
||||
private Long fromUserPermissionId;
|
||||
|
||||
private Long creatorId;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ -233,6 +235,14 @@ public class PermissionDistribute implements Serializable {
|
||||
this.fromUserPermissionId = fromUserPermissionId;
|
||||
}
|
||||
|
||||
public Long getCreatorId() {
|
||||
return creatorId;
|
||||
}
|
||||
|
||||
public void setCreatorId(Long creatorId) {
|
||||
this.creatorId = creatorId;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
@ -270,6 +280,7 @@ public class PermissionDistribute implements Serializable {
|
||||
&& (this.getSource() == null ? other.getSource() == null : this.getSource().equals(other.getSource()))
|
||||
&& (this.getOnlyGetOne() == null ? other.getOnlyGetOne() == null : this.getOnlyGetOne().equals(other.getOnlyGetOne()))
|
||||
&& (this.getFromUserPermissionId() == null ? other.getFromUserPermissionId() == null : this.getFromUserPermissionId().equals(other.getFromUserPermissionId()))
|
||||
&& (this.getCreatorId() == null ? other.getCreatorId() == null : this.getCreatorId().equals(other.getCreatorId()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
|
||||
}
|
||||
|
||||
@ -294,6 +305,7 @@ public class PermissionDistribute implements Serializable {
|
||||
result = prime * result + ((getSource() == null) ? 0 : getSource().hashCode());
|
||||
result = prime * result + ((getOnlyGetOne() == null) ? 0 : getOnlyGetOne().hashCode());
|
||||
result = prime * result + ((getFromUserPermissionId() == null) ? 0 : getFromUserPermissionId().hashCode());
|
||||
result = prime * result + ((getCreatorId() == null) ? 0 : getCreatorId().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
@ -321,9 +333,10 @@ public class PermissionDistribute implements Serializable {
|
||||
sb.append(", source=").append(source);
|
||||
sb.append(", onlyGetOne=").append(onlyGetOne);
|
||||
sb.append(", fromUserPermissionId=").append(fromUserPermissionId);
|
||||
sb.append(", creatorId=").append(creatorId);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1175,6 +1175,66 @@ public class PermissionDistributeExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdIsNull() {
|
||||
addCriterion("creator_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdIsNotNull() {
|
||||
addCriterion("creator_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdEqualTo(Long value) {
|
||||
addCriterion("creator_id =", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdNotEqualTo(Long value) {
|
||||
addCriterion("creator_id <>", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdGreaterThan(Long value) {
|
||||
addCriterion("creator_id >", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("creator_id >=", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdLessThan(Long value) {
|
||||
addCriterion("creator_id <", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdLessThanOrEqualTo(Long value) {
|
||||
addCriterion("creator_id <=", value, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdIn(List<Long> values) {
|
||||
addCriterion("creator_id in", values, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdNotIn(List<Long> values) {
|
||||
addCriterion("creator_id not in", values, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdBetween(Long value1, Long value2) {
|
||||
addCriterion("creator_id between", value1, value2, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreatorIdNotBetween(Long value1, Long value2) {
|
||||
addCriterion("creator_id not between", value1, value2, "creatorId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
@ -1330,4 +1390,4 @@ public class PermissionDistributeExample {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* user_permission
|
||||
* @author
|
||||
* 用户拥有权限
|
||||
*/
|
||||
public class UserPermission implements Serializable {
|
||||
private Long id;
|
||||
@ -62,6 +62,8 @@ public class UserPermission implements Serializable {
|
||||
*/
|
||||
private Long ownerId;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Long getId() {
|
||||
@ -160,6 +162,14 @@ public class UserPermission implements Serializable {
|
||||
this.ownerId = ownerId;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
@ -183,7 +193,8 @@ public class UserPermission implements Serializable {
|
||||
&& (this.getEndTime() == null ? other.getEndTime() == null : this.getEndTime().equals(other.getEndTime()))
|
||||
&& (this.getDistributeId() == null ? other.getDistributeId() == null : this.getDistributeId().equals(other.getDistributeId()))
|
||||
&& (this.getCanDistribute() == null ? other.getCanDistribute() == null : this.getCanDistribute().equals(other.getCanDistribute()))
|
||||
&& (this.getOwnerId() == null ? other.getOwnerId() == null : this.getOwnerId().equals(other.getOwnerId()));
|
||||
&& (this.getOwnerId() == null ? other.getOwnerId() == null : this.getOwnerId().equals(other.getOwnerId()))
|
||||
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -202,6 +213,7 @@ public class UserPermission implements Serializable {
|
||||
result = prime * result + ((getDistributeId() == null) ? 0 : getDistributeId().hashCode());
|
||||
result = prime * result + ((getCanDistribute() == null) ? 0 : getCanDistribute().hashCode());
|
||||
result = prime * result + ((getOwnerId() == null) ? 0 : getOwnerId().hashCode());
|
||||
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -215,16 +227,17 @@ public class UserPermission implements Serializable {
|
||||
sb.append(", permissionId=").append(permissionId);
|
||||
sb.append(", userId=").append(userId);
|
||||
sb.append(", status=").append(status);
|
||||
sb.append(", goodsAmount=").append(amount);
|
||||
sb.append(", amount=").append(amount);
|
||||
sb.append(", remains=").append(remains);
|
||||
sb.append(", forever=").append(forever);
|
||||
sb.append(", startTime=").append(startTime);
|
||||
sb.append(", endTime=").append(endTime);
|
||||
sb.append(", distributeId=").append(distributeId);
|
||||
sb.append(", distribute=").append(canDistribute);
|
||||
sb.append(", canDistribute=").append(canDistribute);
|
||||
sb.append(", ownerId=").append(ownerId);
|
||||
sb.append(", createTime=").append(createTime);
|
||||
sb.append(", serialVersionUID=").append(serialVersionUID);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -376,62 +376,62 @@ public class UserPermissionExample {
|
||||
}
|
||||
|
||||
public Criteria andAmountIsNull() {
|
||||
addCriterion("goodsAmount is null");
|
||||
addCriterion("amount is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAmountIsNotNull() {
|
||||
addCriterion("goodsAmount is not null");
|
||||
addCriterion("amount is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAmountEqualTo(Integer value) {
|
||||
addCriterion("goodsAmount =", value, "goodsAmount");
|
||||
addCriterion("amount =", value, "amount");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAmountNotEqualTo(Integer value) {
|
||||
addCriterion("goodsAmount <>", value, "goodsAmount");
|
||||
addCriterion("amount <>", value, "amount");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAmountGreaterThan(Integer value) {
|
||||
addCriterion("goodsAmount >", value, "goodsAmount");
|
||||
addCriterion("amount >", value, "amount");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAmountGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("goodsAmount >=", value, "goodsAmount");
|
||||
addCriterion("amount >=", value, "amount");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAmountLessThan(Integer value) {
|
||||
addCriterion("goodsAmount <", value, "goodsAmount");
|
||||
addCriterion("amount <", value, "amount");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAmountLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("goodsAmount <=", value, "goodsAmount");
|
||||
addCriterion("amount <=", value, "amount");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAmountIn(List<Integer> values) {
|
||||
addCriterion("goodsAmount in", values, "goodsAmount");
|
||||
addCriterion("amount in", values, "amount");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAmountNotIn(List<Integer> values) {
|
||||
addCriterion("goodsAmount not in", values, "goodsAmount");
|
||||
addCriterion("amount not in", values, "amount");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAmountBetween(Integer value1, Integer value2) {
|
||||
addCriterion("goodsAmount between", value1, value2, "goodsAmount");
|
||||
addCriterion("amount between", value1, value2, "amount");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andAmountNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("goodsAmount not between", value1, value2, "goodsAmount");
|
||||
addCriterion("amount not between", value1, value2, "amount");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
@ -746,52 +746,52 @@ public class UserPermissionExample {
|
||||
}
|
||||
|
||||
public Criteria andCanDistributeEqualTo(Boolean value) {
|
||||
addCriterion("can_distribute =", value, "distribute");
|
||||
addCriterion("can_distribute =", value, "canDistribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCanDistributeNotEqualTo(Boolean value) {
|
||||
addCriterion("can_distribute <>", value, "distribute");
|
||||
addCriterion("can_distribute <>", value, "canDistribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCanDistributeGreaterThan(Boolean value) {
|
||||
addCriterion("can_distribute >", value, "distribute");
|
||||
addCriterion("can_distribute >", value, "canDistribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCanDistributeGreaterThanOrEqualTo(Boolean value) {
|
||||
addCriterion("can_distribute >=", value, "distribute");
|
||||
addCriterion("can_distribute >=", value, "canDistribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCanDistributeLessThan(Boolean value) {
|
||||
addCriterion("can_distribute <", value, "distribute");
|
||||
addCriterion("can_distribute <", value, "canDistribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCanDistributeLessThanOrEqualTo(Boolean value) {
|
||||
addCriterion("can_distribute <=", value, "distribute");
|
||||
addCriterion("can_distribute <=", value, "canDistribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCanDistributeIn(List<Boolean> values) {
|
||||
addCriterion("can_distribute in", values, "distribute");
|
||||
addCriterion("can_distribute in", values, "canDistribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCanDistributeNotIn(List<Boolean> values) {
|
||||
addCriterion("can_distribute not in", values, "distribute");
|
||||
addCriterion("can_distribute not in", values, "canDistribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCanDistributeBetween(Boolean value1, Boolean value2) {
|
||||
addCriterion("can_distribute between", value1, value2, "distribute");
|
||||
addCriterion("can_distribute between", value1, value2, "canDistribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCanDistributeNotBetween(Boolean value1, Boolean value2) {
|
||||
addCriterion("can_distribute not between", value1, value2, "distribute");
|
||||
addCriterion("can_distribute not between", value1, value2, "canDistribute");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
@ -854,6 +854,66 @@ public class UserPermissionExample {
|
||||
addCriterion("owner_id not between", value1, value2, "ownerId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNull() {
|
||||
addCriterion("create_time is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIsNotNull() {
|
||||
addCriterion("create_time is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeEqualTo(LocalDateTime value) {
|
||||
addCriterion("create_time =", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotEqualTo(LocalDateTime value) {
|
||||
addCriterion("create_time <>", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThan(LocalDateTime value) {
|
||||
addCriterion("create_time >", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeGreaterThanOrEqualTo(LocalDateTime value) {
|
||||
addCriterion("create_time >=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThan(LocalDateTime value) {
|
||||
addCriterion("create_time <", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeLessThanOrEqualTo(LocalDateTime value) {
|
||||
addCriterion("create_time <=", value, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeIn(List<LocalDateTime> values) {
|
||||
addCriterion("create_time in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotIn(List<LocalDateTime> values) {
|
||||
addCriterion("create_time not in", values, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeBetween(LocalDateTime value1, LocalDateTime value2) {
|
||||
addCriterion("create_time between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andCreateTimeNotBetween(LocalDateTime value1, LocalDateTime value2) {
|
||||
addCriterion("create_time not between", value1, value2, "createTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -950,4 +1010,4 @@ public class UserPermissionExample {
|
||||
this(condition, value, secondValue, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package club.joylink.rtss.services;
|
||||
|
||||
import club.joylink.rtss.constants.Project;
|
||||
import club.joylink.rtss.constants.StatusEnum;
|
||||
import club.joylink.rtss.entity.PermissionDistribute;
|
||||
import club.joylink.rtss.vo.UserVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.order.OrderCreateVO;
|
||||
@ -59,7 +61,10 @@ public interface IPermissionDistributeService {
|
||||
|
||||
String distributeFromUserPermission(UserPermissionDistributeVO distributeVO, UserVO user);
|
||||
|
||||
void restoreDistributeToUserPermission(Long id);
|
||||
/**
|
||||
* 将权限分发中的权限回收到用户权限
|
||||
*/
|
||||
void return2UserPermission(Long id);
|
||||
|
||||
List<DistributeVO> queryPersonalDistributeList(UserVO user);
|
||||
|
||||
@ -78,7 +83,7 @@ public interface IPermissionDistributeService {
|
||||
|
||||
DistributeVO getById(Long id);
|
||||
|
||||
void recoveryAfterRestoreUserPermission(Long id, Integer amount);
|
||||
void recoveryAfterTakeBackUserPermission(Long id, Integer amount);
|
||||
|
||||
DistributeVO getByOrderCode(String orderCode);
|
||||
|
||||
@ -88,15 +93,21 @@ public interface IPermissionDistributeService {
|
||||
|
||||
PageVO<DistributeVO> queryPackageDetail(Long id, PermissionDistributeQueryVO queryVO);
|
||||
|
||||
/**
|
||||
* 生成赠送的权限分发
|
||||
* @param configVO
|
||||
* @return
|
||||
*/
|
||||
DistributeVO generateGiftDistribute(PermissionGenerateConfigVO configVO);
|
||||
|
||||
/**
|
||||
* 创建项目下所有地图的权限分发
|
||||
*/
|
||||
String createAllMapDistribute(Project project, Integer num, UserVO user);
|
||||
|
||||
/**
|
||||
* 扣除一些权限
|
||||
*/
|
||||
void deductSomePermission(long id, int amount);
|
||||
|
||||
void takeBack(long id);
|
||||
|
||||
List<PermissionDistribute> findEntitiesByUPIds(List<Long> upIds, StatusEnum status);
|
||||
|
||||
PermissionDistribute getEntity(long id);
|
||||
|
||||
List<PermissionDistribute> findEntitiesByUPId(long upId, StatusEnum status);
|
||||
}
|
||||
|
@ -64,4 +64,6 @@ public interface IPermissionService {
|
||||
List<Permission> getJointAndTeachEntities(List<Long> mapIds);
|
||||
|
||||
Permission findJointSimulationEntity(Long mapId);
|
||||
|
||||
Permission findEntity(long id);
|
||||
}
|
||||
|
@ -312,4 +312,9 @@ public interface ISysUserService {
|
||||
void register(UserInfoVO userInfoVO);
|
||||
|
||||
List<UserVO> queryUsers(List<Long> userIds);
|
||||
|
||||
/**
|
||||
* 查询管理和超管
|
||||
*/
|
||||
List<UserVO> queryAdminsAndSuperAdmins();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import club.joylink.rtss.vo.UserVO;
|
||||
import club.joylink.rtss.vo.client.PageVO;
|
||||
import club.joylink.rtss.vo.client.permission.DistributeSelectVO;
|
||||
import club.joylink.rtss.vo.client.permission.PermissionQueryVO;
|
||||
import club.joylink.rtss.vo.client.permission.UserPermissionQueryVO;
|
||||
import club.joylink.rtss.vo.client.userPermission.UserPermissionVO;
|
||||
import club.joylink.rtss.vo.user.PermissionGenerateConfigVO;
|
||||
|
||||
@ -52,9 +53,12 @@ public interface IUserPermissionService {
|
||||
|
||||
void updateById(UserPermissionVO upVO);
|
||||
|
||||
void restorePermissionToDistribute(Long userPermissionId);
|
||||
/**
|
||||
* 将用户权限退回权限分发
|
||||
*/
|
||||
void return2Distribute(Long userPermissionId);
|
||||
|
||||
List<UserPermissionVO> findByDistributeIdAndStatus(Long distributeId, StatusEnum status);
|
||||
List<UserPermissionVO> findEntitiesByDistributeId(Long distributeId, StatusEnum status);
|
||||
|
||||
/**
|
||||
* 恢复用户权限的数量
|
||||
@ -71,13 +75,6 @@ public interface IUserPermissionService {
|
||||
*/
|
||||
List<UserPermissionVO> queryPersonalUserPermission(UserVO user);
|
||||
|
||||
/**
|
||||
* 生成用户权限
|
||||
* @param userVO
|
||||
* @param permissionConfigVOList
|
||||
*/
|
||||
void generateUserPermissions(UserVO userVO, List<PermissionGenerateConfigVO> permissionConfigVOList);
|
||||
|
||||
/**
|
||||
* 查询有效的用户教学权限
|
||||
*/
|
||||
@ -94,4 +91,21 @@ public interface IUserPermissionService {
|
||||
* @param monthAmount 要延长的月数
|
||||
*/
|
||||
void renewal(long id, int monthAmount);
|
||||
|
||||
/**
|
||||
* 回收用户权限(专用)到用户权限中
|
||||
*/
|
||||
void return2UserPermission(Long id);
|
||||
|
||||
/**
|
||||
* 使从该权限分发获取的用户权限失效
|
||||
*/
|
||||
void disableUPsFromDistribute(long distributeId);
|
||||
|
||||
PageVO<UserPermissionVO> queryUPsFromThisUP(UserPermissionQueryVO queryVO);
|
||||
|
||||
/**
|
||||
* 将从该用户权限流出的所有权限收回
|
||||
*/
|
||||
void takeBack(long id);
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import club.joylink.rtss.vo.client.userPermission.UserPermissionAndAmountVO;
|
||||
import club.joylink.rtss.vo.client.userPermission.UserPermissionDistributeVO;
|
||||
import club.joylink.rtss.vo.client.userPermission.UserPermissionVO;
|
||||
import club.joylink.rtss.vo.client.validGroup.ValidList;
|
||||
import club.joylink.rtss.vo.user.PermissionGenerateConfigVO;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -36,7 +35,6 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -104,6 +102,15 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
List<Long> permissionIds = voList.stream().map(PermissionVO::getId).collect(Collectors.toList());
|
||||
criteria.andPermissionIdIn(permissionIds);
|
||||
}
|
||||
if (queryVO.getOrganizationId() != null) {
|
||||
criteria.andOrganizationIdEqualTo(queryVO.getOrganizationId());
|
||||
}
|
||||
if (queryVO.getCreatorId() != null) {
|
||||
criteria.andCreatorIdEqualTo(queryVO.getCreatorId());
|
||||
}
|
||||
if (queryVO.getFromUserPermissionId() != null) {
|
||||
criteria.andFromUserPermissionIdEqualTo(queryVO.getFromUserPermissionId());
|
||||
}
|
||||
|
||||
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||
Page<PermissionDistribute> page = (Page<PermissionDistribute>) permissionDistributeDAO.selectByExample(example);
|
||||
@ -158,7 +165,7 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
*/
|
||||
@Override
|
||||
public void immediateInvalid(Long id) {
|
||||
PermissionDistribute permissionDistribute = getEntityById(id);
|
||||
PermissionDistribute permissionDistribute = getEntity(id);
|
||||
permissionDistribute.setStatus(StatusEnum.Invalid.getCode());
|
||||
permissionDistributeDAO.updateByPrimaryKeySelective(permissionDistribute);
|
||||
}
|
||||
@ -196,9 +203,10 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
order.setDetailVOList(iOrderService.findOrderDetailVOListByOrderId(order.getId()));
|
||||
|
||||
//如果订单有多个商品,创建权限分发包
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (order.getDetailVOList().size() > 1) {
|
||||
//添加权限分发包
|
||||
PermissionDistribute distribute = buildPermissionDistributeFromOrder(order);
|
||||
PermissionDistribute distribute = buildPermissionDistributeFromOrder(order, now);
|
||||
int amount = order.getDetailVOList().stream().mapToInt(OrderDetailVO::getGoodsAmount).sum();
|
||||
distribute.setAmount(amount);
|
||||
distribute.setRemains(amount);
|
||||
@ -214,11 +222,12 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
distribute.setPermissionId(iGoodsService.getById(orderDetailVO.getGoodsId()).getPermissionId());
|
||||
distribute.setAmount(orderDetailVO.getGoodsAmount());
|
||||
distribute.setRemains(distribute.getAmount());
|
||||
distribute.setCreateTime(now);
|
||||
permissionDistributeDAO.insertSelective(distribute);
|
||||
}
|
||||
|
||||
} else { //如果只有一个商品,创建权限分发
|
||||
PermissionDistribute distribute = buildPermissionDistributeFromOrder(order);
|
||||
PermissionDistribute distribute = buildPermissionDistributeFromOrder(order, now);
|
||||
OrderDetailVO orderDetailVO = order.getDetailVOList().get(0);
|
||||
distribute.setPermissionId(iGoodsService.getById(orderDetailVO.getGoodsId()).getPermissionId());
|
||||
distribute.setAmount(orderDetailVO.getGoodsAmount());
|
||||
@ -239,13 +248,13 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
* 领取权限。
|
||||
* 如果权限分发不存在,报DBException(数据不存在)
|
||||
*
|
||||
* @param id 权限分发id
|
||||
* @param user 要获取权限的用户
|
||||
* @param id 权限分发id
|
||||
* @param user 要获取权限的用户
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void getUserPermission(Long id, UserVO user) {
|
||||
PermissionDistribute distribute = getEntityById(id);
|
||||
PermissionDistribute distribute = getEntity(id);
|
||||
canReceiveValid(distribute, user);
|
||||
if (distribute.getIsPackage()) {
|
||||
List<PermissionDistribute> permissionDistributeList = getEntityByParentId(distribute.getId());
|
||||
@ -336,6 +345,7 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
userPermissionAndAmountVOList.removeAll(removeList);
|
||||
|
||||
Long distributeId;
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
if (userPermissionAndAmountVOList.size() == 1) {
|
||||
distribute.setIsPackage(false);
|
||||
UserPermissionAndAmountVO upaaVO = userPermissionAndAmountVOList.get(0);
|
||||
@ -343,6 +353,7 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
distribute.setAmount(upaaVO.getAmount());
|
||||
distribute.setRemains(upaaVO.getAmount());
|
||||
distribute.setFromUserPermissionId(upaaVO.getUserPermissionId());
|
||||
distribute.setCreateTime(now);
|
||||
permissionDistributeDAO.insertSelective(distribute);
|
||||
UserPermission userPermission = new UserPermission();
|
||||
userPermission.setId(upaaVO.getUserPermissionId());
|
||||
@ -353,6 +364,7 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
distribute.setIsPackage(true);
|
||||
distribute.setAmount(userPermissionAndAmountVOList.stream().mapToInt(UserPermissionAndAmountVO::getAmount).sum());
|
||||
distribute.setRemains(distribute.getAmount());
|
||||
distribute.setCreateTime(now);
|
||||
permissionDistributeDAO.insertSelective(distribute);
|
||||
distributeId = distribute.getId();
|
||||
for (UserPermissionAndAmountVO upaaVO : userPermissionAndAmountVOList) {
|
||||
@ -363,6 +375,7 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
distribute.setFromUserPermissionId(upaaVO.getUserPermissionId());
|
||||
distribute.setAmount(upaaVO.getAmount());
|
||||
distribute.setRemains(upaaVO.getAmount());
|
||||
distribute.setCreateTime(now);
|
||||
permissionDistributeDAO.insertSelective(distribute);
|
||||
UserPermission userPermission = new UserPermission();
|
||||
userPermission.setId(upaaVO.getUserPermissionId());
|
||||
@ -373,21 +386,14 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
return generateQrCode(distributeId);
|
||||
}
|
||||
|
||||
private PermissionDistribute getEntityById(Long id) {
|
||||
PermissionDistribute distribute = permissionDistributeDAO.selectByPrimaryKey(id);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(distribute,
|
||||
String.format("id为[%s]的权限分发不存在", id));
|
||||
return distribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将权限分发中的所有权限全部回收到用户权限
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public void restoreDistributeToUserPermission(Long id) {
|
||||
public void return2UserPermission(Long id) {
|
||||
//校验
|
||||
PermissionDistribute distribute = getEntityById(id);
|
||||
PermissionDistribute distribute = getEntity(id);
|
||||
BusinessExceptionAssertEnum.DATA_INVALID.assertNotEquals(StatusEnum.Invalid.getCode(), distribute.getStatus(),
|
||||
"该权限分发已失效");
|
||||
BusinessExceptionAssertEnum.DATA_STATE_INCORRECT.assertEquals(PermissionDistributeSourceEnum.FromUser.getCode(),
|
||||
@ -415,7 +421,7 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
@Override
|
||||
public void systemRevokePermissionDistribute(Long id) {
|
||||
//校验
|
||||
PermissionDistribute distribute = getEntityById(id);
|
||||
PermissionDistribute distribute = getEntity(id);
|
||||
if (StatusEnum.Invalid.getCode().equals(distribute.getStatus())) {
|
||||
return;
|
||||
}
|
||||
@ -474,9 +480,10 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
* 从订单构建一个权限分发,这个权限分发对权限分发包与基础权限分发的公共属性进行了赋值
|
||||
*
|
||||
* @param orderVO
|
||||
* @param now
|
||||
* @return
|
||||
*/
|
||||
private PermissionDistribute buildPermissionDistributeFromOrder(OrderVO orderVO) {
|
||||
private PermissionDistribute buildPermissionDistributeFromOrder(OrderVO orderVO, LocalDateTime now) {
|
||||
//参数校验
|
||||
Objects.requireNonNull(orderVO, "order不能为null");
|
||||
if (CollectionUtils.isEmpty(orderVO.getDetailVOList())) {
|
||||
@ -496,6 +503,8 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
distribute.setStatus(StatusEnum.Valid.getCode());
|
||||
distribute.setCanDistribute(true);
|
||||
distribute.setSource(PermissionDistributeSourceEnum.FromOrder.getCode());
|
||||
distribute.setCreatorId(orderVO.getCreatorId());
|
||||
distribute.setCreateTime(now);
|
||||
return distribute;
|
||||
}
|
||||
|
||||
@ -607,16 +616,9 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
return voList;
|
||||
}
|
||||
|
||||
public List<DistributeVO> getByFromUserPermissionId(Long userPermissionId) {
|
||||
List<DistributeVO> voList = findByFromUserPermissionId(userPermissionId);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(voList,
|
||||
String.format("没有从id为[%s]的用户权限创建的权限分发", userPermissionId));
|
||||
return voList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserPermissionVO> queryDistributeGetUsers(Long id, UserVO user) {
|
||||
List<UserPermissionVO> voList = iUserPermissionService.findByDistributeIdAndStatus(id, StatusEnum.Valid);
|
||||
List<UserPermissionVO> voList = iUserPermissionService.findEntitiesByDistributeId(id, StatusEnum.Valid);
|
||||
for (UserPermissionVO vo : voList) {
|
||||
UserVO uservo = iSysUserService.getUserById(vo.getUserId());
|
||||
vo.setUserName(uservo.getName());
|
||||
@ -630,37 +632,12 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||
Page<PermissionDistribute> page = (Page<PermissionDistribute>) getEntityByParentId(id);
|
||||
List<DistributeVO> voList = page.getResult().stream().map(distribute -> {
|
||||
DistributeVO vo = new DistributeVO(distribute);
|
||||
if (vo.getOrganizationId() != null) {
|
||||
vo.setOrganizationName(iOrganizationService.getById(distribute.getOrganizationId()).getName());
|
||||
}
|
||||
return vo;
|
||||
Permission permission = iPermissionService.findEntity(distribute.getPermissionId());
|
||||
return new DistributeVO(distribute, permission);
|
||||
}).collect(Collectors.toList());
|
||||
return PageVO.convert(page, voList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributeVO generateGiftDistribute(PermissionGenerateConfigVO configVO) {
|
||||
PermissionVO permission = this.iPermissionService.getById(configVO.getPermissionId());
|
||||
log.info(String.format("即将生成权限[%s:%s]的赠送的权限分发数据", permission.getId(), permission.getName()));
|
||||
PermissionDistribute distribute = new PermissionDistribute();
|
||||
distribute.setSource(PermissionDistributeSourceEnum.Gift.getCode());
|
||||
distribute.setPermissionId(configVO.getPermissionId());
|
||||
distribute.setAmount(configVO.getQuantity());
|
||||
distribute.setRemains(configVO.getQuantity());
|
||||
distribute.setForever(false);
|
||||
LocalDateTime startTime = LocalDate.now().atStartOfDay();
|
||||
distribute.setStartTime(startTime);
|
||||
LocalDateTime endTime = startTime.plusMonths(configVO.getMonthNumber());
|
||||
distribute.setEndTime(endTime);
|
||||
distribute.setStatus(StatusEnum.Valid.getCode());
|
||||
distribute.setIsPackage(false);
|
||||
distribute.setCanDistribute(true);
|
||||
distribute.setCreateTime(LocalDateTime.now());
|
||||
this.permissionDistributeDAO.insert(distribute);
|
||||
return new DistributeVO(distribute);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String createAllMapDistribute(Project project, Integer num, UserVO user) {
|
||||
iSysUserService.confirmAdmin(user);
|
||||
@ -684,17 +661,77 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recoveryAfterRestoreUserPermission(Long id, Integer amount) {
|
||||
PermissionDistribute distribute = getEntityById(id);
|
||||
public void deductSomePermission(long id, int amount) {
|
||||
PermissionDistribute pd = this.getEntity(id);
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(
|
||||
pd.getOnlyGetOne() != null && pd.getOnlyGetOne(), "非专用权限权限分发,无法使用此操作");
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(pd.getFromUserPermissionId(), "权限分发不是从用户权限创建的,无法收回权限");
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(pd.getIsPackage(), "权限分发包收回权限逻辑未实现");
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(pd.getAmount() >= amount, String.format("权限分发中剩余权限数量不足%s", amount));
|
||||
pd.setRemains(pd.getRemains() - amount);
|
||||
pd.setAmount(pd.getAmount() - amount);
|
||||
permissionDistributeDAO.updateByPrimaryKey(pd);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void takeBack(long id) {
|
||||
PermissionDistribute entity = this.getEntity(id);
|
||||
BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertEquals(entity.getStatus(), StatusEnum.Valid.getCode(), "无效的权限分发");
|
||||
iUserPermissionService.disableUPsFromDistribute(id); //使所有从该权限分发出去的用户权限失效
|
||||
entity.setRemains(entity.getAmount());
|
||||
permissionDistributeDAO.updateByPrimaryKey(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionDistribute> findEntitiesByUPIds(List<Long> upIds, StatusEnum status) {
|
||||
if (CollectionUtils.isEmpty(upIds))
|
||||
return new ArrayList<>();
|
||||
PermissionDistributeExample example = new PermissionDistributeExample();
|
||||
PermissionDistributeExample.Criteria criteria = example.createCriteria().andFromUserPermissionIdIn(upIds);
|
||||
if (status != null) {
|
||||
criteria.andStatusEqualTo(status.getCode());
|
||||
}
|
||||
return permissionDistributeDAO.selectByExample(example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionDistribute getEntity(long id) {
|
||||
PermissionDistribute distribute = permissionDistributeDAO.selectByPrimaryKey(id);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(distribute,
|
||||
String.format("id为[%s]的权限分发不存在", id));
|
||||
return distribute;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PermissionDistribute> findEntitiesByUPId(long upId, StatusEnum status) {
|
||||
PermissionDistributeExample example = new PermissionDistributeExample();
|
||||
PermissionDistributeExample.Criteria criteria = example.createCriteria().andFromUserPermissionIdEqualTo(upId);
|
||||
if (status != null)
|
||||
criteria.andStatusEqualTo(status.getCode());
|
||||
return permissionDistributeDAO.selectByExample(example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recoveryAfterTakeBackUserPermission(Long id, Integer amount) {
|
||||
PermissionDistribute distribute = getEntity(id);
|
||||
distribute.setRemains(distribute.getRemains() + amount);
|
||||
permissionDistributeDAO.updateByPrimaryKeySelective(distribute);
|
||||
if (distribute.getParentId() != 0) {
|
||||
PermissionDistribute parentDistribute = getEntityById(distribute.getParentId());
|
||||
PermissionDistribute parentDistribute = getEntity(distribute.getParentId());
|
||||
parentDistribute.setRemains(parentDistribute.getRemains() + amount);
|
||||
permissionDistributeDAO.updateByPrimaryKeySelective(parentDistribute);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributeVO getByOrderCode(String orderCode) {
|
||||
PermissionDistribute distribute = findByOrderCode(orderCode);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(distribute,
|
||||
String.format("订单编号为[%s]的权限分发不存在", orderCode));
|
||||
return new DistributeVO(distribute);
|
||||
}
|
||||
|
||||
private PermissionDistribute findByOrderCode(String orderCode) {
|
||||
PermissionDistributeExample example = new PermissionDistributeExample();
|
||||
example.createCriteria().andOrderCodeEqualTo(orderCode);
|
||||
@ -705,11 +742,10 @@ public class PermissionDistributeService implements IPermissionDistributeService
|
||||
return distributeList.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DistributeVO getByOrderCode(String orderCode) {
|
||||
PermissionDistribute distribute = findByOrderCode(orderCode);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(distribute,
|
||||
String.format("订单编号为[%s]的权限分发不存在", orderCode));
|
||||
return new DistributeVO(distribute);
|
||||
public List<DistributeVO> getByFromUserPermissionId(Long userPermissionId) {
|
||||
List<DistributeVO> voList = findByFromUserPermissionId(userPermissionId);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(voList,
|
||||
String.format("没有从id为[%s]的用户权限创建的权限分发", userPermissionId));
|
||||
return voList;
|
||||
}
|
||||
}
|
||||
|
@ -215,12 +215,13 @@ public class PermissionService implements IPermissionService {
|
||||
permissionDAO.updateByPrimaryKey(permission);
|
||||
}
|
||||
|
||||
private Permission findEntityById(Long id) {
|
||||
@Override
|
||||
public Permission findEntity(long id) {
|
||||
return permissionDAO.selectByPrimaryKey(id);
|
||||
}
|
||||
|
||||
private Permission getEntityById(Long id) {
|
||||
Permission permission = findEntityById(id);
|
||||
Permission permission = findEntity(id);
|
||||
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(permission, String.format("id为[%s]的权限不存在", id));
|
||||
return permission;
|
||||
}
|
||||
@ -589,5 +590,4 @@ public class PermissionService implements IPermissionService {
|
||||
return permissions.get(0);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -839,6 +839,16 @@ public class SysUserService implements ISysUserService {
|
||||
return UserVO.convert2BaseInfoVO(users);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserVO> queryAdminsAndSuperAdmins() {
|
||||
SysUserExample example = new SysUserExample();
|
||||
example.setOrderByClause("id");
|
||||
example.createCriteria().andRolesLike(String.format("%%%s%%", BusinessConsts.ROLE_04));
|
||||
example.or().andRolesLike(String.format("%%%s%%", BusinessConsts.ROLE_05));
|
||||
List<SysUser> users = sysUserDAO.selectByExample(example);
|
||||
return UserVO.convert2BaseInfoVO(users);
|
||||
}
|
||||
|
||||
private boolean isSameEmailExist(String email) {
|
||||
SysUserExample example = new SysUserExample();
|
||||
example.createCriteria()
|
||||
|
@ -6,6 +6,7 @@ import club.joylink.rtss.dao.SysUserDAO;
|
||||
import club.joylink.rtss.dao.UserPermissionDAO;
|
||||
import club.joylink.rtss.dao.UserPermissionProcessingDAO;
|
||||
import club.joylink.rtss.entity.PermissionDistribute;
|
||||
import club.joylink.rtss.entity.SysUser;
|
||||
import club.joylink.rtss.entity.UserPermission;
|
||||
import club.joylink.rtss.entity.UserPermissionExample;
|
||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||
@ -17,9 +18,9 @@ import club.joylink.rtss.vo.client.order.OrderDetailCreateVO;
|
||||
import club.joylink.rtss.vo.client.permission.DistributeSelectVO;
|
||||
import club.joylink.rtss.vo.client.permission.PermissionQueryVO;
|
||||
import club.joylink.rtss.vo.client.permission.PermissionVO;
|
||||
import club.joylink.rtss.vo.client.permission.UserPermissionQueryVO;
|
||||
import club.joylink.rtss.vo.client.permissionDistribute.DistributeVO;
|
||||
import club.joylink.rtss.vo.client.userPermission.UserPermissionVO;
|
||||
import club.joylink.rtss.vo.user.PermissionGenerateConfigVO;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -29,6 +30,7 @@ import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@ -87,12 +89,11 @@ public class UserPermissionService implements IUserPermissionService {
|
||||
|
||||
/**
|
||||
* 将用户权限设为失效。
|
||||
* 如果用户权限不存在,报DBException(数据不存在)
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
@Transactional
|
||||
@Override
|
||||
public void setInvalid(Long id) {
|
||||
takeBack(id); //回收所有权限
|
||||
UserPermission userPermission = getEntityById(id);
|
||||
userPermission.setStatus(UserPermissionStatusEnum.Invalid.getCode());
|
||||
userPermissionDAO.updateByPrimaryKeySelective(userPermission);
|
||||
@ -362,13 +363,14 @@ public class UserPermissionService implements IUserPermissionService {
|
||||
userPermission.setAmount(1);
|
||||
userPermission.setRemains(1);
|
||||
}
|
||||
userPermission.setCreateTime(LocalDateTime.now());
|
||||
userPermissionDAO.insertSelective(userPermission);
|
||||
}
|
||||
|
||||
public void updateById(UserPermissionVO upVO) {
|
||||
Objects.requireNonNull(upVO, "UserPermissionVO不能为null");
|
||||
Objects.requireNonNull(upVO.getId(), "UserPermissionVO的id不能为null");
|
||||
UserPermission userPermission = upVO.conver2DB();
|
||||
UserPermission userPermission = upVO.convert2DB();
|
||||
userPermissionDAO.updateByPrimaryKeySelective(userPermission);
|
||||
}
|
||||
|
||||
@ -404,17 +406,21 @@ public class UserPermissionService implements IUserPermissionService {
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void restorePermissionToDistribute(Long userPermissionId) {
|
||||
UserPermissionVO upVO = getById(userPermissionId);
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(StatusEnum.Valid.getCode().equals(upVO.getStatus()));
|
||||
upVO.setStatus(StatusEnum.Invalid.getCode());
|
||||
updateById(upVO);
|
||||
iPermissionDistributeService.recoveryAfterRestoreUserPermission(upVO.getDistributeId(), upVO.getAmount());
|
||||
public void return2Distribute(Long userPermissionId) {
|
||||
UserPermission entity = getEntityById(userPermissionId);
|
||||
return2Distribute(entity);
|
||||
}
|
||||
|
||||
private void return2Distribute(UserPermission up) {
|
||||
BusinessExceptionAssertEnum.INVALID_OPERATION.assertTrue(StatusEnum.Valid.getCode().equals(up.getStatus()));
|
||||
up.setStatus(StatusEnum.Invalid.getCode());
|
||||
userPermissionDAO.updateByPrimaryKey(up);
|
||||
iPermissionDistributeService.recoveryAfterTakeBackUserPermission(up.getDistributeId(), up.getAmount());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserPermissionVO> findByDistributeIdAndStatus(Long distributeId, StatusEnum status) {
|
||||
DistributeVO distribute = iPermissionDistributeService.getById(distributeId);
|
||||
public List<UserPermissionVO> findEntitiesByDistributeId(Long distributeId, StatusEnum status) {
|
||||
PermissionDistribute distribute = iPermissionDistributeService.getEntity(distributeId);
|
||||
List<Long> disIdList;
|
||||
if (distribute.getIsPackage()) {
|
||||
List<DistributeVO> distributeList = iPermissionDistributeService.getByParentId(distributeId);
|
||||
@ -453,15 +459,6 @@ public class UserPermissionService implements IUserPermissionService {
|
||||
return voList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void generateUserPermissions(UserVO userVO, List<PermissionGenerateConfigVO> permissionConfigVOList) {
|
||||
for (PermissionGenerateConfigVO configVO : permissionConfigVOList) {
|
||||
DistributeVO distributeVO = this.iPermissionDistributeService.generateGiftDistribute(configVO);
|
||||
this.iPermissionDistributeService.getUserPermission(distributeVO.getId(), userVO);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<UserPermission> findEntity(List<Long> userIds, Boolean valid) {
|
||||
StatusEnum status = null;
|
||||
@ -510,6 +507,76 @@ public class UserPermissionService implements IUserPermissionService {
|
||||
userPermissionDAO.updateByPrimaryKey(entity);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void return2UserPermission(Long id) {
|
||||
UserPermission entity = getEntityById(id);
|
||||
return2Distribute(entity); //回收用户权限到权限分发中
|
||||
iPermissionDistributeService.deductSomePermission(entity.getDistributeId(), 1);
|
||||
PermissionDistribute distribute = iPermissionDistributeService.getEntity(entity.getDistributeId());
|
||||
UserPermission parentUP = getEntityById(distribute.getFromUserPermissionId());
|
||||
parentUP.setRemains(parentUP.getRemains() + 1);
|
||||
userPermissionDAO.updateByPrimaryKey(parentUP);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableUPsFromDistribute(long distributeId) {
|
||||
List<UserPermission> entities = findEntitiesByDistributeId(distributeId);
|
||||
if (CollectionUtils.isEmpty(entities))
|
||||
return;
|
||||
userPermissionDAO.updateInvalidByDistributeId(distributeId);
|
||||
List<Long> upIds = entities.stream().map(UserPermission::getId).collect(Collectors.toList());
|
||||
iPermissionDistributeService.findEntitiesByUPIds(upIds, StatusEnum.Valid)
|
||||
.forEach(distribute -> userPermissionDAO.updateInvalidByDistributeId(distribute.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageVO<UserPermissionVO> queryUPsFromThisUP(UserPermissionQueryVO queryVO) {
|
||||
UserPermission entity = getEntityById(queryVO.getId());
|
||||
List<PermissionDistribute> distributes = iPermissionDistributeService.findEntitiesByUPId(entity.getId(), StatusEnum.Valid);
|
||||
Page<Object> page = PageHelper.startPage(queryVO.getPageNum(), queryVO.getPageSize());
|
||||
if (CollectionUtils.isEmpty(distributes))
|
||||
PageVO.convert(page, new ArrayList<>());
|
||||
List<Long> distributeIds = distributes.stream().map(PermissionDistribute::getId).collect(Collectors.toList());
|
||||
List<UserPermission> ups = findEntitiesByDistributeIds(distributeIds, StatusEnum.Valid);
|
||||
if (CollectionUtils.isEmpty(ups))
|
||||
PageVO.convert(page, new ArrayList<>());
|
||||
List<Long> userIds = ups.stream().map(UserPermission::getUserId).distinct().collect(Collectors.toList());
|
||||
Map<Long, SysUser> userMap = iSysUserService.findEntities(userIds, null).stream()
|
||||
.collect(Collectors.toMap(SysUser::getId, Function.identity()));
|
||||
List<UserPermissionVO> vos = ups.stream()
|
||||
.map(up -> {
|
||||
SysUser sysUser = userMap.get(up.getUserId());
|
||||
return new UserPermissionVO(up, sysUser);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return PageVO.convert(page, vos);
|
||||
}
|
||||
|
||||
@Transactional
|
||||
@Override
|
||||
public void takeBack(long id) {
|
||||
UserPermission entity = getEntityById(id);
|
||||
List<PermissionDistribute> distributes = iPermissionDistributeService.findEntitiesByUPId(entity.getId(), StatusEnum.Valid);
|
||||
if (CollectionUtils.isEmpty(distributes))
|
||||
return;
|
||||
distributes.stream()
|
||||
.map(PermissionDistribute::getId)
|
||||
.distinct()
|
||||
.forEach(distributeId -> {
|
||||
iPermissionDistributeService.takeBack(distributeId);
|
||||
iPermissionDistributeService.return2UserPermission(distributeId);
|
||||
});
|
||||
}
|
||||
|
||||
private List<UserPermission> findEntitiesByDistributeIds(List<Long> distributeIds, StatusEnum status) {
|
||||
UserPermissionExample example = new UserPermissionExample();
|
||||
UserPermissionExample.Criteria criteria = example.createCriteria().andDistributeIdIn(distributeIds);
|
||||
if (status != null)
|
||||
criteria.andStatusEqualTo(status.getCode());
|
||||
return userPermissionDAO.selectByExample(example);
|
||||
}
|
||||
|
||||
private List<UserPermissionVO> findByUserId(Long userId) {
|
||||
UserPermissionExample example = new UserPermissionExample();
|
||||
example.createCriteria().andUserIdEqualTo(userId);
|
||||
@ -517,4 +584,10 @@ public class UserPermissionService implements IUserPermissionService {
|
||||
return upList.stream().map(UserPermissionVO::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<UserPermission> findEntitiesByDistributeId(long distributeId) {
|
||||
UserPermissionExample example = new UserPermissionExample();
|
||||
example.createCriteria().andDistributeIdEqualTo(distributeId);
|
||||
return userPermissionDAO.selectByExample(example);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package club.joylink.rtss.vo.client.permission;
|
||||
|
||||
import club.joylink.rtss.constants.StatusEnum;
|
||||
import club.joylink.rtss.vo.client.PageQueryVO;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public class UserPermissionQueryVO extends PageQueryVO {
|
||||
@NotNull(message = "id不能为null")
|
||||
private Long id;
|
||||
|
||||
private StatusEnum status;
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.rtss.vo.client.permissionDistribute;
|
||||
|
||||
import club.joylink.rtss.entity.Permission;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import club.joylink.rtss.constants.PermissionDistributeSourceEnum;
|
||||
@ -93,11 +94,10 @@ public class DistributeVO {
|
||||
*/
|
||||
private Boolean canRestore;
|
||||
|
||||
public static List<DistributeVO> convert2VOList(List<PermissionDistribute> list) {
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
return list.stream().map(DistributeVO::new).collect(Collectors.toList());
|
||||
}
|
||||
return null;
|
||||
public DistributeVO(PermissionDistribute distribute, Permission permission) {
|
||||
this(distribute);
|
||||
this.permissionName = permission.getName();
|
||||
this.permissionType = permission.getType();
|
||||
}
|
||||
|
||||
public DistributeVO(PermissionDistribute pd) {
|
||||
@ -126,4 +126,11 @@ public class DistributeVO {
|
||||
this.canRestore = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<DistributeVO> convert2VOList(List<PermissionDistribute> list) {
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
return list.stream().map(DistributeVO::new).collect(Collectors.toList());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,6 @@ import lombok.Setter;
|
||||
@Setter
|
||||
public class PermissionDistributeQueryVO extends PageQueryVO {
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@ApiModelProperty(value="用户名")
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@ -72,4 +66,13 @@ public class PermissionDistributeQueryVO extends PageQueryVO {
|
||||
|
||||
@ApiModelProperty(value = "权限id")
|
||||
private Long permissionId;
|
||||
|
||||
/** 组织/企业id */
|
||||
private Long organizationId;
|
||||
|
||||
/** 创建人id */
|
||||
private Long creatorId;
|
||||
|
||||
/** 创建自该用户权限 */
|
||||
private Long fromUserPermissionId;
|
||||
}
|
||||
|
@ -127,6 +127,10 @@ public class PermissionDistributeVO {
|
||||
*/
|
||||
private Boolean onlyGetOne;
|
||||
|
||||
private Long creatorId;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
public PermissionDistributeVO(PermissionDistribute distribute) {
|
||||
this.id = distribute.getId();
|
||||
this.permissionId = distribute.getPermissionId();
|
||||
@ -142,11 +146,8 @@ public class PermissionDistributeVO {
|
||||
this.source = distribute.getSource();
|
||||
this.onlyGetOne = distribute.getOnlyGetOne();
|
||||
this.isPackage=distribute.getIsPackage();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
public boolean isOnlyGetOne() {
|
||||
return !this.getCanDistribute() && Objects.nonNull(this.onlyGetOne) && this.onlyGetOne;
|
||||
this.creatorId = distribute.getCreatorId();
|
||||
this.createTime = distribute.getCreateTime();
|
||||
}
|
||||
|
||||
public static List<PermissionDistributeVO> convert2VOList(List<PermissionDistribute> list) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package club.joylink.rtss.vo.client.userPermission;
|
||||
|
||||
import club.joylink.rtss.entity.SysUser;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
@ -73,6 +74,8 @@ public class UserPermissionVO {
|
||||
|
||||
private String ownerName;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
public UserPermissionVO(UserPermission userPermission) {
|
||||
id = userPermission.getId();
|
||||
permissionId = userPermission.getPermissionId();
|
||||
@ -86,9 +89,18 @@ public class UserPermissionVO {
|
||||
status = userPermission.getStatus();
|
||||
distributeId = userPermission.getDistributeId();
|
||||
ownerId = userPermission.getOwnerId();
|
||||
this.createTime = userPermission.getCreateTime();
|
||||
}
|
||||
|
||||
public UserPermission conver2DB() {
|
||||
public UserPermissionVO(UserPermission up, SysUser sysUser) {
|
||||
this(up);
|
||||
if (sysUser != null) {
|
||||
this.userName = sysUser.getName();
|
||||
this.userNickname = sysUser.getNickname();
|
||||
}
|
||||
}
|
||||
|
||||
public UserPermission convert2DB() {
|
||||
UserPermission userPermission = new UserPermission();
|
||||
userPermission.setId(this.id);
|
||||
userPermission.setPermissionId(this.permissionId);
|
||||
@ -102,6 +114,7 @@ public class UserPermissionVO {
|
||||
userPermission.setDistributeId(this.distributeId);
|
||||
userPermission.setCanDistribute(this.canDistribute);
|
||||
userPermission.setOwnerId(this.ownerId);
|
||||
userPermission.setCreateTime(this.createTime);
|
||||
return userPermission;
|
||||
}
|
||||
|
||||
|
@ -9,16 +9,17 @@
|
||||
<result column="user_id" jdbcType="BIGINT" property="userId" />
|
||||
<result column="amount" jdbcType="INTEGER" property="amount" />
|
||||
<result column="remains" jdbcType="INTEGER" property="remains" />
|
||||
<result column="forever" jdbcType="BIT" property="forever" />
|
||||
<result column="forever" jdbcType="TINYINT" property="forever" />
|
||||
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
|
||||
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
|
||||
<result column="status" jdbcType="VARCHAR" property="status" />
|
||||
<result column="can_distribute" jdbcType="BIT" property="canDistribute" />
|
||||
<result column="is_package" jdbcType="BIT" property="isPackage" />
|
||||
<result column="can_distribute" jdbcType="TINYINT" property="canDistribute" />
|
||||
<result column="is_package" jdbcType="TINYINT" property="isPackage" />
|
||||
<result column="parent_id" jdbcType="BIGINT" property="parentId" />
|
||||
<result column="source" jdbcType="VARCHAR" property="source" />
|
||||
<result column="only_get_one" jdbcType="BIT" property="onlyGetOne" />
|
||||
<result column="only_get_one" jdbcType="TINYINT" property="onlyGetOne" />
|
||||
<result column="from_user_permission_id" jdbcType="BIGINT" property="fromUserPermissionId" />
|
||||
<result column="creator_id" jdbcType="BIGINT" property="creatorId" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
@ -80,9 +81,9 @@
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, permission_id, order_code, organization_id, user_id, amount, remains, forever,
|
||||
start_time, end_time, `status`, can_distribute, is_package, parent_id, `source`,
|
||||
only_get_one, from_user_permission_id, create_time
|
||||
id, permission_id, order_code, organization_id, user_id, amount, remains, forever,
|
||||
start_time, end_time, `status`, can_distribute, is_package, parent_id, `source`,
|
||||
only_get_one, from_user_permission_id, creator_id, create_time
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="club.joylink.rtss.entity.PermissionDistributeExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@ -107,7 +108,7 @@
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
select
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from permission_distribute
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
@ -123,18 +124,20 @@
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.PermissionDistribute" useGeneratedKeys="true">
|
||||
insert into permission_distribute (permission_id, order_code, organization_id,
|
||||
user_id, amount, remains,
|
||||
forever, start_time, end_time,
|
||||
`status`, can_distribute, is_package,
|
||||
parent_id, `source`, only_get_one,
|
||||
from_user_permission_id, create_time)
|
||||
values (#{permissionId,jdbcType=BIGINT}, #{orderCode,jdbcType=VARCHAR}, #{organizationId,jdbcType=BIGINT},
|
||||
#{userId,jdbcType=BIGINT}, #{amount,jdbcType=INTEGER}, #{remains,jdbcType=INTEGER},
|
||||
#{forever,jdbcType=BIT}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP},
|
||||
#{status,jdbcType=VARCHAR}, #{canDistribute,jdbcType=BIT}, #{isPackage,jdbcType=BIT},
|
||||
#{parentId,jdbcType=BIGINT}, #{source,jdbcType=VARCHAR}, #{onlyGetOne,jdbcType=BIT},
|
||||
#{fromUserPermissionId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP})
|
||||
insert into permission_distribute (permission_id, order_code, organization_id,
|
||||
user_id, amount, remains,
|
||||
forever, start_time, end_time,
|
||||
`status`, can_distribute, is_package,
|
||||
parent_id, `source`, only_get_one,
|
||||
from_user_permission_id, creator_id, create_time
|
||||
)
|
||||
values (#{permissionId,jdbcType=BIGINT}, #{orderCode,jdbcType=VARCHAR}, #{organizationId,jdbcType=BIGINT},
|
||||
#{userId,jdbcType=BIGINT}, #{amount,jdbcType=INTEGER}, #{remains,jdbcType=INTEGER},
|
||||
#{forever,jdbcType=TINYINT}, #{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP},
|
||||
#{status,jdbcType=VARCHAR}, #{canDistribute,jdbcType=TINYINT}, #{isPackage,jdbcType=TINYINT},
|
||||
#{parentId,jdbcType=BIGINT}, #{source,jdbcType=VARCHAR}, #{onlyGetOne,jdbcType=TINYINT},
|
||||
#{fromUserPermissionId,jdbcType=BIGINT}, #{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.PermissionDistribute" useGeneratedKeys="true">
|
||||
insert into permission_distribute
|
||||
@ -187,6 +190,9 @@
|
||||
<if test="fromUserPermissionId != null">
|
||||
from_user_permission_id,
|
||||
</if>
|
||||
<if test="creatorId != null">
|
||||
creator_id,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
@ -211,7 +217,7 @@
|
||||
#{remains,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="forever != null">
|
||||
#{forever,jdbcType=BIT},
|
||||
#{forever,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
#{startTime,jdbcType=TIMESTAMP},
|
||||
@ -223,10 +229,10 @@
|
||||
#{status,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="canDistribute != null">
|
||||
#{canDistribute,jdbcType=BIT},
|
||||
#{canDistribute,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="isPackage != null">
|
||||
#{isPackage,jdbcType=BIT},
|
||||
#{isPackage,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
#{parentId,jdbcType=BIGINT},
|
||||
@ -235,11 +241,14 @@
|
||||
#{source,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="onlyGetOne != null">
|
||||
#{onlyGetOne,jdbcType=BIT},
|
||||
#{onlyGetOne,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="fromUserPermissionId != null">
|
||||
#{fromUserPermissionId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="creatorId != null">
|
||||
#{creatorId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
@ -276,7 +285,7 @@
|
||||
remains = #{record.remains,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.forever != null">
|
||||
forever = #{record.forever,jdbcType=BIT},
|
||||
forever = #{record.forever,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="record.startTime != null">
|
||||
start_time = #{record.startTime,jdbcType=TIMESTAMP},
|
||||
@ -288,10 +297,10 @@
|
||||
`status` = #{record.status,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.canDistribute != null">
|
||||
can_distribute = #{record.canDistribute,jdbcType=BIT},
|
||||
can_distribute = #{record.canDistribute,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="record.isPackage != null">
|
||||
is_package = #{record.isPackage,jdbcType=BIT},
|
||||
is_package = #{record.isPackage,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="record.parentId != null">
|
||||
parent_id = #{record.parentId,jdbcType=BIGINT},
|
||||
@ -300,11 +309,14 @@
|
||||
`source` = #{record.source,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.onlyGetOne != null">
|
||||
only_get_one = #{record.onlyGetOne,jdbcType=BIT},
|
||||
only_get_one = #{record.onlyGetOne,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="record.fromUserPermissionId != null">
|
||||
from_user_permission_id = #{record.fromUserPermissionId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.creatorId != null">
|
||||
creator_id = #{record.creatorId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
@ -322,16 +334,17 @@
|
||||
user_id = #{record.userId,jdbcType=BIGINT},
|
||||
amount = #{record.amount,jdbcType=INTEGER},
|
||||
remains = #{record.remains,jdbcType=INTEGER},
|
||||
forever = #{record.forever,jdbcType=BIT},
|
||||
forever = #{record.forever,jdbcType=TINYINT},
|
||||
start_time = #{record.startTime,jdbcType=TIMESTAMP},
|
||||
end_time = #{record.endTime,jdbcType=TIMESTAMP},
|
||||
`status` = #{record.status,jdbcType=VARCHAR},
|
||||
can_distribute = #{record.canDistribute,jdbcType=BIT},
|
||||
is_package = #{record.isPackage,jdbcType=BIT},
|
||||
can_distribute = #{record.canDistribute,jdbcType=TINYINT},
|
||||
is_package = #{record.isPackage,jdbcType=TINYINT},
|
||||
parent_id = #{record.parentId,jdbcType=BIGINT},
|
||||
`source` = #{record.source,jdbcType=VARCHAR},
|
||||
only_get_one = #{record.onlyGetOne,jdbcType=BIT},
|
||||
only_get_one = #{record.onlyGetOne,jdbcType=TINYINT},
|
||||
from_user_permission_id = #{record.fromUserPermissionId,jdbcType=BIGINT},
|
||||
creator_id = #{record.creatorId,jdbcType=BIGINT},
|
||||
create_time = #{record.createTime,jdbcType=TIMESTAMP}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
@ -359,7 +372,7 @@
|
||||
remains = #{remains,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="forever != null">
|
||||
forever = #{forever,jdbcType=BIT},
|
||||
forever = #{forever,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
start_time = #{startTime,jdbcType=TIMESTAMP},
|
||||
@ -371,10 +384,10 @@
|
||||
`status` = #{status,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="canDistribute != null">
|
||||
can_distribute = #{canDistribute,jdbcType=BIT},
|
||||
can_distribute = #{canDistribute,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="isPackage != null">
|
||||
is_package = #{isPackage,jdbcType=BIT},
|
||||
is_package = #{isPackage,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="parentId != null">
|
||||
parent_id = #{parentId,jdbcType=BIGINT},
|
||||
@ -383,11 +396,14 @@
|
||||
`source` = #{source,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="onlyGetOne != null">
|
||||
only_get_one = #{onlyGetOne,jdbcType=BIT},
|
||||
only_get_one = #{onlyGetOne,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="fromUserPermissionId != null">
|
||||
from_user_permission_id = #{fromUserPermissionId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="creatorId != null">
|
||||
creator_id = #{creatorId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
@ -402,17 +418,18 @@
|
||||
user_id = #{userId,jdbcType=BIGINT},
|
||||
amount = #{amount,jdbcType=INTEGER},
|
||||
remains = #{remains,jdbcType=INTEGER},
|
||||
forever = #{forever,jdbcType=BIT},
|
||||
forever = #{forever,jdbcType=TINYINT},
|
||||
start_time = #{startTime,jdbcType=TIMESTAMP},
|
||||
end_time = #{endTime,jdbcType=TIMESTAMP},
|
||||
`status` = #{status,jdbcType=VARCHAR},
|
||||
can_distribute = #{canDistribute,jdbcType=BIT},
|
||||
is_package = #{isPackage,jdbcType=BIT},
|
||||
can_distribute = #{canDistribute,jdbcType=TINYINT},
|
||||
is_package = #{isPackage,jdbcType=TINYINT},
|
||||
parent_id = #{parentId,jdbcType=BIGINT},
|
||||
`source` = #{source,jdbcType=VARCHAR},
|
||||
only_get_one = #{onlyGetOne,jdbcType=BIT},
|
||||
only_get_one = #{onlyGetOne,jdbcType=TINYINT},
|
||||
from_user_permission_id = #{fromUserPermissionId,jdbcType=BIGINT},
|
||||
creator_id = #{creatorId,jdbcType=BIGINT},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
@ -8,12 +8,13 @@
|
||||
<result column="status" jdbcType="VARCHAR" property="status" />
|
||||
<result column="amount" jdbcType="INTEGER" property="amount" />
|
||||
<result column="remains" jdbcType="INTEGER" property="remains" />
|
||||
<result column="forever" jdbcType="BIT" property="forever" />
|
||||
<result column="forever" jdbcType="TINYINT" property="forever" />
|
||||
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
|
||||
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" />
|
||||
<result column="distribute_id" jdbcType="BIGINT" property="distributeId" />
|
||||
<result column="can_distribute" jdbcType="BIT" property="canDistribute" />
|
||||
<result column="can_distribute" jdbcType="TINYINT" property="canDistribute" />
|
||||
<result column="owner_id" jdbcType="BIGINT" property="ownerId" />
|
||||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
|
||||
</resultMap>
|
||||
<sql id="Example_Where_Clause">
|
||||
<where>
|
||||
@ -74,8 +75,8 @@
|
||||
</where>
|
||||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, permission_id, user_id, `status`, amount, remains, forever, start_time, end_time,
|
||||
distribute_id, can_distribute, owner_id
|
||||
id, permission_id, user_id, `status`, amount, remains, forever, start_time, end_time,
|
||||
distribute_id, can_distribute, owner_id, create_time
|
||||
</sql>
|
||||
<select id="selectByExample" parameterType="club.joylink.rtss.entity.UserPermissionExample" resultMap="BaseResultMap">
|
||||
select
|
||||
@ -100,7 +101,7 @@
|
||||
</if>
|
||||
</select>
|
||||
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
|
||||
select
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from user_permission
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
@ -116,14 +117,16 @@
|
||||
</if>
|
||||
</delete>
|
||||
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.UserPermission" useGeneratedKeys="true">
|
||||
insert into user_permission (permission_id, user_id, `status`,
|
||||
amount, remains, forever,
|
||||
start_time, end_time, distribute_id,
|
||||
can_distribute, owner_id)
|
||||
values (#{permissionId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR},
|
||||
#{amount,jdbcType=INTEGER}, #{remains,jdbcType=INTEGER}, #{forever,jdbcType=BIT},
|
||||
#{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{distributeId,jdbcType=BIGINT},
|
||||
#{canDistribute,jdbcType=BIT}, #{ownerId,jdbcType=BIGINT})
|
||||
insert into user_permission (permission_id, user_id, `status`,
|
||||
amount, remains, forever,
|
||||
start_time, end_time, distribute_id,
|
||||
can_distribute, owner_id, create_time
|
||||
)
|
||||
values (#{permissionId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{status,jdbcType=VARCHAR},
|
||||
#{amount,jdbcType=INTEGER}, #{remains,jdbcType=INTEGER}, #{forever,jdbcType=TINYINT},
|
||||
#{startTime,jdbcType=TIMESTAMP}, #{endTime,jdbcType=TIMESTAMP}, #{distributeId,jdbcType=BIGINT},
|
||||
#{canDistribute,jdbcType=TINYINT}, #{ownerId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="club.joylink.rtss.entity.UserPermission" useGeneratedKeys="true">
|
||||
insert into user_permission
|
||||
@ -161,6 +164,9 @@
|
||||
<if test="ownerId != null">
|
||||
owner_id,
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="permissionId != null">
|
||||
@ -179,7 +185,7 @@
|
||||
#{remains,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="forever != null">
|
||||
#{forever,jdbcType=BIT},
|
||||
#{forever,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
#{startTime,jdbcType=TIMESTAMP},
|
||||
@ -191,11 +197,14 @@
|
||||
#{distributeId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="canDistribute != null">
|
||||
#{canDistribute,jdbcType=BIT},
|
||||
#{canDistribute,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="ownerId != null">
|
||||
#{ownerId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
#{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
<select id="countByExample" parameterType="club.joylink.rtss.entity.UserPermissionExample" resultType="java.lang.Long">
|
||||
@ -226,7 +235,7 @@
|
||||
remains = #{record.remains,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.forever != null">
|
||||
forever = #{record.forever,jdbcType=BIT},
|
||||
forever = #{record.forever,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="record.startTime != null">
|
||||
start_time = #{record.startTime,jdbcType=TIMESTAMP},
|
||||
@ -238,11 +247,14 @@
|
||||
distribute_id = #{record.distributeId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.canDistribute != null">
|
||||
can_distribute = #{record.canDistribute,jdbcType=BIT},
|
||||
can_distribute = #{record.canDistribute,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="record.ownerId != null">
|
||||
owner_id = #{record.ownerId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.createTime != null">
|
||||
create_time = #{record.createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</set>
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
@ -256,12 +268,13 @@
|
||||
`status` = #{record.status,jdbcType=VARCHAR},
|
||||
amount = #{record.amount,jdbcType=INTEGER},
|
||||
remains = #{record.remains,jdbcType=INTEGER},
|
||||
forever = #{record.forever,jdbcType=BIT},
|
||||
forever = #{record.forever,jdbcType=TINYINT},
|
||||
start_time = #{record.startTime,jdbcType=TIMESTAMP},
|
||||
end_time = #{record.endTime,jdbcType=TIMESTAMP},
|
||||
distribute_id = #{record.distributeId,jdbcType=BIGINT},
|
||||
can_distribute = #{record.canDistribute,jdbcType=BIT},
|
||||
owner_id = #{record.ownerId,jdbcType=BIGINT}
|
||||
can_distribute = #{record.canDistribute,jdbcType=TINYINT},
|
||||
owner_id = #{record.ownerId,jdbcType=BIGINT},
|
||||
create_time = #{record.createTime,jdbcType=TIMESTAMP}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
@ -285,7 +298,7 @@
|
||||
remains = #{remains,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="forever != null">
|
||||
forever = #{forever,jdbcType=BIT},
|
||||
forever = #{forever,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="startTime != null">
|
||||
start_time = #{startTime,jdbcType=TIMESTAMP},
|
||||
@ -297,11 +310,14 @@
|
||||
distribute_id = #{distributeId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="canDistribute != null">
|
||||
can_distribute = #{canDistribute,jdbcType=BIT},
|
||||
can_distribute = #{canDistribute,jdbcType=TINYINT},
|
||||
</if>
|
||||
<if test="ownerId != null">
|
||||
owner_id = #{ownerId,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="createTime != null">
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
@ -312,12 +328,13 @@
|
||||
`status` = #{status,jdbcType=VARCHAR},
|
||||
amount = #{amount,jdbcType=INTEGER},
|
||||
remains = #{remains,jdbcType=INTEGER},
|
||||
forever = #{forever,jdbcType=BIT},
|
||||
forever = #{forever,jdbcType=TINYINT},
|
||||
start_time = #{startTime,jdbcType=TIMESTAMP},
|
||||
end_time = #{endTime,jdbcType=TIMESTAMP},
|
||||
distribute_id = #{distributeId,jdbcType=BIGINT},
|
||||
can_distribute = #{canDistribute,jdbcType=BIT},
|
||||
owner_id = #{ownerId,jdbcType=BIGINT}
|
||||
can_distribute = #{canDistribute,jdbcType=TINYINT},
|
||||
owner_id = #{ownerId,jdbcType=BIGINT},
|
||||
create_time = #{createTime,jdbcType=TIMESTAMP}
|
||||
where id = #{id,jdbcType=BIGINT}
|
||||
</update>
|
||||
</mapper>
|
||||
</mapper>
|
||||
|
Loading…
Reference in New Issue
Block a user