|
|
@@ -0,0 +1,156 @@
|
|
|
+package com.lc.ibps.components.employee.provider;
|
|
|
+
|
|
|
+import com.lc.ibps.api.base.constants.StateEnum;
|
|
|
+import com.lc.ibps.api.base.query.QueryFilter;
|
|
|
+import com.lc.ibps.base.core.constants.StringPool;
|
|
|
+import com.lc.ibps.base.core.util.AppUtil;
|
|
|
+import com.lc.ibps.base.core.util.BeanUtils;
|
|
|
+import com.lc.ibps.base.saas.token.ITenantTokenService;
|
|
|
+import com.lc.ibps.base.web.context.ContextUtil;
|
|
|
+import com.lc.ibps.cloud.entity.APIPageList;
|
|
|
+import com.lc.ibps.cloud.entity.APIRequest;
|
|
|
+import com.lc.ibps.cloud.entity.APIResult;
|
|
|
+import com.lc.ibps.cloud.provider.GenericProvider;
|
|
|
+import com.lc.ibps.common.file.persistence.entity.AttachmentPo;
|
|
|
+import com.lc.ibps.components.employee.api.ISignInformationService;
|
|
|
+import com.lc.ibps.components.employee.domain.SignInformation;
|
|
|
+import com.lc.ibps.components.employee.persistence.entity.SignInformationPo;
|
|
|
+import com.lc.ibps.components.employee.repository.SignInformationRepository;
|
|
|
+import com.lc.ibps.file.server.api.IUploadService;
|
|
|
+import io.swagger.annotations.*;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.mock.web.MockMultipartFile;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.imageio.ImageIO;
|
|
|
+import java.awt.image.BufferedImage;
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.util.Base64;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 签到信息表 服务类
|
|
|
+ * <pre>
|
|
|
+ * 构建组:ibps-provider-signInformation
|
|
|
+ * 开发公司:深圳市金源信通科技有限公司
|
|
|
+ * 开发人员:codegen
|
|
|
+ * 创建时间:2024-09-19 16:22:01
|
|
|
+ *</pre>
|
|
|
+ */
|
|
|
+@Api(tags = "签到信息表管理", value = "签到信息表数据")
|
|
|
+@Service
|
|
|
+public class SignInformationProvider extends GenericProvider implements ISignInformationService{
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SignInformationRepository signInformationRepository;
|
|
|
+
|
|
|
+ @ApiOperation(value = "签到信息表列表(分页条件查询)数据", notes = "签到信息表列表(分页条件查询)数据")
|
|
|
+ @Override
|
|
|
+ public APIResult<APIPageList<SignInformationPo>> query(
|
|
|
+ @ApiParam(name = "request", value = "传入查询请求json字符串", required = true)
|
|
|
+ @RequestBody(required = true) APIRequest request) {
|
|
|
+ APIResult<APIPageList<SignInformationPo>> result = new APIResult<>();
|
|
|
+ try {
|
|
|
+ QueryFilter queryFilter = getQueryFilter(request);
|
|
|
+ List<SignInformationPo> data = signInformationRepository.query(queryFilter);
|
|
|
+ APIPageList<SignInformationPo> apiPageData = getAPIPageList(data);
|
|
|
+ result.setData(apiPageData);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO ERROR => other error message
|
|
|
+ setExceptionResult(result, StateEnum.ERROR.getCode(), StateEnum.ERROR.getText(), e);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "根据id查询签到信息表", notes = "根据id查询签到信息表")
|
|
|
+ @Override
|
|
|
+ public APIResult<SignInformationPo> get(
|
|
|
+ @ApiParam(name = "id", value = "查询id", required = true)
|
|
|
+ @RequestParam(name = "id", required = true) String id) {
|
|
|
+ APIResult<SignInformationPo> result = new APIResult<>();
|
|
|
+ try {
|
|
|
+ SignInformationPo signInformationPo = signInformationRepository.get(id);
|
|
|
+ result.setData(signInformationPo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ setExceptionResult(result, StateEnum.ERROR.getCode(), StateEnum.ERROR.getText(), e);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "保存", notes = "保存签到信息表信息",
|
|
|
+ extensions = {
|
|
|
+ @Extension(properties = {
|
|
|
+ @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ @Override
|
|
|
+ public APIResult<Void> save(
|
|
|
+ @ApiParam(name = "signInformationPo", value = "签到信息表对象", required = true)
|
|
|
+ @RequestBody(required = true) SignInformationPo signInformationPo) {
|
|
|
+ APIResult<Void> result = new APIResult<Void>();
|
|
|
+ try {
|
|
|
+ logger.info(" com.lc.ibps.components.provider.SignInformationProvider.save()--->signInformationPo: {}", signInformationPo.toString());
|
|
|
+ SignInformation domain = signInformationRepository.newInstance(signInformationPo);
|
|
|
+ if (BeanUtils.isNotEmpty(signInformationPo.getWaiBuRenYuanQ()) && BeanUtils.isNotEmpty(signInformationPo.getRenYuanXingMin())){
|
|
|
+ IUploadService uploadService = AppUtil.getBean(IUploadService.class);
|
|
|
+ String base64 = signInformationPo.getWaiBuRenYuanQ();
|
|
|
+ String fileName = signInformationPo.getRenYuanXingMin()+".png";
|
|
|
+ MultipartFile multipartFile = convertBase64ToMultipartFile(base64,fileName);
|
|
|
+// if (StringUtils.isBlank(ContextUtil.getCurrentAccessToken())) {
|
|
|
+// ITenantTokenService tenantTokenService = AppUtil.getBean(ITenantTokenService.class);
|
|
|
+// String accessToken = tenantTokenService.getAccessToken();
|
|
|
+// ContextUtil.setCurrentAccessToken(accessToken);
|
|
|
+// }
|
|
|
+ APIResult<AttachmentPo> apiResult = uploadService.uploadFileSign(multipartFile);
|
|
|
+ signInformationPo.setKuaiZhao(apiResult.getData().getId());
|
|
|
+ }
|
|
|
+ domain.save();
|
|
|
+ result.setMessage("保存签到信息表成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ setExceptionResult(result, StateEnum.ERROR.getCode(), StateEnum.ERROR.getText(), e);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static MultipartFile convertBase64ToMultipartFile(String base64String,String fileName) throws IOException {
|
|
|
+ byte[] imageBytes = Base64.getDecoder().decode(base64String.split(",")[1]);
|
|
|
+ return new MockMultipartFile("file", fileName, "image/png", imageBytes);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static InputStream convertBase64ToInputStream(String base64String) {
|
|
|
+ if (base64String.contains(",")) {
|
|
|
+ base64String = base64String.substring(base64String.indexOf(",") + 1);
|
|
|
+ }
|
|
|
+ byte[] imageBytes = Base64.getDecoder().decode(base64String);
|
|
|
+ return new ByteArrayInputStream(imageBytes);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "删除", notes = "删除签到信息表",
|
|
|
+ extensions = {
|
|
|
+ @Extension(properties = {
|
|
|
+ @ExtensionProperty(name = "submitCtrl", value = StringPool.Y)
|
|
|
+ })
|
|
|
+ })
|
|
|
+ @Override
|
|
|
+ public APIResult<Void> remove(
|
|
|
+ @ApiParam(name = "ids", value = "签到信息表ID数组", required = true)
|
|
|
+ @RequestParam(name = "ids", required = true) String[] ids) {
|
|
|
+ APIResult<Void> result = new APIResult<Void>();
|
|
|
+ try {
|
|
|
+ SignInformation domain = signInformationRepository.newInstance();
|
|
|
+ domain.deleteByIds(ids);
|
|
|
+ result.setMessage("删除签到信息表成功");
|
|
|
+ } catch (Exception e) {
|
|
|
+ setExceptionResult(result, StateEnum.ERROR.getCode(), StateEnum.ERROR.getText(), e);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|