use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.
the class AccreditManageResource method deleteAccredit.
@Path("accredits/{id}")
@DELETE
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<AccreditVO> deleteAccredit(@QueryParam("userCode") String userCode, @PathParam("id") String id) {
if (StringUtils.isBlank(userCode) || StringUtils.isBlank(id)) {
return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_ILLEGAL_PARAM));
}
sessionDataStore.setCurrentUserCode(userCode);
try {
Accredit accredit = accreditManageService.closeAccredit(id);
AccreditVO vo = AccreditVO.transform(accredit, true);
sessionDataStore.removeCurrentUserCode();
return new DataVO<>(vo);
} catch (UserInterfaceException ex) {
return new DataVO<>(ex);
} catch (Exception ex) {
if (logger.isErrorEnabled()) {
logger.error("Delete accredit fail.", ex);
}
return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
}
}
use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.
the class AccreditManageResource method accredits.
@Path("accredits")
@POST
@AuthenticateAround(returnValueClass = PaginationDataVO.class)
public PaginationDataVO<List<AccreditVO>> accredits(Pagination pagination) {
if (pagination == null) {
pagination = new Pagination();
}
try {
List<Accredit> accredits = accessor.list(pagination, Accredit.class);
List<AccreditVO> list = AccreditVO.transform(accredits);
return new PaginationDataVO<>(pagination, list);
} catch (UserInterfaceException ex) {
return new PaginationDataVO<>(ex);
} catch (Exception ex) {
if (logger.isErrorEnabled()) {
logger.error("List accredits fail.", ex);
}
return new PaginationDataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
}
}
use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.
the class AccreditManageResource method newAccredit.
@Path("accredits/new")
@POST
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<AccreditVO> newAccredit(@QueryParam("userCode") String userCode, AccreditInfoVO accreditInfoVO) {
sessionDataStore.setCurrentUserCode(userCode);
try {
Accredit accredit = accreditManageService.accredit(accreditInfoVO.getAccreditInfo());
AccreditVO vo = AccreditVO.transform(accredit, true);
sessionDataStore.removeCurrentUserCode();
return new DataVO<>(vo);
} catch (UserInterfaceException ex) {
return new DataVO<>(ex);
} catch (Exception ex) {
if (logger.isErrorEnabled()) {
logger.error("Create accredit fail.", ex);
}
return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
}
}
use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.
the class DepartmentManageResource method deleteDepartment.
@Path("departments/{id}")
@DELETE
@AuthenticateAround(returnValueClass = DataVO.class)
public DataVO<DepartmentVO> deleteDepartment(@QueryParam("userCode") String userCode, @PathParam("id") String id) {
sessionDataStore.setCurrentUserCode(userCode);
try {
Department department = accessor.remove(id, Department.class);
DepartmentVO vo = DepartmentVO.transform(department, true);
sessionDataStore.removeCurrentUserCode();
return new DataVO<>(vo);
} catch (UserInterfaceException ex) {
return new DataVO<>(ex);
} catch (Exception ex) {
if (logger.isErrorEnabled()) {
logger.error("Delete department fail.", ex);
}
return new DataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
}
}
use of org.mx.comps.jwt.AuthenticateAround in project main by JohnPeng739.
the class DepartmentManageResource method departments.
@Path("departments")
@POST
@AuthenticateAround(returnValueClass = PaginationDataVO.class)
public PaginationDataVO<List<DepartmentVO>> departments(Pagination pagination) {
if (pagination == null) {
pagination = new Pagination();
}
try {
List<Department> departments = accessor.list(pagination, Department.class);
List<DepartmentVO> vos = DepartmentVO.transform(departments);
return new PaginationDataVO<>(pagination, vos);
} catch (UserInterfaceException ex) {
return new PaginationDataVO<>(ex);
} catch (Exception ex) {
if (logger.isErrorEnabled()) {
logger.error("List departments fail.", ex);
}
return new PaginationDataVO<>(new UserInterfaceSystemErrorException(UserInterfaceSystemErrorException.SystemErrors.SYSTEM_OTHER_FAIL));
}
}
Aggregations