Skip to content

Commit

Permalink
update role
Browse files Browse the repository at this point in the history
  • Loading branch information
trungnt committed Aug 28, 2021
1 parent 774cd58 commit c443ec6
Show file tree
Hide file tree
Showing 34 changed files with 1,238 additions and 275 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public interface LichTiemChungAction {
public List<LichTiemChung> findAll(int page, int size);

public List<LichTiemChung> findByCoSoYTeId(long id, int page, int size);

public LichTiemChung dongLichTiemChung(long id) throws Exception;

public LichTiemChung updateLichTiemChung(long id, String reqBody) throws Exception;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public interface MuiTiemChungAction {
public MuiTiemChung findById(long id);

public List<MuiTiemChung> findByCmtcccd(String cmtcccd);

public long countByNguoiTiemChungId(long id);

public List<MuiTiemChung> findByNguoiTiemChungId(long id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public interface NguoiDungAction {

public NguoiDung updateNguoiDung(long id, String reqBody) throws Exception;

public NguoiDung updateNguoiDung(long id, boolean quanTriHeThong) throws Exception;
public NguoiDung updateNguoiDung(long id, int vaiTro) throws Exception;

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public List<NguoiTiemChung> searchNguoiTiemChung(String cmtcccd, Integer nhomdoi

public long countNguoiTiemChung(String cmtcccd, Integer nhomdoituong, String ngaydangki, String hovaten,
Long diabancosoid, String cosoytema, Integer tinhtrangdangky, Integer kiemtratrung);

public void duyetDangKyMoi(String reqBody);

public void huyDangKyChinhThuc(String reqBody);

public void khoiPhucDangKy(String reqBody);

public void updateTrangThaiDangKy(String reqBody);
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
public interface PhieuHenTiemAction {

public PhieuHenTiem addPhieuHenTiem(String reqBody) throws Exception;

public long countPhieuHenTiem(long lichTiemChungId, long caTiemChungId, int tinhTrangXacNhan);

public boolean deleteById(long id) throws Exception;

Expand All @@ -26,10 +28,13 @@ public interface PhieuHenTiemAction {
public List<PhieuHenTiem> findByNguoiTiemChungId(long id);

public List<PhieuHenTiem> findAll();

public List<PhieuHenTiem> searchPhieuHenTiem(long lichTiemChungId, long caTiemChungId, int tinhTrangXacNhan,
int page, int size);

public PhieuHenTiem updatePhieuHenTiem(long id, String reqBody) throws Exception;

public void updateTinhTrangXacNhan(String reqBody);

public boolean checkin(String qrcode);
public boolean checkin(String qrcode, String reqBody);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.vaccom.vcmgt.action.CaTiemChungAction;
import org.vaccom.vcmgt.action.LichTiemChungAction;
import org.vaccom.vcmgt.constant.EntityConstant;
import org.vaccom.vcmgt.entity.CaTiemChung;
import org.vaccom.vcmgt.entity.LichTiemChung;
import org.vaccom.vcmgt.exception.ActionException;
import org.vaccom.vcmgt.service.CaTiemChungService;
import org.vaccom.vcmgt.util.MessageUtil;
Expand All @@ -26,6 +28,9 @@ public class CaTiemChungActionImpl implements CaTiemChungAction {
@Autowired
private CaTiemChungService caTiemChungService;

@Autowired
private LichTiemChungAction lichTiemChungAction;

@Override
public CaTiemChung addCaTiemChung(String reqBody) throws Exception {
ObjectMapper mapper = new ObjectMapper();
Expand All @@ -35,6 +40,13 @@ public CaTiemChung addCaTiemChung(String reqBody) throws Exception {
? bodyData.get(EntityConstant.LICHTIEMCHUNG_ID).longValue()
: 0;

LichTiemChung lichTiemChung = lichTiemChungAction.findById(lichTiemChungId);

if (lichTiemChung == null) {
throw new ActionException(MessageUtil.getVNMessageText("catiemchung.lichtiem.not_found"),
HttpStatus.NOT_FOUND.value());
}

int stt = bodyData.has(EntityConstant.STT) ? bodyData.get(EntityConstant.STT).intValue() : 1;

String ngayHenTiem = bodyData.has(EntityConstant.NGAYHENTIEM)
Expand All @@ -59,7 +71,7 @@ public CaTiemChung addCaTiemChung(String reqBody) throws Exception {
caTiemChung.setLichTiemChungId(lichTiemChungId);
caTiemChung.setNgayHenTiem(ngayHenTiem);
caTiemChung.setSoMuiTiem(soMuiTiem);
//caTiemChung.setSoPhieuHen(soPhieuHen);
// caTiemChung.setSoPhieuHen(soPhieuHen);
caTiemChung.setStt(stt);

return caTiemChungService.updateCaTiemChung(caTiemChung);
Expand Down Expand Up @@ -104,12 +116,20 @@ public CaTiemChung updateCaTiemChung(long id, String reqBody) throws Exception {
}

ObjectMapper mapper = new ObjectMapper();

JsonNode bodyData = mapper.readTree(reqBody);

long lichTiemChungId = bodyData.has(EntityConstant.LICHTIEMCHUNG_ID)
? bodyData.get(EntityConstant.LICHTIEMCHUNG_ID).longValue()
: 0;

LichTiemChung lichTiemChung = lichTiemChungAction.findById(lichTiemChungId);

if (lichTiemChung == null) {
throw new ActionException(MessageUtil.getVNMessageText("catiemchung.lichtiem.not_found"),
HttpStatus.NOT_FOUND.value());
}

int stt = bodyData.has(EntityConstant.STT) ? bodyData.get(EntityConstant.STT).intValue() : 1;

String ngayHenTiem = bodyData.has(EntityConstant.NGAYHENTIEM)
Expand All @@ -133,7 +153,7 @@ public CaTiemChung updateCaTiemChung(long id, String reqBody) throws Exception {
caTiemChung.setLichTiemChungId(lichTiemChungId);
caTiemChung.setNgayHenTiem(ngayHenTiem);
caTiemChung.setSoMuiTiem(soMuiTiem);
//caTiemChung.setSoPhieuHen(soPhieuHen);
// caTiemChung.setSoPhieuHen(soPhieuHen);
caTiemChung.setStt(stt);

return caTiemChungService.updateCaTiemChung(caTiemChung);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public LichTiemChung updateLichTiemChung(long id, String reqBody) throws Excepti
lichTiemChung.setNoiSanXuat(noiSanXuat);
lichTiemChung.setSoLoThuoc(soLoThuoc);
lichTiemChung.setMaDot(maDot);
lichTiemChung.setTinhTrangLich(tinhTrangLich);
//lichTiemChung.setTinhTrangLich(tinhTrangLich);
lichTiemChung.setTongSoMuiTiem(tongSoMuiTiem);
lichTiemChung.setBacSiKham(bacSiKham);
lichTiemChung.setSoDienThoai(soDienThoai);
Expand All @@ -213,6 +213,21 @@ public LichTiemChung updateLichTiemChung(long id, String reqBody) throws Excepti

return lichTiemChungService.updateLichTiemChung(lichTiemChung);
}

@Override
public LichTiemChung dongLichTiemChung(long id) throws Exception {
LichTiemChung lichTiemChung = lichTiemChungService.findById(id);

if (lichTiemChung == null) {
throw new ActionException(MessageUtil.getVNMessageText("diabancoso.tendiaban.empty"),
HttpStatus.NOT_FOUND.value());
}

lichTiemChung.setTinhTrangLich(VaccomUtil.DADONG);

return lichTiemChungService.updateLichTiemChung(lichTiemChung);

}

@Override
public List<LichTiemChung> findAll(int page, int size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ public class MuiTiemChungActionImpl implements MuiTiemChungAction {
public long countByCoSoYTeId(long id) {
return muiTiemChungService.countByCoSoYTeId(id);
}


@Override
public long countByNguoiTiemChungId(long id) {
return muiTiemChungService.countByNguoiTiemChungId(id);
}

@Override
public MuiTiemChung addMuiTiemChung(String reqBody) throws Exception {
ObjectMapper mapper = new ObjectMapper();
Expand Down Expand Up @@ -68,8 +73,9 @@ public MuiTiemChung addMuiTiemChung(String reqBody) throws Exception {
: StringPool.BLANK;
String hanSuDung = bodyData.has(EntityConstant.HANSUDUNG) ? bodyData.get(EntityConstant.HANSUDUNG).textValue()
: StringPool.BLANK;

long nguoiTiemChungId = bodyData.has(EntityConstant.NGUOITIEMCHUNG_ID) ? bodyData.get(EntityConstant.NGUOITIEMCHUNG_ID).longValue()

long nguoiTiemChungId = bodyData.has(EntityConstant.NGUOITIEMCHUNG_ID)
? bodyData.get(EntityConstant.NGUOITIEMCHUNG_ID).longValue()
: 0;

long coSoYTeId = bodyData.has(EntityConstant.COSOYTE_ID) ? bodyData.get(EntityConstant.COSOYTE_ID).longValue()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ public NguoiDung addNguoiDung(String reqBody) throws Exception {
String matKhau = bodyData.has(EntityConstant.MATKHAU) ? bodyData.get(EntityConstant.MATKHAU).textValue()
: StringPool.BLANK;

boolean quanTriHeThong = bodyData.has(EntityConstant.QUANTRIHETHONG)
? bodyData.get(EntityConstant.QUANTRIHETHONG).booleanValue()
: false;
int vaiTro = bodyData.has(EntityConstant.VAITRO) ? bodyData.get(EntityConstant.VAITRO).intValue()
: VaccomUtil.VaiTro.NGUOIDUNG.getValue();

String hoVaTen = bodyData.has(EntityConstant.HOVATEN) ? bodyData.get(EntityConstant.HOVATEN).textValue()
: StringPool.BLANK;
Expand Down Expand Up @@ -121,11 +120,11 @@ public NguoiDung addNguoiDung(String reqBody) throws Exception {
nguoiDung.setHoVaTen(hoVaTen);
nguoiDung.setKhoaTaiKhoan(khoaTaiKhoan);
nguoiDung.setMatKhau(new BCryptPasswordEncoder(encodingStrength).encode(matKhau));
nguoiDung.setQuanTriHeThong(quanTriHeThong);
nguoiDung.setVaiTro(vaiTro);
nguoiDung.setSoDienThoai(soDienThoai);
nguoiDung.setTenDangNhap(tenDangNhap);

KhoaDangKy khoaDangKy = createKhoaDangKy(quanTriHeThong);
KhoaDangKy khoaDangKy = createKhoaDangKy(vaiTro);

return nguoiDungService.addNguoiDung(nguoiDung, khoaDangKy);
}
Expand Down Expand Up @@ -182,17 +181,17 @@ public NguoiDung updateNguoiDung(long id, String reqBody) throws Exception {
}

@Override
public NguoiDung updateNguoiDung(long id, boolean quanTriHeThong) throws Exception {
public NguoiDung updateNguoiDung(long id, int vaiTro) throws Exception {

NguoiDung nguoiDung = nguoiDungService.findByID(id);

if (nguoiDung == null) {
throw new ActionException(MessageUtil.getVNMessageText("nguoidung.not_exist"),
HttpStatus.NOT_FOUND.value());
}
nguoiDung.setQuanTriHeThong(quanTriHeThong);

nguoiDung.setVaiTro(vaiTro);

return nguoiDungService.updateNguoiDung(nguoiDung);
}

Expand All @@ -211,11 +210,11 @@ public void initNguoiDung() throws Exception {
nguoiDung.setHoVaTen("Super");
nguoiDung.setKhoaTaiKhoan(false);
nguoiDung.setMatKhau(defaultPass);
nguoiDung.setQuanTriHeThong(true);
nguoiDung.setVaiTro(VaccomUtil.VaiTro.QUANTRIHETHONG.getValue());
nguoiDung.setSoDienThoai("");
nguoiDung.setTenDangNhap("admin");

KhoaDangKy khoaDangKy = createKhoaDangKy(true);
KhoaDangKy khoaDangKy = createKhoaDangKy(VaccomUtil.VaiTro.QUANTRIHETHONG.getValue());

nguoiDungService.addNguoiDung(nguoiDung, khoaDangKy);
}
Expand All @@ -226,7 +225,7 @@ public void initNguoiDung() throws Exception {
public boolean deleteNguoiDung(long id) throws Exception {
NguoiDung nguoiDung = nguoiDungService.findByID(id);

if (nguoiDung == null) {
if (nguoiDung == null || nguoiDung.getTenDangNhap().equals("admin")) {
throw new ActionException(MessageUtil.getVNMessageText("nguoidung.not_exist"),
HttpStatus.NOT_FOUND.value());
}
Expand Down Expand Up @@ -311,7 +310,7 @@ private String gennerateSecretKey(String digest) {
return encryptor.encrypt(digest, secretKey);
}

private KhoaDangKy createKhoaDangKy(boolean isQuanTriHeThong) {
private KhoaDangKy createKhoaDangKy(int vaiTro) {

RandomString random = new RandomString(64);

Expand All @@ -324,7 +323,7 @@ private KhoaDangKy createKhoaDangKy(boolean isQuanTriHeThong) {
KhoaDangKy khoaDangKy = new KhoaDangKy();
khoaDangKy.setKhoaBiMat(khoaBiMat);
khoaDangKy.setKhoaCongKhai(khoaCongKhai);
khoaDangKy.setPhamVi(VaccomUtil.getManagerRoleName(isQuanTriHeThong));
khoaDangKy.setPhamVi(VaccomUtil.getRoleName(vaiTro));
khoaDangKy.setTrangThai(1);

return khoaDangKy;
Expand Down
Loading

0 comments on commit c443ec6

Please sign in to comment.