10 changed files with 694 additions and 1 deletions
@ -0,0 +1,90 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.dto; |
|||
|
|||
import lombok.Data; |
|||
|
|||
import java.io.Serializable; |
|||
import java.util.Date; |
|||
|
|||
|
|||
/** |
|||
* 模块跳转二维码 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2020-10-14 |
|||
*/ |
|||
@Data |
|||
public class ModuleMaCodeDTO implements Serializable { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 主键 |
|||
*/ |
|||
private String id; |
|||
|
|||
/** |
|||
* 模块名 |
|||
*/ |
|||
private String moduleMaCode; |
|||
|
|||
/** |
|||
* 小程序码图片URL |
|||
*/ |
|||
private String codeImageUrl; |
|||
|
|||
|
|||
/** |
|||
* 小程序码APP URL |
|||
*/ |
|||
private String codeAppUrl; |
|||
|
|||
|
|||
|
|||
/** |
|||
* 乐观锁 |
|||
*/ |
|||
private Integer revision; |
|||
|
|||
/** |
|||
* 创建人 |
|||
*/ |
|||
private String createdBy; |
|||
|
|||
/** |
|||
* 创建时间 |
|||
*/ |
|||
private Date createdTime; |
|||
|
|||
/** |
|||
* 更新人 |
|||
*/ |
|||
private String updatedBy; |
|||
|
|||
/** |
|||
* 更新时间 |
|||
*/ |
|||
private Date updatedTime; |
|||
|
|||
/** |
|||
* 删除标记 |
|||
*/ |
|||
private String delFlag; |
|||
|
|||
} |
@ -0,0 +1,106 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.controller; |
|||
|
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ExcelUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.commons.tools.validator.AssertUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; |
|||
import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; |
|||
import com.elink.esua.epdc.dto.ModuleMaCodeDTO; |
|||
import com.elink.esua.epdc.excel.ModuleMaCodeExcel; |
|||
import com.elink.esua.epdc.service.ModuleMaCodeService; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.servlet.http.HttpServletResponse; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
|
|||
/** |
|||
* 模块跳转二维码 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2020-10-14 |
|||
*/ |
|||
@RestController |
|||
@RequestMapping("modulemacode") |
|||
public class ModuleMaCodeController { |
|||
|
|||
@Autowired |
|||
private ModuleMaCodeService moduleMaCodeService; |
|||
|
|||
@GetMapping("page") |
|||
public Result<PageData<ModuleMaCodeDTO>> page(@RequestParam Map<String, Object> params){ |
|||
PageData<ModuleMaCodeDTO> page = moduleMaCodeService.page(params); |
|||
return new Result<PageData<ModuleMaCodeDTO>>().ok(page); |
|||
} |
|||
|
|||
@GetMapping("{id}") |
|||
public Result<ModuleMaCodeDTO> get(@PathVariable("id") String id){ |
|||
ModuleMaCodeDTO data = moduleMaCodeService.get(id); |
|||
return new Result<ModuleMaCodeDTO>().ok(data); |
|||
} |
|||
|
|||
@PostMapping |
|||
public Result save(@RequestBody ModuleMaCodeDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); |
|||
moduleMaCodeService.save(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@PutMapping |
|||
public Result update(@RequestBody ModuleMaCodeDTO dto){ |
|||
//效验数据
|
|||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); |
|||
moduleMaCodeService.update(dto); |
|||
return new Result(); |
|||
} |
|||
|
|||
@DeleteMapping |
|||
public Result delete(@RequestBody String[] ids){ |
|||
//效验数据
|
|||
AssertUtils.isArrayEmpty(ids, "id"); |
|||
moduleMaCodeService.delete(ids); |
|||
return new Result(); |
|||
} |
|||
|
|||
@GetMapping("export") |
|||
public void export(@RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |
|||
List<ModuleMaCodeDTO> list = moduleMaCodeService.list(params); |
|||
ExcelUtils.exportExcelToTarget(response, null, list, ModuleMaCodeExcel.class); |
|||
} |
|||
|
|||
/** |
|||
* @Description 创建模块二维码 |
|||
* @Author songyunpeng |
|||
* @Date 2020/10/14 |
|||
* @Param [dto] |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
**/ |
|||
@PostMapping("create") |
|||
public Result createModuleMaCode(@RequestBody ModuleMaCodeDTO dto) { |
|||
return moduleMaCodeService.createModuleMaCode(dto); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,44 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.dao; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; |
|||
import com.elink.esua.epdc.dto.ModuleMaCodeDTO; |
|||
import com.elink.esua.epdc.entity.ModuleMaCodeEntity; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 模块跳转二维码 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2020-10-14 |
|||
*/ |
|||
@Mapper |
|||
public interface ModuleMaCodeDao extends BaseDao<ModuleMaCodeEntity> { |
|||
/** |
|||
* @Description 分页查询模块二维码列表 |
|||
* @Author songyunpeng |
|||
* @Date 2020/10/14 |
|||
* @Param [params] |
|||
* @return java.util.List<com.elink.esua.epdc.dto.ModuleMaCodeDTO> |
|||
**/ |
|||
List<ModuleMaCodeDTO> selectListModuleMaCode(Map<String, Object> params); |
|||
} |
@ -0,0 +1,54 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.entity; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; |
|||
import lombok.Data; |
|||
import lombok.EqualsAndHashCode; |
|||
|
|||
/** |
|||
* 模块跳转二维码 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2020-10-14 |
|||
*/ |
|||
@Data |
|||
@EqualsAndHashCode(callSuper=false) |
|||
@TableName("epdc_module_ma_code") |
|||
public class ModuleMaCodeEntity extends BaseEpdcEntity { |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
|
|||
/** |
|||
* 模块名 |
|||
*/ |
|||
private String moduleMaCode; |
|||
|
|||
/** |
|||
* 小程序码URL |
|||
*/ |
|||
private String codeImageUrl; |
|||
|
|||
/** |
|||
* 小程序码APP URL |
|||
*/ |
|||
private String codeAppUrl; |
|||
|
|||
|
|||
} |
@ -0,0 +1,62 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.excel; |
|||
|
|||
import cn.afterturn.easypoi.excel.annotation.Excel; |
|||
import lombok.Data; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* 模块跳转二维码 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2020-10-14 |
|||
*/ |
|||
@Data |
|||
public class ModuleMaCodeExcel { |
|||
|
|||
@Excel(name = "主键") |
|||
private String id; |
|||
|
|||
@Excel(name = "模块名") |
|||
private String moduleMaCode; |
|||
|
|||
@Excel(name = "小程序码URL") |
|||
private String codeImageUrl; |
|||
|
|||
@Excel(name = "乐观锁") |
|||
private Integer revision; |
|||
|
|||
@Excel(name = "创建人") |
|||
private String createdBy; |
|||
|
|||
@Excel(name = "创建时间") |
|||
private Date createdTime; |
|||
|
|||
@Excel(name = "更新人") |
|||
private String updatedBy; |
|||
|
|||
@Excel(name = "更新时间") |
|||
private Date updatedTime; |
|||
|
|||
@Excel(name = "删除标记") |
|||
private String delFlag; |
|||
|
|||
|
|||
} |
@ -0,0 +1,105 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.service; |
|||
|
|||
import com.elink.esua.epdc.commons.mybatis.service.BaseService; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dto.ModuleMaCodeDTO; |
|||
import com.elink.esua.epdc.entity.ModuleMaCodeEntity; |
|||
|
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 模块跳转二维码 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2020-10-14 |
|||
*/ |
|||
public interface ModuleMaCodeService extends BaseService<ModuleMaCodeEntity> { |
|||
|
|||
/** |
|||
* 默认分页 |
|||
* |
|||
* @param params |
|||
* @return PageData<ModuleMaCodeDTO> |
|||
* @author generator |
|||
* @date 2020-10-14 |
|||
*/ |
|||
PageData<ModuleMaCodeDTO> page(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 默认查询 |
|||
* |
|||
* @param params |
|||
* @return java.util.List<ModuleMaCodeDTO> |
|||
* @author generator |
|||
* @date 2020-10-14 |
|||
*/ |
|||
List<ModuleMaCodeDTO> list(Map<String, Object> params); |
|||
|
|||
/** |
|||
* 单条查询 |
|||
* |
|||
* @param id |
|||
* @return ModuleMaCodeDTO |
|||
* @author generator |
|||
* @date 2020-10-14 |
|||
*/ |
|||
ModuleMaCodeDTO get(String id); |
|||
|
|||
/** |
|||
* 默认保存 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-10-14 |
|||
*/ |
|||
void save(ModuleMaCodeDTO dto); |
|||
|
|||
/** |
|||
* 默认更新 |
|||
* |
|||
* @param dto |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-10-14 |
|||
*/ |
|||
void update(ModuleMaCodeDTO dto); |
|||
|
|||
/** |
|||
* 批量删除 |
|||
* |
|||
* @param ids |
|||
* @return void |
|||
* @author generator |
|||
* @date 2020-10-14 |
|||
*/ |
|||
void delete(String[] ids); |
|||
|
|||
/** |
|||
* @Description 创建模块二维码 |
|||
* @Author songyunpeng |
|||
* @Date 2020/10/14 |
|||
* @Param [dto] |
|||
* @return com.elink.esua.epdc.commons.tools.utils.Result |
|||
**/ |
|||
Result createModuleMaCode(ModuleMaCodeDTO dto); |
|||
} |
@ -0,0 +1,194 @@ |
|||
/** |
|||
* Copyright 2018 人人开源 https://www.renren.io
|
|||
* <p> |
|||
* This program is free software: you can redistribute it and/or modify |
|||
* it under the terms of the GNU General Public License as published by |
|||
* the Free Software Foundation, either version 3 of the License, or |
|||
* (at your option) any later version. |
|||
* <p> |
|||
* This program is distributed in the hope that it will be useful, |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
* GNU General Public License for more details. |
|||
* <p> |
|||
* You should have received a copy of the GNU General Public License |
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
|
|||
package com.elink.esua.epdc.service.impl; |
|||
|
|||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|||
import com.baomidou.mybatisplus.core.metadata.IPage; |
|||
import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; |
|||
import com.elink.esua.epdc.commons.tools.constant.FieldConstant; |
|||
import com.elink.esua.epdc.commons.tools.constant.NumConstant; |
|||
import com.elink.esua.epdc.commons.tools.exception.RenException; |
|||
import com.elink.esua.epdc.commons.tools.page.PageData; |
|||
import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; |
|||
import com.elink.esua.epdc.commons.tools.utils.Result; |
|||
import com.elink.esua.epdc.dao.ModuleMaCodeDao; |
|||
import com.elink.esua.epdc.dto.ModuleMaCodeDTO; |
|||
import com.elink.esua.epdc.dto.UploadToOssDTO; |
|||
import com.elink.esua.epdc.entity.ModuleMaCodeEntity; |
|||
import com.elink.esua.epdc.feign.OssFeignClient; |
|||
import com.elink.esua.epdc.service.ModuleMaCodeService; |
|||
import com.elink.esua.epdc.utils.WxMaServiceUtils; |
|||
import me.chanjar.weixin.common.error.WxErrorException; |
|||
import org.apache.commons.lang3.StringUtils; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.io.ByteArrayOutputStream; |
|||
import java.io.File; |
|||
import java.io.FileInputStream; |
|||
import java.util.Arrays; |
|||
import java.util.HashMap; |
|||
import java.util.List; |
|||
import java.util.Map; |
|||
|
|||
/** |
|||
* 模块跳转二维码 |
|||
* |
|||
* @author qu qu@elink-cn.com |
|||
* @since v1.0.0 2020-10-14 |
|||
*/ |
|||
@Service |
|||
public class ModuleMaCodeServiceImpl extends BaseServiceImpl<ModuleMaCodeDao, ModuleMaCodeEntity> implements ModuleMaCodeService { |
|||
|
|||
@Autowired |
|||
private WxMaServiceUtils wxMaServiceUtils; |
|||
|
|||
@Autowired |
|||
private OssFeignClient ossFeignClient; |
|||
|
|||
@Override |
|||
public PageData<ModuleMaCodeDTO> page(Map<String, Object> params) { |
|||
IPage<ModuleMaCodeDTO> page = this.getPage(params); |
|||
List<ModuleMaCodeDTO> dtoList = this.baseDao.selectListModuleMaCode(params); |
|||
|
|||
return new PageData<>(dtoList, page.getTotal()); |
|||
} |
|||
|
|||
@Override |
|||
public List<ModuleMaCodeDTO> list(Map<String, Object> params) { |
|||
List<ModuleMaCodeEntity> entityList = baseDao.selectList(getWrapper(params)); |
|||
|
|||
return ConvertUtils.sourceToTarget(entityList, ModuleMaCodeDTO.class); |
|||
} |
|||
|
|||
private QueryWrapper<ModuleMaCodeEntity> getWrapper(Map<String, Object> params){ |
|||
String id = (String)params.get(FieldConstant.ID_HUMP); |
|||
|
|||
QueryWrapper<ModuleMaCodeEntity> wrapper = new QueryWrapper<>(); |
|||
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|||
|
|||
return wrapper; |
|||
} |
|||
|
|||
@Override |
|||
public ModuleMaCodeDTO get(String id) { |
|||
ModuleMaCodeEntity entity = baseDao.selectById(id); |
|||
return ConvertUtils.sourceToTarget(entity, ModuleMaCodeDTO.class); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void save(ModuleMaCodeDTO dto) { |
|||
ModuleMaCodeEntity entity = ConvertUtils.sourceToTarget(dto, ModuleMaCodeEntity.class); |
|||
insert(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void update(ModuleMaCodeDTO dto) { |
|||
ModuleMaCodeEntity entity = ConvertUtils.sourceToTarget(dto, ModuleMaCodeEntity.class); |
|||
updateById(entity); |
|||
} |
|||
|
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public void delete(String[] ids) { |
|||
// 逻辑删除(@TableLogic 注解)
|
|||
baseDao.deleteBatchIds(Arrays.asList(ids)); |
|||
} |
|||
|
|||
|
|||
@Override |
|||
public Result createModuleMaCode(ModuleMaCodeDTO dto) { |
|||
ModuleMaCodeEntity entity = new ModuleMaCodeEntity(); |
|||
entity.setCodeImageUrl(this.createMaCode(dto.getModuleMaCode(), dto.getCodeAppUrl())); |
|||
entity.setModuleMaCode(dto.getModuleMaCode()); |
|||
entity.setCodeAppUrl(dto.getCodeAppUrl()); |
|||
//判断是否存在
|
|||
Map<String,Object> params = new HashMap<>(); |
|||
params.put("MODULE_MA_CODE",dto.getModuleMaCode()); |
|||
List<ModuleMaCodeEntity> moduleMaCodeEntities = baseDao.selectByMap(params); |
|||
if(moduleMaCodeEntities!=null && moduleMaCodeEntities.size()>0){ |
|||
entity.setId(moduleMaCodeEntities.get(0).getId()); |
|||
this.baseDao.updateById(entity); |
|||
} else { |
|||
this.baseDao.insert(entity); |
|||
} |
|||
return new Result(); |
|||
} |
|||
/** |
|||
* 创建微信小程序码,并上传到oss |
|||
* |
|||
* @param param 小程序码的参数 |
|||
* @param pageUrl 小程序码的跳转链接 |
|||
* @return java.lang.String 小程序码的下载抵制 |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/10/22 10:14 |
|||
*/ |
|||
private String createMaCode(String param, String pageUrl) { |
|||
File wxaCodeUnlimit; |
|||
try { |
|||
wxaCodeUnlimit = wxMaServiceUtils.normalWxMaService().getQrcodeService() |
|||
.createWxaCodeUnlimit(param, pageUrl, 1280, true, null, false); |
|||
} catch (WxErrorException e) { |
|||
throw new RenException("请求微信接口失败"); |
|||
} |
|||
|
|||
UploadToOssDTO dto = new UploadToOssDTO(); |
|||
dto.setFileByte(this.fileToByteArray(wxaCodeUnlimit)); |
|||
dto.setFileName(wxaCodeUnlimit.getName()); |
|||
|
|||
Result<String> ossResult = ossFeignClient.uploadFile(dto); |
|||
if (null == ossResult || !ossResult.success() || null == ossResult.getData()) { |
|||
throw new RenException("小程序码上传失败"); |
|||
} |
|||
return ossResult.getData(); |
|||
} |
|||
/** |
|||
* File文件转为byte[] |
|||
* |
|||
* @param file |
|||
* @return byte[] |
|||
* @author work@yujt.net.cn |
|||
* @date 2019/9/19 15:56 |
|||
*/ |
|||
private byte[] fileToByteArray(File file) { |
|||
try { |
|||
//获取输入流
|
|||
FileInputStream fis = new FileInputStream(file); |
|||
//新的 byte 数组输出流,缓冲区容量1024byte
|
|||
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024); |
|||
//缓存
|
|||
byte[] b = new byte[1024]; |
|||
int n; |
|||
while ((n = fis.read(b)) != NumConstant.ONE_NEG) { |
|||
bos.write(b, NumConstant.ZERO, n); |
|||
} |
|||
fis.close(); |
|||
//改变为byte[]
|
|||
byte[] data = bos.toByteArray(); |
|||
bos.close(); |
|||
return data; |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
} |
@ -0,0 +1,35 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
|
|||
<mapper namespace="com.elink.esua.epdc.dao.ModuleMaCodeDao"> |
|||
|
|||
<resultMap type="com.elink.esua.epdc.entity.ModuleMaCodeEntity" id="moduleMaCodeMap"> |
|||
<result property="id" column="ID"/> |
|||
<result property="moduleMaCode" column="MODULE_MA_CODE"/> |
|||
<result property="codeAppUrl" column="CODE_APP_URL"/> |
|||
<result property="codeImageUrl" column="CODE_IMAGE_URL"/> |
|||
<result property="revision" column="REVISION"/> |
|||
<result property="createdBy" column="CREATED_BY"/> |
|||
<result property="createdTime" column="CREATED_TIME"/> |
|||
<result property="updatedBy" column="UPDATED_BY"/> |
|||
<result property="updatedTime" column="UPDATED_TIME"/> |
|||
<result property="delFlag" column="DEL_FLAG"/> |
|||
</resultMap> |
|||
<select id="selectListModuleMaCode" resultType="com.elink.esua.epdc.dto.ModuleMaCodeDTO"> |
|||
select ID, |
|||
MODULE_MA_CODE, |
|||
CODE_IMAGE_URL, |
|||
REVISION, |
|||
CREATED_BY, |
|||
CREATED_TIME, |
|||
UPDATED_BY, |
|||
UPDATED_TIME, |
|||
DEL_FLAG, |
|||
CODE_APP_URL |
|||
from epdc_module_ma_code |
|||
where del_flag ='0' |
|||
<if test="moduleMaCode != null and moduleMaCode != ''">and module_ma_code = #{moduleMaCode}</if> |
|||
</select> |
|||
|
|||
|
|||
</mapper> |
Loading…
Reference in new issue