| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- import { Injectable } from '@angular/core';
- import { Family } from '../models/family';
-
- @Injectable({
- providedIn: 'root',
- })
- export class FamilyService {
- private families: Family[] = [
- {
- id: '1',
- dankaId: '1',
- furigana: 'すずき はなこ',
- name: '鈴木 花子',
- relationship: '母',
- birthDate: '1975-01-01',
- note: '次の世帯主',
- fatherId: '5',
- motherId: '6',
- spouseId: '3',
- },
- {
- id: '2',
- dankaId: '1',
- furigana: 'すずき たろう',
- name: '鈴木 太郎',
- relationship: '長男',
- birthDate: '2005-12-31',
- note: '',
- fatherId: '3',
- motherId: '1',
- spouseId: '7',
- },
- {
- id: '3',
- dankaId: '1',
- furigana: 'すずき いちろう',
- name: '鈴木 一郎',
- relationship: '父',
- birthDate: '1973-05-10',
- note: '',
- fatherId: '',
- motherId: '',
- spouseId: '1',
- },
- {
- id: '4',
- dankaId: '1',
- furigana: 'すずき さくら',
- name: '鈴木 さくら',
- relationship: '長女',
- birthDate: '2008-04-15',
- note: '',
- fatherId: '3',
- motherId: '1',
- spouseId: '',
- },
- {
- id: '5',
- dankaId: '1',
- furigana: 'さとう まさお',
- name: '佐藤 正男',
- relationship: '母方の祖父',
- birthDate: '1948-03-20',
- note: '花子の父',
- fatherId: '',
- motherId: '',
- spouseId: '6',
- },
- {
- id: '6',
- dankaId: '1',
- furigana: 'さとう ひさこ',
- name: '佐藤 久子',
- relationship: '母方の祖母',
- birthDate: '1950-09-08',
- note: '花子の母',
- fatherId: '',
- motherId: '',
- spouseId: '5',
- },
- {
- id: '7',
- dankaId: '1',
- furigana: 'すずき みさき',
- name: '鈴木 美咲',
- relationship: '長男の妻',
- birthDate: '2006-07-22',
- note: '',
- fatherId: '',
- motherId: '',
- spouseId: '2',
- },
- {
- id: '8',
- dankaId: '1',
- furigana: 'すずき れん',
- name: '鈴木 蓮',
- relationship: '孫',
- birthDate: '2026-02-01',
- note: '太郎と美咲の子',
- fatherId: '2',
- motherId: '7',
- spouseId: '',
- },
- ];
-
- //檀家と紐づいている家族情報の取得
- getFamiliesByDankaId(dankaId: string): Family[] {
- return this.families.filter((family) => family.dankaId === dankaId);
- }
-
- //家族の情報を取得
- getFamilyById(id: string): Family | undefined {
- return this.families.find((family) => family.id === id);
- }
-
- //家族の情報を更新
- saveFamily(updateFamily: Family) {
- const index = this.families.findIndex((families) => families.id === updateFamily.id);
- if (index === -1) {
- this.families.push(updateFamily);
- return;
- }
- this.families[index] = updateFamily;
- }
- //家族の情報を削除
- deleteFamily(id: string | undefined) {
- const index = this.families.findIndex((family) => family.id === id);
- if (index === -1) {
- return;
- }
- this.families.splice(index, 1);
- }
-
- //家族情報を全件取得する処理
- getFamilyList(): Family[] {
- return this.families;
- }
- }
|