m
This commit is contained in:
@@ -0,0 +1,413 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GeneratedUser_sign_in_calendarController = void 0;
|
||||
const openapi = require("@nestjs/swagger");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const swagger_1 = require("@nestjs/swagger");
|
||||
const api_1 = require("../../app/common/api");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const api_optional_decorator_1 = require("../../app/common/decorator/api_optional.decorator");
|
||||
const class_validator_1 = require("class-validator");
|
||||
const user_id_context_1 = require("../../app/common/context/user_id.context");
|
||||
const order_by_enum_1 = require("../../app/common/enum/order_by.enum");
|
||||
const expression_enum_1 = require("../../app/common/enum/expression.enum");
|
||||
const class_transformer_1 = require("class-transformer");
|
||||
const user_sign_in_calendar_model_1 = require("../../model/user_sign_in_calendar.model");
|
||||
const ExtraExp = {
|
||||
eq: (k, v) => {
|
||||
return (0, typeorm_2.Equal)(v);
|
||||
},
|
||||
neq: (k, v) => {
|
||||
return (0, typeorm_2.Not)(v);
|
||||
},
|
||||
gt: (k, v) => {
|
||||
return (0, typeorm_2.MoreThan)(v);
|
||||
},
|
||||
egt: (k, v) => {
|
||||
return (0, typeorm_2.MoreThanOrEqual)(v);
|
||||
},
|
||||
lt: (k, v) => {
|
||||
return (0, typeorm_2.LessThan)(v);
|
||||
},
|
||||
elt: (k, v) => {
|
||||
return (0, typeorm_2.LessThanOrEqual)(v);
|
||||
},
|
||||
between: (k, v) => {
|
||||
const p = Array.isArray(v) ? v : `${v}`.split(',');
|
||||
if (p.length < 2) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof p[1] == 'undefined') {
|
||||
throw new common_1.BadRequestException({
|
||||
message: k + '字段,between查询参数错误需要用逗号分割',
|
||||
});
|
||||
}
|
||||
return (0, typeorm_2.Between)(p[0], p[1]);
|
||||
},
|
||||
'not between': (k, v) => {
|
||||
const p = Array.isArray(v) ? v : `${v}`.split(',');
|
||||
if (p.length < 2) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof p[1] == 'undefined') {
|
||||
throw new common_1.BadRequestException({
|
||||
message: k + '字段,between查询参数错误需要用逗号分割',
|
||||
});
|
||||
}
|
||||
return (0, typeorm_2.Not)((0, typeorm_2.Between)(p[0], p[1]));
|
||||
},
|
||||
in: (k, v) => {
|
||||
if (!Array.isArray(v)) {
|
||||
v = `${v}`.split(',');
|
||||
}
|
||||
return (0, typeorm_2.In)(v);
|
||||
},
|
||||
'not in': (k, v) => {
|
||||
if (!Array.isArray(v)) {
|
||||
v = `${v}`.split(',');
|
||||
}
|
||||
return (0, typeorm_2.Not)((0, typeorm_2.In)(v));
|
||||
},
|
||||
like: (k, v) => {
|
||||
return (0, typeorm_2.Like)(`%${v}%`);
|
||||
},
|
||||
slike: (k, v) => {
|
||||
return (0, typeorm_2.Like)(`${v}%`);
|
||||
},
|
||||
elike: (k, v) => {
|
||||
return (0, typeorm_2.Like)(`${v}%`);
|
||||
},
|
||||
};
|
||||
class GeneratedUser_sign_in_calendarFindOrderDto {
|
||||
id;
|
||||
createTime;
|
||||
updateTime;
|
||||
deleteTime;
|
||||
signInDate;
|
||||
isMakeUp;
|
||||
}
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: 'ID', enum: order_by_enum_1.OrderBy }),
|
||||
(0, class_validator_1.IsEnum)(order_by_enum_1.OrderBy),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindOrderDto.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: '创建时间', enum: order_by_enum_1.OrderBy }),
|
||||
(0, class_validator_1.IsEnum)(order_by_enum_1.OrderBy),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindOrderDto.prototype, "createTime", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: '更新时间', enum: order_by_enum_1.OrderBy }),
|
||||
(0, class_validator_1.IsEnum)(order_by_enum_1.OrderBy),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindOrderDto.prototype, "updateTime", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: '删除时间', enum: order_by_enum_1.OrderBy }),
|
||||
(0, class_validator_1.IsEnum)(order_by_enum_1.OrderBy),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindOrderDto.prototype, "deleteTime", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: '签到日期', enum: order_by_enum_1.OrderBy }),
|
||||
(0, class_validator_1.IsEnum)(order_by_enum_1.OrderBy),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindOrderDto.prototype, "signInDate", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: '签到类型: 0-正常签到, 1-补签', enum: order_by_enum_1.OrderBy }),
|
||||
(0, class_validator_1.IsEnum)(order_by_enum_1.OrderBy),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindOrderDto.prototype, "isMakeUp", void 0);
|
||||
class GeneratedUser_sign_in_calendarFindRelationDto {
|
||||
user;
|
||||
}
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: '' }),
|
||||
(0, class_validator_1.IsBoolean)(),
|
||||
__metadata("design:type", Boolean)
|
||||
], GeneratedUser_sign_in_calendarFindRelationDto.prototype, "user", void 0);
|
||||
class GeneratedUser_sign_in_calendarFindExpressionDto {
|
||||
id;
|
||||
createTime;
|
||||
updateTime;
|
||||
deleteTime;
|
||||
signInDate;
|
||||
isMakeUp;
|
||||
}
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: 'ID', enum: expression_enum_1.Expression }),
|
||||
(0, class_validator_1.IsEnum)(expression_enum_1.Expression),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindExpressionDto.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: '创建时间', enum: expression_enum_1.Expression }),
|
||||
(0, class_validator_1.IsEnum)(expression_enum_1.Expression),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindExpressionDto.prototype, "createTime", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: '更新时间', enum: expression_enum_1.Expression }),
|
||||
(0, class_validator_1.IsEnum)(expression_enum_1.Expression),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindExpressionDto.prototype, "updateTime", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: '删除时间', enum: expression_enum_1.Expression }),
|
||||
(0, class_validator_1.IsEnum)(expression_enum_1.Expression),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindExpressionDto.prototype, "deleteTime", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: '签到日期', enum: expression_enum_1.Expression }),
|
||||
(0, class_validator_1.IsEnum)(expression_enum_1.Expression),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindExpressionDto.prototype, "signInDate", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({ description: '签到类型: 0-正常签到, 1-补签', enum: expression_enum_1.Expression }),
|
||||
(0, class_validator_1.IsEnum)(expression_enum_1.Expression),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindExpressionDto.prototype, "isMakeUp", void 0);
|
||||
class GeneratedUser_sign_in_calendarFindExtraDto {
|
||||
expression;
|
||||
order;
|
||||
relations;
|
||||
}
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({
|
||||
description: '查询表达式',
|
||||
example: { "id": "gt" },
|
||||
type: GeneratedUser_sign_in_calendarFindExpressionDto
|
||||
}),
|
||||
(0, class_transformer_1.Type)(() => GeneratedUser_sign_in_calendarFindExpressionDto),
|
||||
(0, class_validator_1.ValidateNested)(),
|
||||
__metadata("design:type", GeneratedUser_sign_in_calendarFindExpressionDto)
|
||||
], GeneratedUser_sign_in_calendarFindExtraDto.prototype, "expression", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({
|
||||
description: '指定字段排序',
|
||||
example: { "id": "desc" },
|
||||
type: [GeneratedUser_sign_in_calendarFindOrderDto],
|
||||
}),
|
||||
(0, class_validator_1.IsArray)(),
|
||||
(0, class_transformer_1.Type)(() => GeneratedUser_sign_in_calendarFindOrderDto),
|
||||
(0, class_validator_1.ValidateNested)({ each: true }),
|
||||
__metadata("design:type", Array)
|
||||
], GeneratedUser_sign_in_calendarFindExtraDto.prototype, "order", void 0);
|
||||
__decorate([
|
||||
(0, api_optional_decorator_1.ApiOptional)({
|
||||
description: '查询关联数据',
|
||||
type: GeneratedUser_sign_in_calendarFindRelationDto,
|
||||
}),
|
||||
(0, class_transformer_1.Type)(() => GeneratedUser_sign_in_calendarFindRelationDto),
|
||||
(0, class_validator_1.ValidateNested)(),
|
||||
__metadata("design:type", GeneratedUser_sign_in_calendarFindRelationDto)
|
||||
], GeneratedUser_sign_in_calendarFindExtraDto.prototype, "relations", void 0);
|
||||
class GeneratedUser_sign_in_calendarFindWhereDto {
|
||||
id;
|
||||
createTime;
|
||||
updateTime;
|
||||
deleteTime;
|
||||
signInDate;
|
||||
isMakeUp;
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiPropertyOptional)({ description: 'ID' }),
|
||||
(0, class_validator_1.Allow)(),
|
||||
__metadata("design:type", Number)
|
||||
], GeneratedUser_sign_in_calendarFindWhereDto.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiPropertyOptional)({ description: '创建时间' }),
|
||||
(0, class_validator_1.Allow)(),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindWhereDto.prototype, "createTime", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiPropertyOptional)({ description: '更新时间' }),
|
||||
(0, class_validator_1.Allow)(),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindWhereDto.prototype, "updateTime", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiPropertyOptional)({ description: '删除时间' }),
|
||||
(0, class_validator_1.Allow)(),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindWhereDto.prototype, "deleteTime", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiPropertyOptional)({ description: '签到日期' }),
|
||||
(0, class_validator_1.Allow)(),
|
||||
__metadata("design:type", String)
|
||||
], GeneratedUser_sign_in_calendarFindWhereDto.prototype, "signInDate", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiPropertyOptional)({ description: '签到类型: 0-正常签到, 1-补签' }),
|
||||
(0, class_validator_1.Allow)(),
|
||||
__metadata("design:type", Number)
|
||||
], GeneratedUser_sign_in_calendarFindWhereDto.prototype, "isMakeUp", void 0);
|
||||
class GeneratedUser_sign_in_calendarFindDto {
|
||||
paginated;
|
||||
where;
|
||||
extra;
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiPropertyOptional)({ description: '分页', type: api_1.PaginatedDto }),
|
||||
(0, class_transformer_1.Type)(() => api_1.PaginatedDto),
|
||||
(0, class_validator_1.ValidateNested)(),
|
||||
__metadata("design:type", api_1.PaginatedDto)
|
||||
], GeneratedUser_sign_in_calendarFindDto.prototype, "paginated", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiPropertyOptional)({ description: '查询条件', type: GeneratedUser_sign_in_calendarFindWhereDto }),
|
||||
(0, class_transformer_1.Type)(() => GeneratedUser_sign_in_calendarFindWhereDto),
|
||||
(0, class_validator_1.ValidateNested)(),
|
||||
__metadata("design:type", GeneratedUser_sign_in_calendarFindWhereDto)
|
||||
], GeneratedUser_sign_in_calendarFindDto.prototype, "where", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiPropertyOptional)({ description: '额外', type: GeneratedUser_sign_in_calendarFindExtraDto }),
|
||||
(0, class_transformer_1.Type)(() => GeneratedUser_sign_in_calendarFindExtraDto),
|
||||
(0, class_validator_1.ValidateNested)(),
|
||||
__metadata("design:type", GeneratedUser_sign_in_calendarFindExtraDto)
|
||||
], GeneratedUser_sign_in_calendarFindDto.prototype, "extra", void 0);
|
||||
class GeneratedUser_sign_in_calendarCreateDto extends (0, swagger_1.OmitType)(user_sign_in_calendar_model_1.UserSignInCalendarModel, [
|
||||
'id',
|
||||
'createTime',
|
||||
'updateTime',
|
||||
'deleteTime',
|
||||
'user',
|
||||
'userId',
|
||||
]) {
|
||||
}
|
||||
class GeneratedUser_sign_in_calendarUpdateDto extends (0, swagger_1.PartialType)(GeneratedUser_sign_in_calendarCreateDto) {
|
||||
}
|
||||
class GeneratedUser_sign_in_calendarDetailWhereDto extends (0, swagger_1.PartialType)((0, swagger_1.OmitType)(GeneratedUser_sign_in_calendarFindWhereDto, ['id'])) {
|
||||
}
|
||||
class GeneratedUser_sign_in_calendarDetailDto {
|
||||
where;
|
||||
extra;
|
||||
}
|
||||
__decorate([
|
||||
(0, swagger_1.ApiPropertyOptional)({ description: '查询条件', type: GeneratedUser_sign_in_calendarDetailWhereDto }),
|
||||
(0, class_validator_1.Allow)(),
|
||||
__metadata("design:type", GeneratedUser_sign_in_calendarDetailWhereDto)
|
||||
], GeneratedUser_sign_in_calendarDetailDto.prototype, "where", void 0);
|
||||
__decorate([
|
||||
(0, swagger_1.ApiPropertyOptional)({ description: '额外', type: GeneratedUser_sign_in_calendarFindExtraDto }),
|
||||
(0, class_validator_1.Allow)(),
|
||||
__metadata("design:type", GeneratedUser_sign_in_calendarFindExtraDto)
|
||||
], GeneratedUser_sign_in_calendarDetailDto.prototype, "extra", void 0);
|
||||
const identity = 'userId';
|
||||
const identityExist = true;
|
||||
let GeneratedUser_sign_in_calendarController = class GeneratedUser_sign_in_calendarController {
|
||||
repos;
|
||||
constructor(repos) {
|
||||
this.repos = repos;
|
||||
}
|
||||
async list(dto) {
|
||||
const page = dto.paginated?.page || 1;
|
||||
const size = dto.paginated?.size || 15;
|
||||
const skip = (page - 1) * size;
|
||||
let where;
|
||||
if (dto.extra?.expression && dto.where) {
|
||||
where = Object.fromEntries(Object.entries(dto.where).map(([key, value]) => {
|
||||
const expression = dto.extra?.expression[key];
|
||||
if (typeof value != 'undefined' && value != '' && value != null) {
|
||||
if (expression && ExtraExp[expression]) {
|
||||
value = ExtraExp[expression](key, value);
|
||||
}
|
||||
}
|
||||
if (expression == expression_enum_1.Expression.between &&
|
||||
(!value || (Array.isArray(value) && value.length < 2))) {
|
||||
value = undefined;
|
||||
}
|
||||
return [key, value];
|
||||
}));
|
||||
}
|
||||
else {
|
||||
where = (dto.where || {});
|
||||
}
|
||||
where = Object.fromEntries(Object.entries(where).filter(([_, v]) => {
|
||||
if (typeof v == 'undefined') {
|
||||
return false;
|
||||
}
|
||||
if (typeof v == 'string' && !v) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}));
|
||||
if (identityExist && identity && (0, user_id_context_1.getUserIdContext)()) {
|
||||
where[identity] = (0, user_id_context_1.getUserIdContext)();
|
||||
}
|
||||
const o = dto.extra?.order && dto.extra?.order.length
|
||||
? dto.extra?.order
|
||||
: [{ id: 'desc' }];
|
||||
const order = Object.fromEntries(o.map((it) => Object.keys(it).map((key) => [key, it[key]]))[0]);
|
||||
const list = await this.repos.find({
|
||||
where,
|
||||
order,
|
||||
skip: skip,
|
||||
take: size,
|
||||
relations: typeof dto.extra?.relations == 'object'
|
||||
? Object.keys(dto.extra?.relations).filter((it) => dto.extra?.relations[it])
|
||||
: [],
|
||||
});
|
||||
const count = await this.repos.count({
|
||||
where: where,
|
||||
});
|
||||
return api_1.Api.pagination(list, count);
|
||||
}
|
||||
async detail(id, dto) {
|
||||
const where = {
|
||||
id,
|
||||
...dto.where,
|
||||
};
|
||||
if (identityExist && identity && (0, user_id_context_1.getUserIdContext)()) {
|
||||
where[identity] = (0, user_id_context_1.getUserIdContext)();
|
||||
}
|
||||
const item = await this.repos.findOne({
|
||||
where,
|
||||
relations: typeof dto.extra?.relations == 'object'
|
||||
? Object.keys(dto.extra?.relations).filter((it) => dto.extra?.relations[it])
|
||||
: [],
|
||||
});
|
||||
return api_1.Api.success(item);
|
||||
}
|
||||
};
|
||||
exports.GeneratedUser_sign_in_calendarController = GeneratedUser_sign_in_calendarController;
|
||||
__decorate([
|
||||
(0, common_1.Post)('list'),
|
||||
(0, swagger_1.ApiOperation)({ summary: '用户签到日历列表' }),
|
||||
api_1.Api.ApiPaginatedResponse({
|
||||
model: user_sign_in_calendar_model_1.UserSignInCalendarModel,
|
||||
codeDescription: '200成功',
|
||||
}),
|
||||
openapi.ApiResponse({ status: 201 }),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [GeneratedUser_sign_in_calendarFindDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], GeneratedUser_sign_in_calendarController.prototype, "list", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('detail/:id'),
|
||||
(0, swagger_1.ApiParam)({ name: 'id', description: '用户签到日历ID' }),
|
||||
(0, swagger_1.ApiOperation)({ summary: '用户签到日历详情' }),
|
||||
api_1.Api.ApiResponse({
|
||||
model: user_sign_in_calendar_model_1.UserSignInCalendarModel,
|
||||
codeDescription: '200成功',
|
||||
}),
|
||||
openapi.ApiResponse({ status: 201 }),
|
||||
__param(0, (0, common_1.Param)('id', common_1.ParseIntPipe)),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Number, GeneratedUser_sign_in_calendarDetailDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], GeneratedUser_sign_in_calendarController.prototype, "detail", null);
|
||||
exports.GeneratedUser_sign_in_calendarController = GeneratedUser_sign_in_calendarController = __decorate([
|
||||
(0, common_1.Controller)('generated/user_sign_in_calendar'),
|
||||
(0, swagger_1.ApiTags)('G用户签到日历'),
|
||||
__param(0, (0, typeorm_1.InjectRepository)(user_sign_in_calendar_model_1.UserSignInCalendarModel)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository])
|
||||
], GeneratedUser_sign_in_calendarController);
|
||||
//# sourceMappingURL=generated_user_sign_in_calendar.controller.js.map
|
||||
Reference in New Issue
Block a user