增加字体
This commit is contained in:
parent
345cad0956
commit
5ea0c5b143
1845
doc/2021-01-06.sql
Normal file
1845
doc/2021-01-06.sql
Normal file
File diff suppressed because one or more lines are too long
@ -21,6 +21,10 @@
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-framework</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.binarywang</groupId>
|
||||
@ -33,6 +37,13 @@
|
||||
<version>${wx-java.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itext7-core</artifactId>
|
||||
<version>${itext7-core.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
@ -8,20 +8,43 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.github.binarywang.wxpay.service.WxPayService;
|
||||
import com.github.binarywang.wxpay.util.SignUtils;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysUser;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.exception.CustomException;
|
||||
import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
|
||||
import com.ruoyi.common.utils.MessageUtils;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.framework.manager.AsyncManager;
|
||||
import com.ruoyi.framework.manager.factory.AsyncFactory;
|
||||
import com.ruoyi.framework.web.service.TokenService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import com.ruoyi.winery.config.wx.WxMiniProperties;
|
||||
import com.ruoyi.winery.domain.winery.WineryMauser;
|
||||
import com.ruoyi.winery.service.IWineryMauserService;
|
||||
|
||||
import com.sun.tools.javac.util.List;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.Authentication;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static com.ruoyi.winery.define.MiniDefine.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author tottimctj
|
||||
@ -49,6 +72,16 @@ public class MiniComponent {
|
||||
private WxPayService wxPayService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
@Resource
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
|
||||
public WxMaJscode2SessionResult login(String code) throws WxErrorException {
|
||||
|
||||
WxMaJscode2SessionResult sessionInfo = wxMaService.getUserService().getSessionInfo(code);
|
||||
@ -70,6 +103,66 @@ public class MiniComponent {
|
||||
return sessionInfo;
|
||||
}
|
||||
|
||||
public AjaxResult registration(String openid, String mobile) {
|
||||
|
||||
|
||||
SysUser user = new SysUser();
|
||||
|
||||
user.setUserName(openid);
|
||||
user.setPhonenumber(mobile);
|
||||
|
||||
user.setNickName(mobile);
|
||||
user.setDeptId(MINI_DEPTID);
|
||||
user.setPassword(MINI_DEFUALT_PASSWORD);
|
||||
user.setRoleIds(new Long[]{MINI_DEFUALT_ROLEID});
|
||||
user.setPostIds(new Long[]{MINI_DEFUALT_POSTID});
|
||||
|
||||
|
||||
if (UserConstants.NOT_UNIQUE.equals(userService.checkUserNameUnique(user.getUserName()))) {
|
||||
return AjaxResult.error("新增用户" + user.getUserName() + "失败,登录账号已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
|
||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||
} else if (StringUtils.isNotEmpty(user.getEmail())
|
||||
&& UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
|
||||
return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||
}
|
||||
user.setCreateBy(MINI_MANAGE_USER);
|
||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||
return userService.insertUser(user) > 0 ? AjaxResult.success(user) : AjaxResult.error();
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序登录
|
||||
*
|
||||
* @param openId
|
||||
* @return
|
||||
*/
|
||||
public String loginByMini(String openId) {
|
||||
// 用户验证
|
||||
Authentication authentication = null;
|
||||
try {
|
||||
// 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
|
||||
authentication = authenticationManager
|
||||
.authenticate(new UsernamePasswordAuthenticationToken(openId, MINI_DEFUALT_PASSWORD));
|
||||
} catch (Exception e) {
|
||||
if (e instanceof BadCredentialsException) {
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(openId, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
|
||||
throw new UserPasswordNotMatchException();
|
||||
} else {
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(openId, Constants.LOGIN_FAIL, e.getMessage()));
|
||||
throw new CustomException(e.getMessage());
|
||||
}
|
||||
}
|
||||
AsyncManager.me().execute(AsyncFactory.recordLogininfor(openId, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
|
||||
LoginUser loginUser = (LoginUser) authentication.getPrincipal();
|
||||
// 生成token
|
||||
return tokenService.createToken(loginUser);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取手机号
|
||||
*
|
||||
|
@ -50,7 +50,6 @@ public class GoodsMainController extends BaseController {
|
||||
startPage();
|
||||
LambdaQueryWrapper<GoodsMain> lqw = Wrappers.lambdaQuery(goodsMain);
|
||||
|
||||
|
||||
lqw.eq(GoodsMain::getDeptId, getDeptId(token));
|
||||
|
||||
if (StringUtils.isNotBlank(goodsMain.getGoodsName())) {
|
||||
|
@ -5,8 +5,10 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.framework.web.service.SysLoginService;
|
||||
import com.ruoyi.winery.component.MiniComponent;
|
||||
import com.ruoyi.winery.domain.winery.WineryCompanyRecord;
|
||||
import com.ruoyi.winery.enums.IrrigationTypeEnum;
|
||||
@ -38,6 +40,9 @@ public class MiniController {
|
||||
IWineryCompanyRecordService recordWineryService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private SysLoginService loginService;
|
||||
|
||||
/**
|
||||
* 通过微信api授权获取手机号
|
||||
*
|
||||
@ -53,7 +58,6 @@ public class MiniController {
|
||||
if (StrUtil.isBlank(mobile)) {
|
||||
return AjaxResult.error("获取失败!");
|
||||
}
|
||||
|
||||
JSONObject rsp = new JSONObject();
|
||||
rsp.set("mobile", mobile);
|
||||
|
||||
@ -61,8 +65,29 @@ public class MiniController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过微信api授权获取手机号并注册
|
||||
*
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@Log(title = "发送小程序手机号码并注册", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/registrationByMiniMobile")
|
||||
AjaxResult postMobileRegistration(@RequestBody JSONObject json) {
|
||||
|
||||
String mobile = miniComponent.getMobile(json);
|
||||
if (StrUtil.isBlank(mobile)) {
|
||||
return AjaxResult.error("获取失败!");
|
||||
}
|
||||
JSONObject rsp = new JSONObject();
|
||||
rsp.set("mobile", mobile);
|
||||
String openid = json.getStr("openid");
|
||||
return miniComponent.registration(openid, mobile);
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "微信小程序登录", businessType = BusinessType.OTHER)
|
||||
@GetMapping("/login")
|
||||
@GetMapping("/getSession")
|
||||
public AjaxResult getSession(@RequestParam("code") String code) throws WxErrorException {
|
||||
|
||||
WxMaJscode2SessionResult sessionInfo = miniComponent.login(code);
|
||||
@ -75,6 +100,17 @@ public class MiniController {
|
||||
}
|
||||
|
||||
|
||||
@Log(title = "微信小程序登录系统", businessType = BusinessType.OTHER)
|
||||
@PostMapping("/loginByMini")
|
||||
public AjaxResult loginByMini(@RequestBody JSONObject json) {
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// 生成令牌
|
||||
String token = miniComponent.loginByMini(json.getStr("openid"));
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/postForm")
|
||||
AjaxResult postForm(@RequestBody JSONObject json) {
|
||||
|
||||
@ -86,7 +122,6 @@ public class MiniController {
|
||||
if (old != null) {
|
||||
record.setId(old.getId());
|
||||
}
|
||||
|
||||
return AjaxResult.success(recordWineryService.saveOrUpdate(record));
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,97 @@
|
||||
package com.ruoyi.winery.controller.mini;
|
||||
|
||||
import com.itextpdf.io.font.FontProgram;
|
||||
import com.itextpdf.io.font.FontProgramFactory;
|
||||
import com.itextpdf.io.font.PdfEncodings;
|
||||
import com.itextpdf.io.image.ImageDataFactory;
|
||||
import com.itextpdf.kernel.font.PdfFont;
|
||||
import com.itextpdf.kernel.font.PdfFontFactory;
|
||||
import com.itextpdf.kernel.geom.PageSize;
|
||||
import com.itextpdf.kernel.geom.Rectangle;
|
||||
import com.itextpdf.kernel.pdf.PdfDocument;
|
||||
import com.itextpdf.kernel.pdf.PdfWriter;
|
||||
import com.itextpdf.kernel.pdf.xobject.PdfImageXObject;
|
||||
import com.itextpdf.layout.Document;
|
||||
import com.itextpdf.layout.element.Paragraph;
|
||||
import com.itextpdf.layout.element.Text;
|
||||
import com.itextpdf.layout.property.BackgroundImage;
|
||||
import com.itextpdf.layout.property.TextAlignment;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
|
||||
/**
|
||||
* @author tottimctj
|
||||
* @since 2020-11-10
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/winery/test")
|
||||
@Slf4j
|
||||
public class TestController {
|
||||
|
||||
public static final String REGULAR =
|
||||
"classpath:/fonts/PingFang_Heavy.ttf";
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
FontProgram fontProgram =
|
||||
FontProgramFactory.createFont(REGULAR);
|
||||
|
||||
|
||||
String path = "/Users/tottimctj/Downloads/temp.pdf";
|
||||
|
||||
PdfFont font = PdfFontFactory.createFont("STSongStd-Light", "UniGB-UCS2-H", false);
|
||||
PdfFont font2 = PdfFontFactory.createFont(
|
||||
fontProgram, PdfEncodings.IDENTITY_H, true);
|
||||
|
||||
PdfWriter writer = new PdfWriter(new FileOutputStream(new File(path)));
|
||||
PdfDocument pdf = new PdfDocument(writer);
|
||||
Document document = new Document(pdf, new PageSize(500f,505f));
|
||||
document.setMargins(0, 0, 0, 0);
|
||||
Paragraph p = new Paragraph();
|
||||
p.setMarginTop(0);
|
||||
p.setHeight(500);
|
||||
p.setWidth(500);
|
||||
p.setFontSize(25);
|
||||
// Text text1 = new Text("字体1希望软件!").setFont(font);
|
||||
//
|
||||
// text1.setTextAlignment(TextAlignment.CENTER);
|
||||
// text1.setRelativePosition(200, 200, 200, 200);
|
||||
// p.add(text1);
|
||||
|
||||
Text text2 = new Text("字体2希望软件!").setFont(font2);
|
||||
text2.setTextAlignment(TextAlignment.CENTER);
|
||||
text2.setRelativePosition(0, 200, 0, 0);
|
||||
p.add(text2);
|
||||
|
||||
// p.setBorder(new SolidBorder(DeviceGray.BLACK,0.5f));//边框
|
||||
// p.setBackgroundColor(ColorConstants.GREEN);//绿色你懂的
|
||||
|
||||
|
||||
// Image image = new Image(ImageDataFactory.create("https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=28918940,1444141489&fm=26&gp=0.jpg"));
|
||||
// image.setHeight(300);
|
||||
// image.setWidth(200);
|
||||
// BackgroundSize backgroundSize = new BackgroundSize();
|
||||
|
||||
|
||||
PdfImageXObject imageXObject = new PdfImageXObject(ImageDataFactory.create("https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=28918940,1444141489&fm=26&gp=0.jpg"));
|
||||
|
||||
BackgroundImage backgroundImage = new BackgroundImage(imageXObject);
|
||||
p.setBackgroundImage(backgroundImage);
|
||||
|
||||
|
||||
document.add(p);
|
||||
|
||||
|
||||
document.close();
|
||||
writer.close();
|
||||
pdf.close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.ruoyi.winery.define;
|
||||
|
||||
/**
|
||||
* @author tottimctj
|
||||
* @since 2021-01-07
|
||||
*/
|
||||
public class MiniDefine {
|
||||
|
||||
public static final String MINI_MANAGE_USER = "admin";
|
||||
|
||||
public static final Long MINI_DEPTID = 100L;
|
||||
|
||||
public static final String MINI_DEFUALT_PASSWORD = "Xiao4rHospSoft";
|
||||
|
||||
public static final Long MINI_DEFUALT_ROLEID = 101L;
|
||||
|
||||
public static final Long MINI_DEFUALT_POSTID = 5L;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.ruoyi.winery.domain.mini;
|
||||
|
||||
/**
|
||||
* @author tottimctj
|
||||
* @since 2021-01-07
|
||||
*/
|
||||
public class MiniLoginBody {
|
||||
|
||||
String openid;
|
||||
}
|
@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="state" column="remark" />
|
||||
</resultMap>
|
||||
|
||||
|
10
pom.xml
10
pom.xml
@ -36,6 +36,7 @@
|
||||
<hutool.version>5.4.0</hutool.version>
|
||||
<wx-java.version>4.0.0</wx-java.version>
|
||||
<cos-java.version>5.6.34</cos-java.version>
|
||||
<itext7-core.version>7.1.13</itext7-core.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖声明 -->
|
||||
@ -229,6 +230,15 @@
|
||||
<version>${ruoyi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- pdf编辑生成 -->
|
||||
<dependency>
|
||||
<groupId>com.itextpdf</groupId>
|
||||
<artifactId>itext7-core</artifactId>
|
||||
<version>${itext7-core.version}</version>
|
||||
<type>pom</type>
|
||||
</dependency>
|
||||
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
BIN
ruoyi-admin/src/main/resources/fonts/FZBIAOYSJW.TTF
Normal file
BIN
ruoyi-admin/src/main/resources/fonts/FZBIAOYSJW.TTF
Normal file
Binary file not shown.
BIN
ruoyi-admin/src/main/resources/fonts/FZCYSJW.TTF
Normal file
BIN
ruoyi-admin/src/main/resources/fonts/FZCYSJW.TTF
Normal file
Binary file not shown.
BIN
ruoyi-admin/src/main/resources/fonts/PingFang_Bold.ttf
Normal file
BIN
ruoyi-admin/src/main/resources/fonts/PingFang_Bold.ttf
Normal file
Binary file not shown.
BIN
ruoyi-admin/src/main/resources/fonts/PingFang_Heavy.ttf
Normal file
BIN
ruoyi-admin/src/main/resources/fonts/PingFang_Heavy.ttf
Normal file
Binary file not shown.
BIN
ruoyi-admin/src/main/resources/fonts/PingFang_Medium.ttf
Normal file
BIN
ruoyi-admin/src/main/resources/fonts/PingFang_Medium.ttf
Normal file
Binary file not shown.
BIN
ruoyi-admin/src/main/resources/fonts/PingFang_Regular.ttf
Normal file
BIN
ruoyi-admin/src/main/resources/fonts/PingFang_Regular.ttf
Normal file
Binary file not shown.
@ -21,7 +21,12 @@
|
||||
</el-form-item>
|
||||
<el-form-item label="商品类型" prop="goodsType">
|
||||
<el-select v-model="queryParams.goodsType" placeholder="请选择商品类型" clearable size="small">
|
||||
<el-option label="请选择字典生成" value=""/>
|
||||
<el-option
|
||||
v-for="dict in goodsTypeOptions"
|
||||
:key="dict.dictValue"
|
||||
:label="dict.dictLabel"
|
||||
:value="dict.dictValue"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
@ -90,7 +95,7 @@
|
||||
<el-table-column label="商品ID" align="center" prop="id" v-if="false"/>
|
||||
<el-table-column label="商品名称" align="center" prop="goodsName"/>
|
||||
<el-table-column label="商品简称" align="center" prop="goodsAlias"/>
|
||||
<el-table-column label="商品类型" align="center" prop="goodsType"/>
|
||||
<el-table-column label="商品类型" align="center" prop="goodsType" :formatter="goodsTypeFormat" width="100px"/>
|
||||
<!-- <el-table-column label="关联规格" align="center" prop="goodsSpec"/>-->
|
||||
<!-- <el-table-column label="商品说明" align="center" prop="goodsDesc"/>-->
|
||||
<el-table-column label="商品封面" align="center" prop="goodsFaceImg">
|
||||
@ -239,6 +244,8 @@ export default {
|
||||
open: false,
|
||||
// 状态字典
|
||||
stateOptions: [],
|
||||
// 商品类型字典
|
||||
goodsTypeOptions: [],
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
@ -274,6 +281,10 @@ export default {
|
||||
this.getDicts("sys_release_status").then(response => {
|
||||
this.stateOptions = response.data;
|
||||
});
|
||||
|
||||
this.getDicts("goods_type").then(response => {
|
||||
this.goodsTypeOptions = response.data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
inputGoodsFaceImg(fileName) {
|
||||
@ -287,6 +298,11 @@ export default {
|
||||
stateFormat(row, column) {
|
||||
return this.selectDictLabel(this.stateOptions, row.state);
|
||||
},
|
||||
|
||||
// 商品类型字典翻译
|
||||
goodsTypeFormat(row, column) {
|
||||
return this.selectDictLabel(this.goodsTypeOptions, row.goodsType);
|
||||
},
|
||||
/** 查询商品信息列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
|
@ -138,7 +138,7 @@
|
||||
<el-table-column label="用户编号" align="center" prop="userId" />
|
||||
<el-table-column label="用户名称" align="center" prop="userName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="用户昵称" align="center" prop="nickName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="部门" align="center" prop="dept.deptName" :show-overflow-tooltip="true" />
|
||||
<el-table-column label="部门" align="center" prop="dept.deptName" :show-overflow-tooltip="true" width="100px" />
|
||||
<el-table-column label="手机号码" align="center" prop="phonenumber" width="120" />
|
||||
<el-table-column label="状态" align="center">
|
||||
<template slot-scope="scope">
|
||||
@ -657,4 +657,4 @@ export default {
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
</script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user