Merge branch 'dev'
This commit is contained in:
commit
0b0ddb34c1
@ -1,21 +1,15 @@
|
|||||||
package com.jasamedika.medifirst2000.converter;
|
package com.jasamedika.medifirst2000.converter;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.converter.base.BaseVoConverter;
|
import com.jasamedika.medifirst2000.converter.base.BaseVoConverter;
|
||||||
import com.jasamedika.medifirst2000.dao.custom.base.impl.FindConverterDao;
|
import com.jasamedika.medifirst2000.dao.custom.base.impl.FindConverterDao;
|
||||||
import com.jasamedika.medifirst2000.entities.KelompokUser;
|
import com.jasamedika.medifirst2000.entities.KelompokUser;
|
||||||
import com.jasamedika.medifirst2000.entities.LoginUser;
|
import com.jasamedika.medifirst2000.entities.LoginUser;
|
||||||
import com.jasamedika.medifirst2000.service.KelompokUserService;
|
|
||||||
import com.jasamedika.medifirst2000.service.PegawaiService;
|
|
||||||
import com.jasamedika.medifirst2000.util.ExtendedSpringBeanUtil;
|
import com.jasamedika.medifirst2000.util.ExtendedSpringBeanUtil;
|
||||||
import com.jasamedika.medifirst2000.vo.KelompokUserVO;
|
|
||||||
import com.jasamedika.medifirst2000.vo.LoginUserVO;
|
import com.jasamedika.medifirst2000.vo.LoginUserVO;
|
||||||
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converter class between LoginUser and LoginUserVO
|
* Converter class between LoginUser and LoginUserVO
|
||||||
@ -23,85 +17,22 @@ import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
|||||||
* @author Roberto
|
* @author Roberto
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
public class LoginUserAuthConverter extends FindConverterDao implements
|
public class LoginUserAuthConverter extends FindConverterDao implements BaseVoConverter<LoginUserVO, LoginUser> {
|
||||||
BaseVoConverter<LoginUserVO, LoginUser> {
|
|
||||||
/*
|
|
||||||
@Override
|
|
||||||
public LoginUser transferVOToModel(LoginUserVO vo, LoginUser model) {
|
public LoginUser transferVOToModel(LoginUserVO vo, LoginUser model) {
|
||||||
if (null == model)
|
if (null == model)
|
||||||
model = new LoginUser();
|
model = new LoginUser();
|
||||||
|
ExtendedSpringBeanUtil.copySpecificProperties(vo, model, new String[] { "id", "kataSandi", "namaUser", },
|
||||||
try {
|
new String[] { "id", "kataSandi", "namaUser", });
|
||||||
String[] fieldsToInclude = null;
|
|
||||||
Map<String, Object> serialized = vo.serialize(fieldsToInclude,vo.getClass().getName());
|
|
||||||
Gson gson = new Gson();
|
|
||||||
String json = gson.toJson(serialized);
|
|
||||||
model = gson.fromJson(json, LoginUser.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return model;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<LoginUserVO> transferListOfModelToListOfVO(List<LoginUser> models, List<LoginUserVO> vos) {
|
|
||||||
if (null == vos)
|
|
||||||
vos = new ArrayList<LoginUserVO>();
|
|
||||||
|
|
||||||
if (null == models)
|
|
||||||
return vos;
|
|
||||||
|
|
||||||
for (LoginUser loginUser : models) {
|
|
||||||
LoginUserVO vo = new LoginUserVO();
|
|
||||||
vo=transferModelToVO(loginUser, vo);
|
|
||||||
vos.add(vo);
|
|
||||||
}
|
|
||||||
|
|
||||||
return vos;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public LoginUserVO transferModelToVO(LoginUser model, LoginUserVO vo) {
|
|
||||||
if (null == vo)
|
|
||||||
vo = new LoginUserVO();
|
|
||||||
try {
|
|
||||||
String[] fieldsToInclude = null;
|
|
||||||
Map<String, Object> serialized = model.serialize(fieldsToInclude,model.getClass().getSimpleName());
|
|
||||||
Gson gson = new Gson();
|
|
||||||
|
|
||||||
String json = gson.toJson(serialized);
|
|
||||||
vo = gson.fromJson(json, LoginUserVO.class);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return vo;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
public LoginUser transferVOToModel(LoginUserVO vo, LoginUser model) {
|
|
||||||
if (null == model)
|
|
||||||
model = new LoginUser();
|
|
||||||
|
|
||||||
// fix this
|
|
||||||
ExtendedSpringBeanUtil.copySpecificProperties(vo, model, new String[] {
|
|
||||||
"id", "kataSandi", "namaUser", }, new String[] { "id",
|
|
||||||
"kataSandi", "namaUser", });
|
|
||||||
if (vo.getKelompokUser() != null) {
|
if (vo.getKelompokUser() != null) {
|
||||||
KelompokUser kelompokUser = (KelompokUser) findObjectById(
|
KelompokUser kelompokUser = (KelompokUser) findObjectById(KelompokUser.class, vo.getKelompokUser().getId());
|
||||||
KelompokUser.class, vo.getKelompokUser().getId());
|
|
||||||
model.setKelompokUser(kelompokUser);
|
model.setKelompokUser(kelompokUser);
|
||||||
}
|
}
|
||||||
return model;
|
return model;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LoginUserVO> transferListOfModelToListOfVO(
|
public List<LoginUserVO> transferListOfModelToListOfVO(List<LoginUser> models, List<LoginUserVO> vos) {
|
||||||
List<LoginUser> models, List<LoginUserVO> vos) {
|
|
||||||
if (null == vos)
|
if (null == vos)
|
||||||
vos = new ArrayList<LoginUserVO>();
|
vos = new ArrayList<>();
|
||||||
|
|
||||||
if (null == models)
|
if (null == models)
|
||||||
return vos;
|
return vos;
|
||||||
|
|
||||||
@ -110,35 +41,14 @@ public class LoginUserAuthConverter extends FindConverterDao implements
|
|||||||
transferModelToVO(loginUser, loginUserVO);
|
transferModelToVO(loginUser, loginUserVO);
|
||||||
vos.add(loginUserVO);
|
vos.add(loginUserVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vos;
|
return vos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LoginUserVO transferModelToVO(LoginUser model, LoginUserVO vo) {
|
public LoginUserVO transferModelToVO(LoginUser model, LoginUserVO vo) {
|
||||||
if (null == vo)
|
if (null == vo)
|
||||||
|
|
||||||
vo = new LoginUserVO();
|
vo = new LoginUserVO();
|
||||||
|
ExtendedSpringBeanUtil.copySpecificProperties(model, vo, new String[] { "id", "kataSandi", "namaUser", },
|
||||||
// fix this
|
new String[] { "id", "kataSandi", "namaUser", });
|
||||||
ExtendedSpringBeanUtil.copySpecificProperties(model, vo, new String[] {
|
|
||||||
"id", "kataSandi", "namaUser", }, new String[] { "id",
|
|
||||||
"kataSandi", "namaUser", });
|
|
||||||
|
|
||||||
if (model.getKelompokUser() != null) {
|
|
||||||
KelompokUserVO kelompokUserVo = kelompokUserService.findById(model
|
|
||||||
.getKelompokUser().getId());
|
|
||||||
vo.setKelompokUser(kelompokUserVo);
|
|
||||||
}
|
|
||||||
if (model.getPegawai() != null) {
|
|
||||||
PegawaiVO kelompokUserVo = pgawaiService.findById(model
|
|
||||||
.getPegawai().getId());
|
|
||||||
vo.setPegawai(kelompokUserVo);
|
|
||||||
}
|
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private KelompokUserService kelompokUserService;
|
|
||||||
@Autowired
|
|
||||||
private PegawaiService pgawaiService;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
package com.jasamedika.medifirst2000.service.impl;
|
package com.jasamedika.medifirst2000.service.impl;
|
||||||
|
|
||||||
import java.net.URISyntaxException;
|
import com.google.gson.Gson;
|
||||||
import java.util.ArrayList;
|
import com.jasamedika.medifirst2000.dao.ActivityPegawaiDao;
|
||||||
import java.util.Date;
|
import com.jasamedika.medifirst2000.dao.PegawaiDao;
|
||||||
import java.util.List;
|
import com.jasamedika.medifirst2000.entities.ActivityPegawai;
|
||||||
import java.util.Map;
|
import com.jasamedika.medifirst2000.entities.Pegawai;
|
||||||
|
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||||
import javax.persistence.EntityManager;
|
import com.jasamedika.medifirst2000.service.ActivityPegawaiService;
|
||||||
import javax.persistence.PersistenceContext;
|
import com.jasamedika.medifirst2000.util.CommonUtil;
|
||||||
import javax.persistence.Query;
|
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
||||||
|
import io.socket.client.IO;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@ -19,159 +19,129 @@ import org.springframework.data.domain.PageRequest;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import javax.persistence.EntityManager;
|
||||||
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
|
import javax.persistence.PersistenceContext;
|
||||||
import com.jasamedika.medifirst2000.dao.ActivityPegawaiDao;
|
import javax.persistence.Query;
|
||||||
import com.jasamedika.medifirst2000.dao.PegawaiDao;
|
import java.net.URISyntaxException;
|
||||||
import com.jasamedika.medifirst2000.entities.ActivityPegawai;
|
import java.util.*;
|
||||||
import com.jasamedika.medifirst2000.entities.Pegawai;
|
|
||||||
import com.jasamedika.medifirst2000.service.ActivityPegawaiService;
|
|
||||||
import com.jasamedika.medifirst2000.util.CommonUtil;
|
|
||||||
import com.jasamedika.medifirst2000.vo.PegawaiVO;
|
|
||||||
|
|
||||||
import io.socket.client.IO;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implement class for PelayananObatService
|
* Implement class for PelayananObatService
|
||||||
*
|
*
|
||||||
* @author Generator
|
* @author Generator
|
||||||
* @param <T>
|
|
||||||
*/
|
*/
|
||||||
@Service("activityPegawaiServiceImpl")
|
@Service("activityPegawaiServiceImpl")
|
||||||
public class ActivityPegawaiServiceImpl implements ActivityPegawaiService {
|
public class ActivityPegawaiServiceImpl implements ActivityPegawaiService {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(ActivityPegawaiService.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(ActivityPegawaiService.class);
|
||||||
|
|
||||||
static io.socket.client.Socket socket =null;
|
static io.socket.client.Socket socket = null;
|
||||||
|
|
||||||
@PersistenceContext
|
@PersistenceContext
|
||||||
protected EntityManager em;
|
protected EntityManager em;
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(readOnly=false)
|
|
||||||
public String GetSettingDataFixed(String prefix) {
|
|
||||||
StringBuffer buffer = new StringBuffer();
|
|
||||||
buffer.append("select model.nilaiField from SettingDataFixed ")
|
|
||||||
.append(" model where model.namaField ='"+prefix+"' ");
|
|
||||||
Query query = em.createQuery(buffer.toString());
|
|
||||||
|
|
||||||
String result = (String)query.getSingleResult();
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void BroadcastMessage(final String to, final Map data) {
|
|
||||||
try {
|
|
||||||
if(socket==null)
|
|
||||||
{
|
|
||||||
socket = IO.socket(GetSettingDataFixed("UrlSocketMessaging"));
|
|
||||||
|
|
||||||
socket.on(io.socket.client.Socket.EVENT_CONNECT, new io.socket.emitter.Emitter.Listener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void call(Object... args) {
|
|
||||||
|
|
||||||
try {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
JSONObject item=new JSONObject("{\"to\":\""+to+"\",\"message\":"+gson.toJson(data)+"}");
|
|
||||||
LOGGER.info("{\"to\":\""+to+"\",\"message\":"+gson.toJson(data)+"}");
|
|
||||||
socket.emit("subscribe", item);
|
|
||||||
//socket.disconnect();
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
socket.connect();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
try {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
JSONObject item=new JSONObject("{\"to\":\""+to+"\",\"message\":"+gson.toJson(data)+"}");
|
|
||||||
LOGGER.info("{\"to\":\""+to+"\",\"message\":"+gson.toJson(data)+"}");
|
|
||||||
socket.emit("subscribe", item);
|
|
||||||
//socket.disconnect();
|
|
||||||
} catch (JSONException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@Autowired
|
|
||||||
private BaseConverterImpl<PegawaiVO, Pegawai> pelayananObatConverter;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ActivityPegawaiDao activityPegawaiDao;
|
private ActivityPegawaiDao activityPegawaiDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PegawaiDao pegawaiDao;
|
private PegawaiDao pegawaiDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly=false)
|
@Transactional
|
||||||
|
public String GetSettingDataFixed(String prefix) {
|
||||||
|
String buffer = "select model.nilaiField from SettingDataFixed " + " model where model.namaField ='" + prefix
|
||||||
|
+ "' ";
|
||||||
|
Query query = em.createQuery(buffer);
|
||||||
|
return (String) query.getSingleResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void BroadcastMessage(final String to, final Map<String, Object> data) {
|
||||||
|
try {
|
||||||
|
if (socket == null) {
|
||||||
|
socket = IO.socket(GetSettingDataFixed("UrlSocketMessaging"));
|
||||||
|
socket.on(io.socket.client.Socket.EVENT_CONNECT, args -> {
|
||||||
|
try {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
JSONObject item = new JSONObject(
|
||||||
|
"{\"to\":\"" + to + "\",\"message\":" + gson.toJson(data) + "}");
|
||||||
|
LOGGER.info("{\"to\":\"" + to + "\",\"message\":" + gson.toJson(data) + "}");
|
||||||
|
socket.emit("subscribe", item);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
throw new ServiceVOException(e.getMessage());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
socket.connect();
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
JSONObject item = new JSONObject("{\"to\":\"" + to + "\",\"message\":" + gson.toJson(data) + "}");
|
||||||
|
LOGGER.info("{\"to\":\"" + to + "\",\"message\":" + gson.toJson(data) + "}");
|
||||||
|
socket.emit("subscribe", item);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
throw new ServiceVOException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new ServiceVOException(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
public Boolean record(PegawaiVO pegawai, Date tanggal, String keterangan) {
|
public Boolean record(PegawaiVO pegawai, Date tanggal, String keterangan) {
|
||||||
Pegawai pegawaiSave = new Pegawai();
|
Pegawai pegawaiSave = new Pegawai();
|
||||||
pegawaiSave.setId(pegawai.getId());
|
pegawaiSave.setId(pegawai.getId());
|
||||||
ActivityPegawai act = new ActivityPegawai();
|
ActivityPegawai act = new ActivityPegawai();
|
||||||
act.setKeterangan(keterangan);
|
act.setKeterangan(keterangan);
|
||||||
act.setPegawai(pegawaiSave);
|
act.setPegawai(pegawaiSave);
|
||||||
act.setTanggalKejadian(new Date());
|
act.setTanggalKejadian(new Date());
|
||||||
|
act = activityPegawaiDao.save(act);
|
||||||
act =activityPegawaiDao.save(act);
|
act = activityPegawaiDao.findOne(act.getNoRec());
|
||||||
act =activityPegawaiDao.findOne(act.getNoRec());
|
|
||||||
act.setPegawai(pegawaiDao.findById(pegawai.getId()));
|
|
||||||
try {
|
try {
|
||||||
BroadcastMessage("IKI",act.ToMap());
|
BroadcastMessage("IKI", act.ToMap());
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
throw new ServiceVOException(e.getMessage());
|
||||||
}
|
}
|
||||||
return act.getNoRec()!="";
|
return !Objects.equals(act.getNoRec(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly=false)
|
@Transactional
|
||||||
public Boolean record(PegawaiVO pegawai, Date tanggal, String keterangan,String group) {
|
public Boolean record(PegawaiVO pegawai, Date tanggal, String keterangan, String group) {
|
||||||
Pegawai pegawaiSave = new Pegawai();
|
Pegawai pegawaiSave = new Pegawai();
|
||||||
pegawaiSave.setId(pegawai.getId());
|
pegawaiSave.setId(pegawai.getId());
|
||||||
ActivityPegawai act = new ActivityPegawai();
|
ActivityPegawai act = new ActivityPegawai();
|
||||||
act.setKeterangan(keterangan);
|
act.setKeterangan(keterangan);
|
||||||
act.setGroup(group);
|
act.setGroup(group);
|
||||||
act.setPegawai(pegawaiSave);
|
act.setPegawai(pegawaiSave);
|
||||||
act.setTanggalKejadian(new Date());
|
act.setTanggalKejadian(new Date());
|
||||||
|
act = activityPegawaiDao.save(act);
|
||||||
act =activityPegawaiDao.save(act);
|
act = activityPegawaiDao.findOne(act.getNoRec());
|
||||||
act =activityPegawaiDao.findOne(act.getNoRec());
|
|
||||||
act.setPegawai(pegawaiDao.findById(pegawai.getId()));
|
act.setPegawai(pegawaiDao.findById(pegawai.getId()));
|
||||||
try {
|
try {
|
||||||
BroadcastMessage("IKI",act.ToMap());
|
BroadcastMessage("IKI", act.ToMap());
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
throw new ServiceVOException(e.getMessage());
|
||||||
}
|
}
|
||||||
return act.getNoRec()!="";
|
return !Objects.equals(act.getNoRec(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ActivityPegawai> getData() {
|
public List<ActivityPegawai> getData() {
|
||||||
return (List<ActivityPegawai>) activityPegawaiDao.findDescending();
|
return activityPegawaiDao.findDescending();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ActivityPegawai> getData(Date start, Date until,Integer top) {
|
public List<ActivityPegawai> getData(Date start, Date until, Integer top) {
|
||||||
return (List<ActivityPegawai>) activityPegawaiDao.findDescending(start,until,new PageRequest(0,top));
|
return activityPegawaiDao.findDescending(start, until, new PageRequest(0, top));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> getActivityData(String tanggal, Integer idPegawai) {
|
public List<Map<String, Object>> getActivityData(String tanggal, Integer idPegawai) {
|
||||||
List<Map<String, Object>> result = new ArrayList<Map<String,Object>>();
|
|
||||||
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(tanggal) && CommonUtil.isNotNullOrEmpty(idPegawai)) {
|
if (CommonUtil.isNotNullOrEmpty(tanggal) && CommonUtil.isNotNullOrEmpty(idPegawai)) {
|
||||||
result = activityPegawaiDao.aktivitasByDatePegawai(tanggal, idPegawai);
|
return activityPegawaiDao.aktivitasByDatePegawai(tanggal, idPegawai);
|
||||||
} else if (CommonUtil.isNotNullOrEmpty(tanggal) && CommonUtil.isNullOrEmpty(idPegawai)) {
|
} else if (CommonUtil.isNotNullOrEmpty(tanggal) && CommonUtil.isNullOrEmpty(idPegawai)) {
|
||||||
result = activityPegawaiDao.aktivitasByDate(tanggal);
|
return activityPegawaiDao.aktivitasByDate(tanggal);
|
||||||
} else {
|
|
||||||
result = activityPegawaiDao.aktivitasHariIni();
|
|
||||||
}
|
}
|
||||||
|
return activityPegawaiDao.aktivitasHariIni();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2,7 +2,6 @@ package com.jasamedika.medifirst2000.service.impl;
|
|||||||
|
|
||||||
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
|
import com.jasamedika.medifirst2000.converter.BaseConverterImpl;
|
||||||
import com.jasamedika.medifirst2000.converter.LoginUserAuthConverter;
|
import com.jasamedika.medifirst2000.converter.LoginUserAuthConverter;
|
||||||
import com.jasamedika.medifirst2000.converter.LoginUserConverter;
|
|
||||||
import com.jasamedika.medifirst2000.dao.HistoryLoginModulAplikasiDao;
|
import com.jasamedika.medifirst2000.dao.HistoryLoginModulAplikasiDao;
|
||||||
import com.jasamedika.medifirst2000.dao.LoginUserDao;
|
import com.jasamedika.medifirst2000.dao.LoginUserDao;
|
||||||
import com.jasamedika.medifirst2000.dao.MapPegawaiToModulAplikasiDao;
|
import com.jasamedika.medifirst2000.dao.MapPegawaiToModulAplikasiDao;
|
||||||
@ -30,7 +29,6 @@ import java.util.*;
|
|||||||
|
|
||||||
@Service("LoginUserService")
|
@Service("LoginUserService")
|
||||||
public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUserService {
|
public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUserService {
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoginUserServiceImpl.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(LoginUserServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -43,10 +41,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
private LoginUserAuthConverter loginUserAuthConverter;
|
private LoginUserAuthConverter loginUserAuthConverter;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LoginUserConverter loginUserConverter;
|
private BaseConverterImpl<LoginUserVO, LoginUser> loginUserConverter;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private BaseConverterImpl<LoginUserVO, LoginUser> loginUserConverters;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private BaseConverterImpl<PegawaiVO, Pegawai> pegawaiConverter;
|
private BaseConverterImpl<PegawaiVO, Pegawai> pegawaiConverter;
|
||||||
@ -103,7 +98,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = false)
|
@Transactional
|
||||||
public LoginUserVO add(LoginUserVO vo) throws JpaSystemException, ServiceVOException {
|
public LoginUserVO add(LoginUserVO vo) throws JpaSystemException, ServiceVOException {
|
||||||
// convert to model and call repository
|
// convert to model and call repository
|
||||||
LoginUser loginUser = new LoginUser();
|
LoginUser loginUser = new LoginUser();
|
||||||
@ -113,7 +108,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
try {
|
try {
|
||||||
loginUser.setKataSandi(passwordUtil.encryptPassword(loginUser.getKataSandi()));
|
loginUser.setKataSandi(passwordUtil.encryptPassword(loginUser.getKataSandi()));
|
||||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
throw new ServiceVOException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
LoginUser resultModel = loginUserDao.save(loginUser);
|
LoginUser resultModel = loginUserDao.save(loginUser);
|
||||||
@ -126,7 +121,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = false)
|
@Transactional
|
||||||
public LoginUserVO update(LoginUserVO vo) throws JpaSystemException, ServiceVOException {
|
public LoginUserVO update(LoginUserVO vo) throws JpaSystemException, ServiceVOException {
|
||||||
|
|
||||||
// Alter Syamsu
|
// Alter Syamsu
|
||||||
@ -139,7 +134,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
try {
|
try {
|
||||||
loginUserLama.setKataSandi(passwordUtil.encryptPassword(loginUserLama.getKataSandi()));
|
loginUserLama.setKataSandi(passwordUtil.encryptPassword(loginUserLama.getKataSandi()));
|
||||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
throw new ServiceVOException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
loginUserDao.save(loginUserLama);
|
loginUserDao.save(loginUserLama);
|
||||||
@ -152,7 +147,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(readOnly = false)
|
@Transactional
|
||||||
public Boolean delete(Integer key) throws JpaSystemException {
|
public Boolean delete(Integer key) throws JpaSystemException {
|
||||||
if (loginUserDao.exists(key)) {
|
if (loginUserDao.exists(key)) {
|
||||||
loginUserDao.delete(key);
|
loginUserDao.delete(key);
|
||||||
@ -180,7 +175,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
|
|
||||||
List<LoginUser> loginUserList = IteratorUtils.toList(loginUserDao.findAll().iterator());
|
List<LoginUser> loginUserList = IteratorUtils.toList(loginUserDao.findAll().iterator());
|
||||||
|
|
||||||
List<LoginUserVO> loginUserVOList = new ArrayList<LoginUserVO>();
|
List<LoginUserVO> loginUserVOList = new ArrayList<>();
|
||||||
loginUserConverter.transferListOfModelToListOfVO(loginUserList, loginUserVOList);
|
loginUserConverter.transferListOfModelToListOfVO(loginUserList, loginUserVOList);
|
||||||
|
|
||||||
return loginUserVOList;
|
return loginUserVOList;
|
||||||
@ -202,7 +197,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
|
|
||||||
LoginUser loginUser = loginUsers.get(0);
|
LoginUser loginUser = loginUsers.get(0);
|
||||||
PasswordUtil passwordUtil = new PasswordUtil();
|
PasswordUtil passwordUtil = new PasswordUtil();
|
||||||
Boolean isValidPassword = false;
|
boolean isValidPassword;
|
||||||
try {
|
try {
|
||||||
isValidPassword = passwordUtil.isPasswordEqual(authVO.getKataSandi(), loginUser.getKataSandi());
|
isValidPassword = passwordUtil.isPasswordEqual(authVO.getKataSandi(), loginUser.getKataSandi());
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
@ -214,11 +209,19 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
// to do validasi yang advanced di sini
|
// to do validasi yang advanced di sini
|
||||||
|
|
||||||
LoginUserVO vo = new LoginUserVO();
|
LoginUserVO vo = new LoginUserVO();
|
||||||
loginUserAuthConverter.transferModelToVO(loginUser, vo);
|
vo = loginUserAuthConverter.transferModelToVO(loginUser, vo);
|
||||||
|
if (CommonUtil.isNotNullOrEmpty(loginUser.getKelompokUser())) {
|
||||||
|
KelompokUserVO kelompokUserVO = new KelompokUserVO();
|
||||||
|
kelompokUserVO = kelompokUserConverter.transferModelToVO(loginUser.getKelompokUser(), kelompokUserVO);
|
||||||
|
vo.setKelompokUser(kelompokUserVO);
|
||||||
|
}
|
||||||
|
if (CommonUtil.isNotNullOrEmpty(loginUser.getPegawai())) {
|
||||||
|
PegawaiVO pegawaiVO = new PegawaiVO();
|
||||||
|
pegawaiVO = pegawaiConverter.transferModelToVO(loginUser.getPegawai(), pegawaiVO);
|
||||||
|
vo.setPegawai(pegawaiVO);
|
||||||
|
}
|
||||||
return vo;
|
return vo;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("User account is unauthorized : username : " + authVO.getNamaUser());
|
throw new RuntimeException("User account is unauthorized : username : " + authVO.getNamaUser());
|
||||||
}
|
}
|
||||||
@ -226,22 +229,20 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginUser getLoginUser() {
|
public LoginUser getLoginUser() {
|
||||||
List<LoginUser> loginUser = null;
|
|
||||||
try {
|
try {
|
||||||
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
Object principal = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
|
||||||
String namaUser = principal.toString();
|
String namaUser = principal.toString();
|
||||||
loginUser = loginUserDao.findByNamaUser(namaUser);
|
List<LoginUser> loginUser = loginUserDao.findByNamaUser(namaUser);
|
||||||
|
return loginUser.get(0);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
throw new ServiceVOException(e.getMessage());
|
||||||
}
|
}
|
||||||
return loginUser.get(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getAllUser() {
|
public Map<String, Object> getAllUser() {
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
List<LoginUser> list = new ArrayList<LoginUser>();
|
List<LoginUser> list = loginUserDao.findAllUser();
|
||||||
list = (List<LoginUser>) loginUserDao.findAllUser();
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(list)) {
|
if (CommonUtil.isNotNullOrEmpty(list)) {
|
||||||
result.put("data", list);
|
result.put("data", list);
|
||||||
result.put("dataFound", true);
|
result.put("dataFound", true);
|
||||||
@ -251,12 +252,9 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reza
|
|
||||||
// -----------------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> getLoadData() {
|
public Map<String, Object> getLoadData() {
|
||||||
Map<String, Object> result = new HashMap<String, Object>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
List<Map<String, Object>> listPegawai = loginUserDao.listPegawai();
|
List<Map<String, Object>> listPegawai = loginUserDao.listPegawai();
|
||||||
if (CommonUtil.isNotNullOrEmpty(listPegawai)) {
|
if (CommonUtil.isNotNullOrEmpty(listPegawai)) {
|
||||||
@ -348,7 +346,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
throw new ServiceVOException(ex.getMessage());
|
||||||
}
|
}
|
||||||
return listSideMenu;
|
return listSideMenu;
|
||||||
}
|
}
|
||||||
@ -366,7 +364,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
|
|
||||||
LoginUser loginUser = new LoginUser();
|
LoginUser loginUser = new LoginUser();
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo)) {
|
if (CommonUtil.isNotNullOrEmpty(vo)) {
|
||||||
loginUser = loginUserConverters.transferVOToModel(vo, new LoginUser());
|
loginUser = loginUserConverter.transferVOToModel(vo, new LoginUser());
|
||||||
loginUser.setKdProfile((short) 0);
|
loginUser.setKdProfile((short) 0);
|
||||||
loginUser.setStatusEnabled(true);
|
loginUser.setStatusEnabled(true);
|
||||||
loginUser.setKodeExternal("");
|
loginUser.setKodeExternal("");
|
||||||
@ -381,7 +379,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
try {
|
try {
|
||||||
loginUser.setKataSandi(new PasswordUtil().encryptPassword(vo.getKataSandi()));
|
loginUser.setKataSandi(new PasswordUtil().encryptPassword(vo.getKataSandi()));
|
||||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
throw new ServiceVOException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo.getPegawai())) {
|
if (CommonUtil.isNotNullOrEmpty(vo.getPegawai())) {
|
||||||
@ -441,9 +439,8 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
public Map<String, Object> getListRuangan(Integer loginUserId) {
|
public Map<String, Object> getListRuangan(Integer loginUserId) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
List<Map<String, Object>> listRuangan = loginUserDao.getListRuangan(loginUserId);
|
List<Map<String, Object>> listRuangan = loginUserDao.getListRuangan(loginUserId);
|
||||||
if (CommonUtil.isNotNullOrEmpty(listRuangan)) {
|
if (CommonUtil.isNotNullOrEmpty(listRuangan))
|
||||||
result.put("listRuangan", listRuangan);
|
result.put("listRuangan", listRuangan);
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -451,62 +448,22 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
public Map<String, Object> getListModulAplikasi(Integer pegawaiId) {
|
public Map<String, Object> getListModulAplikasi(Integer pegawaiId) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
List<Map<String, Object>> listModulAplikasi = loginUserDao.getListModulAplikasi(pegawaiId);
|
List<Map<String, Object>> listModulAplikasi = loginUserDao.getListModulAplikasi(pegawaiId);
|
||||||
if (CommonUtil.isNotNullOrEmpty(listModulAplikasi)) {
|
if (CommonUtil.isNotNullOrEmpty(listModulAplikasi))
|
||||||
result.put("listModulAplikasi", listModulAplikasi);
|
result.put("listModulAplikasi", listModulAplikasi);
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Map<String, Object>> getListObjectModulAplikasi(Integer modulAplikasiId) {
|
public List<Map<String, Object>> getListObjectModulAplikasi(Integer modulAplikasiId) {
|
||||||
List<Map<String, Object>> result = new ArrayList<>();
|
return new ArrayList<>();
|
||||||
// for(Map<String, Object> objectModulHead :
|
|
||||||
// loginUserDao.getObjectModulHeadByModul(modulAplikasiId)){
|
|
||||||
// Map<String, Object> parent = new HashMap<>();
|
|
||||||
//
|
|
||||||
// if(CommonUtil.isNotNullOrEmpty(objectModulHead)){
|
|
||||||
// parent.put("name", objectModulHead.get("objekModulAplikasi"));
|
|
||||||
// parent.put("noUrut", objectModulHead.get("objekModulNoUrut"));
|
|
||||||
//
|
|
||||||
// List<Map<String, Object>> listObjectModul =
|
|
||||||
// loginUserDao.getModulByModulHead((Integer)objectModulHead.get("id"));
|
|
||||||
// if(CommonUtil.isNullOrEmpty(listObjectModul)){
|
|
||||||
// parent.put("link", objectModulHead.get("alamatUrlForm"));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// List<Map<String, Object>> listChildren = new ArrayList<>();
|
|
||||||
// for(Map<String, Object> objectModul: listObjectModul){
|
|
||||||
// Map<String, Object> children = new HashMap<>();
|
|
||||||
//
|
|
||||||
// if(CommonUtil.isNotNullOrEmpty(objectModul)){
|
|
||||||
// children.put("name", objectModul.get("objekModulAplikasi"));
|
|
||||||
// children.put("link", objectModul.get("alamatUrlForm"));
|
|
||||||
// children.put("noUrut", objectModul.get("objekModulNoUrut"));
|
|
||||||
// }
|
|
||||||
// if(CommonUtil.isNotNullOrEmpty(children)){
|
|
||||||
// listChildren.add(children);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if(CommonUtil.isNotNullOrEmpty(listChildren)){
|
|
||||||
// parent.put("children", listChildren);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if(CommonUtil.isNotNullOrEmpty(parent)){
|
|
||||||
// result.add(parent);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Object> saveUpdateLoginUser(LoginUserVO vo) {
|
public Map<String, Object> saveUpdateLoginUser(LoginUserVO vo) {
|
||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo)) {
|
if (CommonUtil.isNotNullOrEmpty(vo)) {
|
||||||
LoginUser loginUser = new LoginUser();
|
|
||||||
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo.getId())) {
|
if (CommonUtil.isNotNullOrEmpty(vo.getId())) {
|
||||||
loginUser = setLoginUser(vo);
|
LoginUser loginUser = setLoginUser(vo);
|
||||||
if (CommonUtil.isNotNullOrEmpty(loginUser)) {
|
if (CommonUtil.isNotNullOrEmpty(loginUser)) {
|
||||||
LoginUser loginUserResult = loginUserDao.save(loginUser);
|
LoginUser loginUserResult = loginUserDao.save(loginUser);
|
||||||
result.put("namaUser", loginUserResult.getNamaUser());
|
result.put("namaUser", loginUserResult.getNamaUser());
|
||||||
@ -518,7 +475,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
if (CommonUtil.isNotNullOrEmpty(users)) {
|
if (CommonUtil.isNotNullOrEmpty(users)) {
|
||||||
result.put("statusError", "Nama user sudah ada, silahkan input nama user lainya");
|
result.put("statusError", "Nama user sudah ada, silahkan input nama user lainya");
|
||||||
} else {
|
} else {
|
||||||
loginUser = setLoginUser(vo);
|
LoginUser loginUser = setLoginUser(vo);
|
||||||
if (CommonUtil.isNotNullOrEmpty(loginUser)) {
|
if (CommonUtil.isNotNullOrEmpty(loginUser)) {
|
||||||
LoginUser loginUserResult = loginUserDao.save(loginUser);
|
LoginUser loginUserResult = loginUserDao.save(loginUser);
|
||||||
result.put("namaUser", loginUserResult.getNamaUser());
|
result.put("namaUser", loginUserResult.getNamaUser());
|
||||||
@ -557,7 +514,7 @@ public class LoginUserServiceImpl extends BaseVoServiceImpl implements LoginUser
|
|||||||
try {
|
try {
|
||||||
loginUser.setKataSandi(new PasswordUtil().encryptPassword(vo.getKataSandi()));
|
loginUser.setKataSandi(new PasswordUtil().encryptPassword(vo.getKataSandi()));
|
||||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
throw new ServiceVOException(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (CommonUtil.isNotNullOrEmpty(vo.getPegawai())) {
|
if (CommonUtil.isNotNullOrEmpty(vo.getPegawai())) {
|
||||||
|
|||||||
@ -1,24 +1,31 @@
|
|||||||
package com.jasamedika.medifirst2000.entities;
|
package com.jasamedika.medifirst2000.entities;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import javax.persistence.*;
|
|
||||||
import com.jasamedika.medifirst2000.base.BaseTransaction;
|
import com.jasamedika.medifirst2000.base.BaseTransaction;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
import com.jasamedika.medifirst2000.helper.Caption;
|
import com.jasamedika.medifirst2000.helper.Caption;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static javax.persistence.FetchType.LAZY;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "ActivityPegawai_H")
|
@Table(name = "ActivityPegawai_H")
|
||||||
public class ActivityPegawai extends BaseTransaction {
|
public class ActivityPegawai extends BaseTransaction {
|
||||||
|
private static final long serialVersionUID = 3739050768690435138L;
|
||||||
|
|
||||||
@Caption(value = "keterangan")
|
@Caption(value = "keterangan")
|
||||||
@Column(name = "Keterangan", nullable = true)
|
@Column(name = "Keterangan")
|
||||||
private String keterangan;
|
private String keterangan;
|
||||||
|
|
||||||
@Caption(value = "Tanggal Kejadian")
|
@Caption(value = "Tanggal Kejadian")
|
||||||
@Column(name = "tanggalKejadian", nullable = true)
|
@Column(name = "tanggalKejadian")
|
||||||
private Date tanggalKejadian;
|
private Date tanggalKejadian;
|
||||||
|
|
||||||
@ManyToOne
|
@ManyToOne(fetch = LAZY)
|
||||||
@JoinColumn(name = "PegawaiFK")
|
@JoinColumn(name = "PegawaiFK")
|
||||||
@Caption(value = "Pegawai")
|
@Caption(value = "Pegawai")
|
||||||
private Pegawai pegawai;
|
private Pegawai pegawai;
|
||||||
@ -27,48 +34,6 @@ public class ActivityPegawai extends BaseTransaction {
|
|||||||
private Integer pegawaiId;
|
private Integer pegawaiId;
|
||||||
|
|
||||||
@Caption(value = "group")
|
@Caption(value = "group")
|
||||||
@Column(name = "GroupData", nullable = true, length = 250)
|
@Column(name = "GroupData", length = 250)
|
||||||
private String group;
|
private String group;
|
||||||
|
|
||||||
public String getKeterangan() {
|
|
||||||
return keterangan;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKeterangan(String keterangan) {
|
|
||||||
this.keterangan = keterangan;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Date getTanggalKejadian() {
|
|
||||||
return tanggalKejadian;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTanggalKejadian(Date tanggalKejadian) {
|
|
||||||
this.tanggalKejadian = tanggalKejadian;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Pegawai getPegawai() {
|
|
||||||
return pegawai;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPegawai(Pegawai pegawai) {
|
|
||||||
this.pegawai = pegawai;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Integer getPegawaiId() {
|
|
||||||
return pegawaiId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPegawaiId(Integer pegawaiId) {
|
|
||||||
this.pegawaiId = pegawaiId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getGroup() {
|
|
||||||
return group;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGroup(String group) {
|
|
||||||
this.group = group;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1,50 +1,19 @@
|
|||||||
package com.jasamedika.medifirst2000.vo.custom;
|
package com.jasamedika.medifirst2000.vo.custom;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VO untuk Login
|
* VO untuk Login
|
||||||
*/
|
*/
|
||||||
public class AuthVO implements Serializable {
|
@Getter
|
||||||
/**
|
@Setter
|
||||||
* serialVersionUID
|
public class AuthVO {
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 7391557986006113925L;
|
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
private String namaUser;
|
private String namaUser;
|
||||||
private String kdUser;
|
|
||||||
|
private String kdUser;
|
||||||
|
|
||||||
private String kataSandi;
|
private String kataSandi;
|
||||||
|
|
||||||
public Integer getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(Integer id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKdUser() {
|
|
||||||
return kdUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKdUser(String kdUser) {
|
|
||||||
this.kdUser = kdUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getNamaUser() {
|
|
||||||
return namaUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNamaUser(String namaUser) {
|
|
||||||
this.namaUser = namaUser;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getKataSandi() {
|
|
||||||
return kataSandi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKataSandi(String kataSandi) {
|
|
||||||
this.kataSandi = kataSandi;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,29 +1,7 @@
|
|||||||
package com.jasamedika.medifirst2000.controller;
|
package com.jasamedika.medifirst2000.controller;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
|
||||||
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
|
||||||
import org.springframework.security.core.userdetails.User;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import com.jasamedika.medifirst2000.constants.Constants;
|
import com.jasamedika.medifirst2000.constants.Constants;
|
||||||
|
import com.jasamedika.medifirst2000.exception.ServiceVOException;
|
||||||
import com.jasamedika.medifirst2000.logging.hibernate.async.LoggingSystemAsynchronous;
|
import com.jasamedika.medifirst2000.logging.hibernate.async.LoggingSystemAsynchronous;
|
||||||
import com.jasamedika.medifirst2000.notification.MessagePublisher;
|
import com.jasamedika.medifirst2000.notification.MessagePublisher;
|
||||||
import com.jasamedika.medifirst2000.security.model.UserAuthentication;
|
import com.jasamedika.medifirst2000.security.model.UserAuthentication;
|
||||||
@ -39,6 +17,19 @@ import com.jasamedika.medifirst2000.util.rest.RestUtil;
|
|||||||
import com.jasamedika.medifirst2000.vo.AgamaVO;
|
import com.jasamedika.medifirst2000.vo.AgamaVO;
|
||||||
import com.jasamedika.medifirst2000.vo.LoginUserVO;
|
import com.jasamedika.medifirst2000.vo.LoginUserVO;
|
||||||
import com.jasamedika.medifirst2000.vo.custom.AuthVO;
|
import com.jasamedika.medifirst2000.vo.custom.AuthVO;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
|
import org.springframework.security.core.authority.SimpleGrantedAuthority;
|
||||||
|
import org.springframework.security.core.userdetails.User;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller class for Authenticate Business
|
* Controller class for Authenticate Business
|
||||||
@ -48,68 +39,53 @@ import com.jasamedika.medifirst2000.vo.custom.AuthVO;
|
|||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/auth")
|
@RequestMapping("/auth")
|
||||||
public class AuthenticateController {
|
public class AuthenticateController {
|
||||||
|
private static final Logger LOGGER = LoggerFactory.getLogger(AuthenticateController.class);
|
||||||
|
|
||||||
|
protected Map<String, String> mapHeaderMessage = new HashMap<>();
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
MessagePublisher<String, Object> messagePublisher;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
LoggingSystemAsynchronous loggingSystemAsynchronous;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LoginUserService loginUserService;
|
private LoginUserService loginUserService;
|
||||||
|
|
||||||
protected Map<String, String> mapHeaderMessage = new HashMap<String, String>();
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public AgamaService<AgamaVO> agamaService;
|
public AgamaService<AgamaVO> agamaService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ActivityPegawaiService activityPegawaiServiceImpl;
|
private ActivityPegawaiService activityPegawaiService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public JadwalDokterService jadwalDokterService;
|
public JadwalDokterService jadwalDokterService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
MessagePublisher<String, Object> messagePublisher;
|
|
||||||
|
|
||||||
// @Autowired
|
|
||||||
// private DataSource dataSource;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private TokenAuthenticationService tokenAuthenticationService;
|
private TokenAuthenticationService tokenAuthenticationService;
|
||||||
|
|
||||||
// @Autowired
|
|
||||||
// private ObjekModulAplikasiSService objekModulAplikasiSService;
|
|
||||||
|
|
||||||
//Alter Syamsu
|
|
||||||
@Autowired
|
|
||||||
LoggingSystemAsynchronous loggingSystemAsynchronous;
|
|
||||||
|
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(AuthenticateController.class);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@RequestMapping(value = "/history", method = RequestMethod.GET)
|
@RequestMapping(value = "/history", method = RequestMethod.GET)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<Object> GetHistory(@RequestParam(value = "dateStart", required = false) String dateStart,
|
public ResponseEntity<Object> GetHistory(@RequestParam(value = "dateStart", required = false) String dateStart,
|
||||||
@RequestParam(value = "dateEnd", required = false) String dateEnd,
|
@RequestParam(value = "dateEnd", required = false) String dateEnd,
|
||||||
@RequestParam(value = "top", required = false,defaultValue="0") Integer top, HttpServletRequest request,
|
@RequestParam(value = "top", required = false, defaultValue = "0") Integer top, HttpServletRequest request,
|
||||||
HttpServletResponse httpResponse) {
|
HttpServletResponse httpResponse) {
|
||||||
if(top ==0)
|
if (top == 0)
|
||||||
top =Integer.MAX_VALUE;
|
top = Integer.MAX_VALUE;
|
||||||
Date start = DateUtil.toDate(dateStart);
|
Date start = DateUtil.toDate(dateStart);
|
||||||
Date until = DateUtil.toDate(dateEnd);
|
Date until = DateUtil.toDate(dateEnd);
|
||||||
Object data =null;
|
|
||||||
try {
|
try {
|
||||||
data = JsonUtil.ToMaps( activityPegawaiServiceImpl.getData(start, until,top));
|
Object data = JsonUtil.ToMaps(activityPegawaiService.getData(start, until, top));
|
||||||
|
return RestUtil.getJsonResponse(data, HttpStatus.OK, mapHeaderMessage);
|
||||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
throw new ServiceVOException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return RestUtil.getJsonResponse(data, HttpStatus.OK, mapHeaderMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Alter Syamsu
|
|
||||||
@RequestMapping(value = "/sign-in", method = RequestMethod.POST)
|
@RequestMapping(value = "/sign-in", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<LoginUserVO> signIn(@RequestBody AuthVO vo, HttpServletRequest request, HttpServletResponse httpResponse) {
|
public ResponseEntity<LoginUserVO> signIn(@RequestBody AuthVO vo, HttpServletRequest request,
|
||||||
|
HttpServletResponse httpResponse) {
|
||||||
|
|
||||||
if (vo.getNamaUser() == null || vo.getKataSandi() == null) {
|
if (vo.getNamaUser() == null || vo.getKataSandi() == null) {
|
||||||
this.mapHeaderMessage.put(Constants.MessageInfo.ERROR_MESSAGE, "Username or Password is empty");
|
this.mapHeaderMessage.put(Constants.MessageInfo.ERROR_MESSAGE, "Username or Password is empty");
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.BAD_REQUEST, mapHeaderMessage);
|
return RestUtil.getJsonHttptatus(HttpStatus.BAD_REQUEST, mapHeaderMessage);
|
||||||
@ -118,127 +94,65 @@ public class AuthenticateController {
|
|||||||
LOGGER.info("starting logging {}", vo.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
|
LOGGER.info("starting logging {}", vo.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mapHeaderMessage = new HashMap<String, String>();
|
mapHeaderMessage = new HashMap<>();
|
||||||
LoginUserVO loginUserVo = loginUserService.signIn(vo);
|
LoginUserVO loginUserVo = loginUserService.signIn(vo);
|
||||||
if (loginUserVo == null) {
|
if (loginUserVo == null) {
|
||||||
this.mapHeaderMessage.put(Constants.MessageInfo.ERROR_MESSAGE, "Invalid Username or Password");
|
this.mapHeaderMessage.put(Constants.MessageInfo.ERROR_MESSAGE, "Invalid Username or Password");
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE, mapHeaderMessage);
|
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
// GrantedAuthority authority = new
|
|
||||||
// SimpleGrantedAuthority(loginUserVo
|
|
||||||
// .getKelompokUser().getKelompokUser());
|
|
||||||
|
|
||||||
GrantedAuthority authority = new SimpleGrantedAuthority("USER");
|
GrantedAuthority authority = new SimpleGrantedAuthority("USER");
|
||||||
|
String token = tokenAuthenticationService.addAuthentication(httpResponse,
|
||||||
String token = tokenAuthenticationService.addAuthentication(httpResponse, new UserAuthentication(
|
new UserAuthentication(new User(loginUserVo.getNamaUser(), loginUserVo.getKataSandi(),
|
||||||
new User(loginUserVo.getNamaUser(), loginUserVo.getKataSandi(), Arrays.asList(authority))));
|
Collections.singletonList(authority))));
|
||||||
|
|
||||||
Boolean isSupervising = request.getHeader(Constants.HttpHeader.SUPERVISING) == null ? false : true;
|
boolean isSupervising = request.getHeader(Constants.HttpHeader.SUPERVISING) != null;
|
||||||
|
|
||||||
if (isSupervising) { // supervising login
|
if (isSupervising) { // supervising login
|
||||||
mapHeaderMessage.put("X-AUTH-SUPERVISOR-TOKEN", token);
|
mapHeaderMessage.put("X-AUTH-SUPERVISOR-TOKEN", token);
|
||||||
activityPegawaiServiceImpl.record(loginUserVo.getPegawai(), new Date(), "Supervising Login");
|
activityPegawaiService.record(loginUserVo.getPegawai(), new Date(), "Supervising Login");
|
||||||
return RestUtil.getJsonResponse(loginUserVo, HttpStatus.OK, mapHeaderMessage);
|
|
||||||
} else { // normal login
|
} else { // normal login
|
||||||
|
Map<String, Object> data = new HashMap<>();
|
||||||
Map<String,Object> data = new HashMap<>();
|
if (loginUserVo.getPegawai().getJenisPegawai() != null && loginUserVo.getPegawai().getJenisPegawai()
|
||||||
|
.getId() == Integer.parseInt(GetSettingDataFixed("KdJenisPegawaiDokter")))
|
||||||
if (loginUserVo.getPegawai().getJenisPegawai() != null && loginUserVo.getPegawai().getJenisPegawai().getId() == Integer.parseInt(GetSettingDataFixed("KdJenisPegawaiDokter"))) {
|
jadwalDokterService.CheckJadwalDokter(new Date(), loginUserVo.getPegawai());
|
||||||
Boolean result = jadwalDokterService.CheckJadwalDokter(new Date(), loginUserVo.getPegawai());
|
mapHeaderMessage.put("X-AUTH-TOKEN", token);
|
||||||
//if (!result) {
|
activityPegawaiService.record(loginUserVo.getPegawai(), new Date(), "Behasil Login Ke System");
|
||||||
// mapHeaderMessage.put("message", "Tidak memiliki Jadwal hari ini");
|
messagePublisher.sendDirectNotification(data);
|
||||||
//} else {
|
|
||||||
mapHeaderMessage.put("X-AUTH-TOKEN", token);
|
|
||||||
activityPegawaiServiceImpl.record(loginUserVo.getPegawai(), new Date(), "Behasil Login Ke System");
|
|
||||||
messagePublisher.sendDirectNotification(data);
|
|
||||||
//BroadcastMessage("IKI", "");
|
|
||||||
//}
|
|
||||||
} else {
|
|
||||||
|
|
||||||
mapHeaderMessage.put("X-AUTH-TOKEN", token);
|
|
||||||
activityPegawaiServiceImpl.record(loginUserVo.getPegawai(), new Date(), "Behasil Login Ke System");
|
|
||||||
messagePublisher.sendDirectNotification(data);
|
|
||||||
//BroadcastMessage("IKI", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer idPegawai = 0;
|
Integer idPegawai = 0;
|
||||||
if (CommonUtil.isNotNullOrEmpty(loginUserVo.getPegawai())){
|
if (CommonUtil.isNotNullOrEmpty(loginUserVo.getPegawai()))
|
||||||
idPegawai = loginUserVo.getPegawai().getId();
|
idPegawai = loginUserVo.getPegawai().getId();
|
||||||
}
|
|
||||||
|
|
||||||
loggingSystemAsynchronous.saveSignInLog(0, 0, loginUserVo.getNamaUser(), idPegawai);
|
loggingSystemAsynchronous.saveSignInLog(0, 0, loginUserVo.getNamaUser(), idPegawai);
|
||||||
|
|
||||||
return RestUtil.getJsonResponse(loginUserVo, HttpStatus.OK, mapHeaderMessage);
|
|
||||||
}
|
}
|
||||||
|
return RestUtil.getJsonResponse(loginUserVo, HttpStatus.OK, mapHeaderMessage);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
|
||||||
LOGGER.error("Signing-in error {}", ex.getMessage());
|
LOGGER.error("Signing-in error {}", ex.getMessage());
|
||||||
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.UNAUTHORIZED);
|
return RestUtil.getJsonHttptatus(HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String GetSettingDataFixed(String prefix) {
|
public String GetSettingDataFixed(String prefix) {
|
||||||
return activityPegawaiServiceImpl.GetSettingDataFixed(prefix);
|
return activityPegawaiService.GetSettingDataFixed(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void BroadcastMessage(final String to, final String data) {
|
|
||||||
// final Socket socket;
|
|
||||||
// try {
|
|
||||||
// socket = IO.socket(GetSettingDataFixed("UrlSocketMessaging"));
|
|
||||||
//
|
|
||||||
// socket.on(Socket.EVENT_CONNECT, new Emitter.Listener() {
|
|
||||||
// @Override
|
|
||||||
// public void call(Object... args) {
|
|
||||||
// try {
|
|
||||||
// JSONObject item= new JSONObject("{\"to\":\""+to+"\",\"message\":\""+data+"\"}");
|
|
||||||
// socket.emit("subscribe", item);
|
|
||||||
// } catch (JSONException e) {
|
|
||||||
// LOGGER.info(e.getMessage());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
// socket.connect();
|
|
||||||
// } catch (URISyntaxException e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
@RequestMapping(value = "/sign-out", method = RequestMethod.POST)
|
@RequestMapping(value = "/sign-out", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<AuthVO> signOut(@RequestBody AuthVO vo, HttpServletResponse httpResponse) {
|
public ResponseEntity<AuthVO> signOut(@RequestBody AuthVO vo, HttpServletResponse httpResponse) {
|
||||||
|
|
||||||
LoginUserVO loginUserVO = loginUserService.findById(vo.getId());
|
LoginUserVO loginUserVO = loginUserService.findById(vo.getId());
|
||||||
|
|
||||||
LOGGER.info("starting logout {}", loginUserVO.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
|
LOGGER.info("starting logout {}",
|
||||||
|
loginUserVO.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
|
||||||
Integer idPegawai = 0;
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(loginUserVO.getPegawai())){
|
|
||||||
idPegawai = loginUserVO.getPegawai().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
loggingSystemAsynchronous.saveSignOutLog(loginUserVO.getNamaUser(), idPegawai);
|
|
||||||
// GrantedAuthority authority = new SimpleGrantedAuthority("USER");
|
|
||||||
// String token = tokenAuthenticationService.addAuthentication(httpResponse, new UserAuthentication(
|
|
||||||
// new User(loginUserVO.getNamaUser(), loginUserVO.getKataSandi(), Arrays.asList(authority))));
|
|
||||||
// mapHeaderMessage.put("X-AUTH-SUPERVISOR-TOKEN", token);
|
|
||||||
|
|
||||||
return RestUtil.getJsonResponse(vo, HttpStatus.OK);
|
|
||||||
|
|
||||||
|
|
||||||
// misal call service logout dan seterusnya
|
Integer idPegawai = 0;
|
||||||
// Karena Stateless tidak perlu set " session user " menjadi tidak
|
if (CommonUtil.isNotNullOrEmpty(loginUserVO.getPegawai()))
|
||||||
// aktif, return HttpStatus.OK ke client
|
idPegawai = loginUserVO.getPegawai().getId();
|
||||||
//RestUtil.getJsonHttptatus(HttpStatus.OK);
|
loggingSystemAsynchronous.saveSignOutLog(loginUserVO.getNamaUser(), idPegawai);
|
||||||
|
return RestUtil.getJsonResponse(vo, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/sign-in-mobile", method = RequestMethod.POST)
|
@RequestMapping(value = "/sign-in-mobile", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<Map<String,Object>> signInMobile(@RequestBody AuthVO vo, HttpServletRequest request, HttpServletResponse httpResponse) {
|
public ResponseEntity<Map<String, Object>> signInMobile(@RequestBody AuthVO vo, HttpServletRequest request,
|
||||||
|
HttpServletResponse httpResponse) {
|
||||||
|
|
||||||
if (vo.getNamaUser() == null || vo.getKataSandi() == null) {
|
if (vo.getNamaUser() == null || vo.getKataSandi() == null) {
|
||||||
this.mapHeaderMessage.put(Constants.MessageInfo.ERROR_MESSAGE, "Username or Password is empty");
|
this.mapHeaderMessage.put(Constants.MessageInfo.ERROR_MESSAGE, "Username or Password is empty");
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.BAD_REQUEST, mapHeaderMessage);
|
return RestUtil.getJsonHttptatus(HttpStatus.BAD_REQUEST, mapHeaderMessage);
|
||||||
@ -247,99 +161,64 @@ public class AuthenticateController {
|
|||||||
LOGGER.info("starting logging {}", vo.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
|
LOGGER.info("starting logging {}", vo.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mapHeaderMessage = new HashMap<String, String>();
|
mapHeaderMessage = new HashMap<>();
|
||||||
LoginUserVO loginUserVo = loginUserService.signIn(vo);
|
LoginUserVO loginUserVo = loginUserService.signIn(vo);
|
||||||
if (loginUserVo == null) {
|
if (loginUserVo == null) {
|
||||||
this.mapHeaderMessage.put(Constants.MessageInfo.ERROR_MESSAGE, "Invalid Username or Password");
|
this.mapHeaderMessage.put(Constants.MessageInfo.ERROR_MESSAGE, "Invalid Username or Password");
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE, mapHeaderMessage);
|
return RestUtil.getJsonHttptatus(HttpStatus.NOT_ACCEPTABLE, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
// GrantedAuthority authority = new
|
|
||||||
// SimpleGrantedAuthority(loginUserVo
|
|
||||||
// .getKelompokUser().getKelompokUser());
|
|
||||||
|
|
||||||
GrantedAuthority authority = new SimpleGrantedAuthority("USER");
|
GrantedAuthority authority = new SimpleGrantedAuthority("USER");
|
||||||
|
String token = tokenAuthenticationService.addAuthentication(httpResponse,
|
||||||
String token = tokenAuthenticationService.addAuthentication(httpResponse, new UserAuthentication(
|
new UserAuthentication(new User(loginUserVo.getNamaUser(), loginUserVo.getKataSandi(),
|
||||||
new User(loginUserVo.getNamaUser(), loginUserVo.getKataSandi(), Arrays.asList(authority))));
|
Collections.singletonList(authority))));
|
||||||
|
boolean isSupervising = request.getHeader(Constants.HttpHeader.SUPERVISING) != null;
|
||||||
Boolean isSupervising = request.getHeader(Constants.HttpHeader.SUPERVISING) == null ? false : true;
|
|
||||||
|
|
||||||
if (isSupervising) { // supervising login
|
if (isSupervising) { // supervising login
|
||||||
mapHeaderMessage.put("X-AUTH-SUPERVISOR-TOKEN", token);
|
mapHeaderMessage.put("X-AUTH-SUPERVISOR-TOKEN", token);
|
||||||
activityPegawaiServiceImpl.record(loginUserVo.getPegawai(), new Date(), "Supervising Login");
|
activityPegawaiService.record(loginUserVo.getPegawai(), new Date(), "Supervising Login");
|
||||||
Map<String,Object> result= new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
result.put("token", token);
|
result.put("token", token);
|
||||||
result.put("id", loginUserVo.getId());
|
result.put("id", loginUserVo.getId());
|
||||||
result.put("idPegawai", loginUserVo.getPegawai().getId());
|
result.put("idPegawai", loginUserVo.getPegawai().getId());
|
||||||
result.put("name", loginUserVo.getPegawai().getNamaLengkap());
|
result.put("name", loginUserVo.getPegawai().getNamaLengkap());
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||||
} else { // normal login
|
} else { // normal login
|
||||||
|
Map<String, Object> data = new HashMap<>();
|
||||||
Map<String,Object> data = new HashMap<>();
|
if (loginUserVo.getPegawai().getJenisPegawai() != null && loginUserVo.getPegawai().getJenisPegawai()
|
||||||
|
.getId() == Integer.parseInt(GetSettingDataFixed("KdJenisPegawaiDokter")))
|
||||||
if (loginUserVo.getPegawai().getJenisPegawai() != null && loginUserVo.getPegawai().getJenisPegawai().getId() == Integer.parseInt(GetSettingDataFixed("KdJenisPegawaiDokter"))) {
|
jadwalDokterService.CheckJadwalDokter(new Date(), loginUserVo.getPegawai());
|
||||||
Boolean result = jadwalDokterService.CheckJadwalDokter(new Date(), loginUserVo.getPegawai());
|
mapHeaderMessage.put("X-AUTH-TOKEN", token);
|
||||||
// if (!result) {
|
activityPegawaiService.record(loginUserVo.getPegawai(), new Date(), "Behasil Login Ke System");
|
||||||
// mapHeaderMessage.put("message", "Tidak memiliki Jadwal hari ini");
|
messagePublisher.sendDirectNotification(data);
|
||||||
// } else {
|
|
||||||
mapHeaderMessage.put("X-AUTH-TOKEN", token);
|
|
||||||
activityPegawaiServiceImpl.record(loginUserVo.getPegawai(), new Date(), "Behasil Login Ke System");
|
|
||||||
messagePublisher.sendDirectNotification(data);
|
|
||||||
//BroadcastMessage("IKI", "");
|
|
||||||
// }
|
|
||||||
} else {
|
|
||||||
|
|
||||||
mapHeaderMessage.put("X-AUTH-TOKEN", token);
|
|
||||||
activityPegawaiServiceImpl.record(loginUserVo.getPegawai(), new Date(), "Behasil Login Ke System");
|
|
||||||
messagePublisher.sendDirectNotification(data);
|
|
||||||
//BroadcastMessage("IKI", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
Integer idPegawai = 0;
|
Integer idPegawai = 0;
|
||||||
if (CommonUtil.isNotNullOrEmpty(loginUserVo.getPegawai())){
|
if (CommonUtil.isNotNullOrEmpty(loginUserVo.getPegawai()))
|
||||||
idPegawai = loginUserVo.getPegawai().getId();
|
idPegawai = loginUserVo.getPegawai().getId();
|
||||||
}
|
|
||||||
|
|
||||||
loggingSystemAsynchronous.saveSignInLog(0, 0, loginUserVo.getNamaUser(), idPegawai);
|
loggingSystemAsynchronous.saveSignInLog(0, 0, loginUserVo.getNamaUser(), idPegawai);
|
||||||
Map<String,Object> result= new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
result.put("token", token);
|
result.put("token", token);
|
||||||
result.put("id", loginUserVo.getId());
|
result.put("id", loginUserVo.getId());
|
||||||
result.put("idPegawai", loginUserVo.getPegawai().getId());
|
result.put("idPegawai", loginUserVo.getPegawai().getId());
|
||||||
result.put("name", loginUserVo.getPegawai().getNamaLengkap());
|
result.put("name", loginUserVo.getPegawai().getNamaLengkap());
|
||||||
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
return RestUtil.getJsonResponse(result, HttpStatus.OK, mapHeaderMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
|
||||||
LOGGER.error("Signing-in error {}", ex.getMessage());
|
LOGGER.error("Signing-in error {}", ex.getMessage());
|
||||||
|
|
||||||
return RestUtil.getJsonHttptatus(HttpStatus.UNAUTHORIZED);
|
return RestUtil.getJsonHttptatus(HttpStatus.UNAUTHORIZED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/sign-out-mobile", method = RequestMethod.POST)
|
@RequestMapping(value = "/sign-out-mobile", method = RequestMethod.POST)
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ResponseEntity<AuthVO> signOutMobile(@RequestBody AuthVO vo, HttpServletResponse httpResponse) {
|
public ResponseEntity<AuthVO> signOutMobile(@RequestBody AuthVO vo, HttpServletResponse httpResponse) {
|
||||||
|
|
||||||
LoginUserVO loginUserVO = loginUserService.findById(vo.getId());
|
LoginUserVO loginUserVO = loginUserService.findById(vo.getId());
|
||||||
|
|
||||||
LOGGER.info("starting logout {}", loginUserVO.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
|
LOGGER.info("starting logout {}",
|
||||||
|
loginUserVO.getNamaUser() + " at " + DateUtil.getIndonesianStringDate(new Date()));
|
||||||
Integer idPegawai = 0;
|
|
||||||
if (CommonUtil.isNotNullOrEmpty(loginUserVO.getPegawai())){
|
|
||||||
idPegawai = loginUserVO.getPegawai().getId();
|
|
||||||
}
|
|
||||||
|
|
||||||
loggingSystemAsynchronous.saveSignOutLog(loginUserVO.getNamaUser(), idPegawai);
|
|
||||||
// GrantedAuthority authority = new SimpleGrantedAuthority("USER");
|
|
||||||
// String token = tokenAuthenticationService.addAuthentication(httpResponse, new UserAuthentication(
|
|
||||||
// new User(loginUserVO.getNamaUser(), loginUserVO.getKataSandi(), Arrays.asList(authority))));
|
|
||||||
// mapHeaderMessage.put("X-AUTH-SUPERVISOR-TOKEN", token);
|
|
||||||
|
|
||||||
return RestUtil.getJsonResponse(vo, HttpStatus.OK);
|
|
||||||
|
|
||||||
|
|
||||||
// misal call service logout dan seterusnya
|
Integer idPegawai = 0;
|
||||||
// Karena Stateless tidak perlu set " session user " menjadi tidak
|
if (CommonUtil.isNotNullOrEmpty(loginUserVO.getPegawai()))
|
||||||
// aktif, return HttpStatus.OK ke client
|
idPegawai = loginUserVO.getPegawai().getId();
|
||||||
//RestUtil.getJsonHttptatus(HttpStatus.OK);
|
loggingSystemAsynchronous.saveSignOutLog(loginUserVO.getNamaUser(), idPegawai);
|
||||||
|
return RestUtil.getJsonResponse(vo, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user