Ejemplo n.º 1
0
        public async Task <string> Create(CreatePositionInput input)
        {
            input.CheckDataAnnotations().CheckValidResult();
            await _positionDomainService.CreatePosition(input);

            return("新增职位信息成功");
        }
Ejemplo n.º 2
0
        public async Task CreatePosition(CreatePositionInput input, string positionCode, DbConnection conn, DbTransaction trans)
        {
            await CheckPosition(input);

            var position = input.MapTo <Position>();

            position.Code = positionCode;
            await _positionRepository.InsertAsync(position, conn, trans);
        }
Ejemplo n.º 3
0
        private async Task CheckPosition(CreatePositionInput input)
        {
            var workbookAppServiceProxy = GetService <IWordbookAppService>();

            if (!await workbookAppServiceProxy.Check(new CheckWordbookInput()
            {
                WordbookCode = SystemPresetWordbookCode.Organization.PositionFunction, WordbookItemId = input.FunctionId
            }))
            {
                throw new BusinessException($"系统中不存在指定的岗位职能类型");
            }
            if (!await workbookAppServiceProxy.Check(new CheckWordbookInput()
            {
                WordbookCode = SystemPresetWordbookCode.Organization.PositionLevel, WordbookItemId = input.PositionLevelId
            }))
            {
                throw new BusinessException($"系统中不存在指定的岗位级别");
            }
        }
Ejemplo n.º 4
0
        public async Task CreatePosition(CreatePositionInput input)
        {
            await CheckPosition(input);

            var position          = input.MapTo <Position>();
            var departPositionMax = (await _positionRepository.GetAllAsync(p => p.DeptId == input.DeptId)).FirstOrDefault();
            var department        = await _departmentRepository.GetAsync(input.DeptId);

            var orgInfo = await _organizationRepository.GetAsync(department.OrgId);

            var positionCode = string.Empty;

            if (departPositionMax == null)
            {
                positionCode = "1".PadLeft(HeroConstants.CodeRuleRestrain.CodeCoverBit, HeroConstants.CodeRuleRestrain.CodeCoverSymbol);
            }
            else
            {
                positionCode = (Convert.ToInt32(departPositionMax.Code.TrimStart('0')) + 1).ToString().PadLeft(HeroConstants.CodeRuleRestrain.CodeCoverBit, HeroConstants.CodeRuleRestrain.CodeCoverSymbol);
            }

            position.Code = orgInfo.Code + positionCode;
            await _positionRepository.InsertAsync(position);
        }