Merge branch 'master' of http://120.76.84.145:10101/gitblit/r/java/mx_charging_pile
# Conflicts:
# ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/controller/TAppUserController.java
# ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/TIntegralRuleController.java
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ÇåÀí¹¤³ÌtargetÉú³É·¾¶¡£ |
| | | echo. |
| | | |
| | | %~d0 |
| | | cd %~dp0 |
| | | |
| | | cd .. |
| | | call mvn clean |
| | | |
| | | pause |
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ´ò°üWeb¹¤³Ì£¬Éú³Éwar/jar°üÎļþ¡£ |
| | | echo. |
| | | |
| | | %~d0 |
| | | cd %~dp0 |
| | | |
| | | cd .. |
| | | call mvn clean package -Dmaven.test.skip=true |
| | | |
| | | pause |
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ʹÓÃJarÃüÁîÔËÐÐAuth¹¤³Ì¡£ |
| | | echo. |
| | | |
| | | cd %~dp0 |
| | | cd ../ruoyi-auth/target |
| | | |
| | | set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m |
| | | |
| | | java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-auth.jar |
| | | |
| | | cd bin |
| | | pause |
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ʹÓÃJarÃüÁîÔËÐÐGateway¹¤³Ì¡£ |
| | | echo. |
| | | |
| | | cd %~dp0 |
| | | cd ../ruoyi-gateway/target |
| | | |
| | | set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m |
| | | |
| | | java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-gateway.jar |
| | | |
| | | cd bin |
| | | pause |
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ʹÓÃJarÃüÁîÔËÐÐModules-File¹¤³Ì¡£ |
| | | echo. |
| | | |
| | | cd %~dp0 |
| | | cd ../ruoyi-modules/ruoyi-file/target |
| | | |
| | | set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m |
| | | |
| | | java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-modules-file.jar |
| | | |
| | | cd bin |
| | | pause |
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ʹÓÃJarÃüÁîÔËÐÐModules-Gen¹¤³Ì¡£ |
| | | echo. |
| | | |
| | | cd %~dp0 |
| | | cd ../ruoyi-modules/ruoyi-gen/target |
| | | |
| | | set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m |
| | | |
| | | java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-modules-gen.jar |
| | | |
| | | cd bin |
| | | pause |
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ʹÓÃJarÃüÁîÔËÐÐModules-Job¹¤³Ì¡£ |
| | | echo. |
| | | |
| | | cd %~dp0 |
| | | cd ../ruoyi-modules/ruoyi-job/target |
| | | |
| | | set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m |
| | | |
| | | java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-modules-job.jar |
| | | |
| | | cd bin |
| | | pause |
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ʹÓÃJarÃüÁîÔËÐÐModules-System¹¤³Ì¡£ |
| | | echo. |
| | | |
| | | cd %~dp0 |
| | | cd ../ruoyi-modules/ruoyi-system/target |
| | | |
| | | set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m |
| | | |
| | | java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-modules-system.jar |
| | | |
| | | cd bin |
| | | pause |
New file |
| | |
| | | @echo off |
| | | echo. |
| | | echo [ÐÅÏ¢] ʹÓÃJarÃüÁîÔËÐÐMonitor¹¤³Ì¡£ |
| | | echo. |
| | | |
| | | cd %~dp0 |
| | | cd ../ruoyi-visual/ruoyi-monitor/target |
| | | |
| | | set JAVA_OPTS=-Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m |
| | | |
| | | java -Dfile.encoding=utf-8 %JAVA_OPTS% -jar ruoyi-visual-monitor.jar |
| | | |
| | | cd bin |
| | | pause |
| | |
| | | import com.ruoyi.other.api.factory.RoleSiteFallbackFactory; |
| | | import com.ruoyi.other.api.factory.UserSiteFallbackFactory; |
| | | import org.springframework.cloud.openfeign.FeignClient; |
| | | import org.springframework.web.bind.annotation.DeleteMapping; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | * @param roleId |
| | | * @return |
| | | */ |
| | | @PostMapping("/t-role-site/getSiteIds") |
| | | R<List<Integer>> getSiteIds(Long roleId); |
| | | @PostMapping("/t-role-site/getSiteIds/{roleId}") |
| | | R<List<Integer>> getSiteIds(@PathVariable("roleId") Long roleId); |
| | | |
| | | |
| | | /** |
| | |
| | | @TableField("role_key") |
| | | private String roleKey; |
| | | |
| | | /** 角色排序 */ |
| | | @Excel(name = "角色排序") |
| | | @TableField("role_sort") |
| | | private Integer roleSort; |
| | | |
| | | /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */ |
| | | @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限") |
| | | @TableField("data_scope") |
| | | private String dataScope; |
| | | |
| | | /** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */ |
| | | @TableField("menu_check_strictly") |
| | | private boolean menuCheckStrictly; |
| | | |
| | | /** 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) */ |
| | | @TableField("dept_check_strictly") |
| | | private boolean deptCheckStrictly; |
| | | |
| | | /** 角色状态(0正常 1停用) */ |
| | | @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用") |
| | |
| | | this.roleKey = roleKey; |
| | | } |
| | | |
| | | @NotNull(message = "显示顺序不能为空") |
| | | public Integer getRoleSort() |
| | | { |
| | | return roleSort; |
| | | } |
| | | |
| | | public void setRoleSort(Integer roleSort) |
| | | { |
| | | this.roleSort = roleSort; |
| | | } |
| | | |
| | | public String getDataScope() |
| | | { |
| | | return dataScope; |
| | |
| | | public void setDataScope(String dataScope) |
| | | { |
| | | this.dataScope = dataScope; |
| | | } |
| | | |
| | | public boolean isMenuCheckStrictly() |
| | | { |
| | | return menuCheckStrictly; |
| | | } |
| | | |
| | | public void setMenuCheckStrictly(boolean menuCheckStrictly) |
| | | { |
| | | this.menuCheckStrictly = menuCheckStrictly; |
| | | } |
| | | |
| | | public boolean isDeptCheckStrictly() |
| | | { |
| | | return deptCheckStrictly; |
| | | } |
| | | |
| | | public void setDeptCheckStrictly(boolean deptCheckStrictly) |
| | | { |
| | | this.deptCheckStrictly = deptCheckStrictly; |
| | | } |
| | | |
| | | public String getStatus() |
| | |
| | | .append("roleId", getRoleId()) |
| | | .append("roleName", getRoleName()) |
| | | .append("roleKey", getRoleKey()) |
| | | .append("roleSort", getRoleSort()) |
| | | .append("dataScope", getDataScope()) |
| | | .append("menuCheckStrictly", isMenuCheckStrictly()) |
| | | .append("deptCheckStrictly", isDeptCheckStrictly()) |
| | | .append("status", getStatus()) |
| | | .append("delFlag", getDelFlag()) |
| | | .append("createBy", getCreateBy()) |
| | |
| | | import java.util.List; |
| | | import javax.validation.constraints.*; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.fasterxml.jackson.annotation.JsonFormat; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.apache.commons.lang3.builder.ToStringBuilder; |
| | |
| | | |
| | | /** 用户ID */ |
| | | @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号") |
| | | @TableField("user_id") |
| | | @TableId(value = "user_id", type = IdType.AUTO) |
| | | private Long userId; |
| | | |
| | | /** 部门ID */ |
| | |
| | | private Long userId; |
| | | |
| | | /** |
| | | * 用户名 |
| | | * 用户手机号 |
| | | */ |
| | | private String phone; |
| | | /** |
| | |
| | | * 登录IP地址 |
| | | */ |
| | | private String ipaddr; |
| | | /** |
| | | * 头像 |
| | | */ |
| | | private String avatar; |
| | | /** |
| | | * 地址 |
| | | */ |
| | | private String address; |
| | | } |
New file |
| | |
| | | package com.ruoyi.system.api.model; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import com.ruoyi.common.core.web.domain.BasePojo; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import lombok.EqualsAndHashCode; |
| | | |
| | | import java.time.LocalDateTime; |
| | | |
| | | /** |
| | | * <p> |
| | | * |
| | | * </p> |
| | | * |
| | | * @author luodangjia |
| | | * @since 2024-08-06 |
| | | */ |
| | | @Data |
| | | public class TAppUserLoginInfo extends BasePojo { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | private Long id; |
| | | |
| | | @ApiModelProperty(value = "用户") |
| | | private String name; |
| | | |
| | | @ApiModelProperty(value = "手机号") |
| | | private String phone; |
| | | |
| | | @ApiModelProperty(value = "头像") |
| | | private String avatar; |
| | | |
| | | @ApiModelProperty(value = "会员id") |
| | | private Integer vipId; |
| | | |
| | | @ApiModelProperty(value = "会员到期时间") |
| | | private LocalDateTime vipEndTime; |
| | | |
| | | @ApiModelProperty(value = "单位id") |
| | | private Integer companyId; |
| | | |
| | | @ApiModelProperty(value = "身份证号") |
| | | private String idCard; |
| | | |
| | | @ApiModelProperty(value = "认证状态(0=否,1=是)") |
| | | private Integer authStatus; |
| | | |
| | | @ApiModelProperty(value = "微信openid") |
| | | private String wxOpenid; |
| | | |
| | | @ApiModelProperty(value = "支付宝openid") |
| | | private String aliOpenid; |
| | | |
| | | @ApiModelProperty(value = "积分") |
| | | private Integer points; |
| | | |
| | | @ApiModelProperty(value = "省名称") |
| | | private String province; |
| | | |
| | | @ApiModelProperty(value = "省区划代码") |
| | | private String provinceCode; |
| | | |
| | | @ApiModelProperty(value = "市名称") |
| | | private String city; |
| | | |
| | | @ApiModelProperty(value = "市区划代码") |
| | | private String cityCode; |
| | | |
| | | @ApiModelProperty(value = "状态(1=正常,2=冻结,3=注销)") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value = "最后一次登录时间") |
| | | private LocalDateTime lastLoginTime; |
| | | |
| | | } |
| | |
| | | enabled: true |
| | | application-id: ${spring.application.name} |
| | | tx-service-group: seata_tx_group #此处配置自定义的seata事务分组名称 |
| | | enable-auto-data-source-proxy: true #开启数据库代理 |
| | | enable-auto-data-source-proxy: false #关闭数据库代理 |
| | | service: |
| | | vgroup-mapping: |
| | | seata_tx_group: default |
| | |
| | | * @return |
| | | */ |
| | | private boolean authSign(JSONObject jsonStr, String sign, String nonce_str) { |
| | | System.err.println("请求签名:" + sign); |
| | | String signUrlEncode = localSignUrl(jsonStr, nonce_str); |
| | | signUrlEncode = signUrlEncode.replaceAll("& #40;", "\\(") |
| | | .replaceAll("& #41;", "\\)"); |
| | | if(sign.equals(signUrlEncode)){ |
| | | return true; |
| | | } |
| | | |
| | | System.err.println("签名值:" + signUrlEncode); |
| | | return false; |
| | | } |
| | |
| | | </dependency> |
| | | |
| | | <!-- RuoYi Common DataSource --> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | | <artifactId>ruoyi-common-datasource</artifactId> |
| | | </dependency> |
| | | <!--<dependency>--> |
| | | <!--<groupId>com.ruoyi</groupId>--> |
| | | <!--<artifactId>ruoyi-common-datasource</artifactId>--> |
| | | <!--</dependency>--> |
| | | |
| | | <!-- RuoYi Common DataScope --> |
| | | <dependency> |
| | |
| | | for (SysRole record : page.getRecords()) { |
| | | List<Integer> data = roleSiteClient.getSiteIds(record.getRoleId()).getData(); |
| | | List<Site> sites = siteClient.getSiteByIds(data).getData(); |
| | | List<String> collect = sites.stream().map(Site::getName).collect(Collectors.toList()); |
| | | record.setSiteNames(collect); |
| | | if(null != sites){ |
| | | List<String> collect = sites.stream().map(Site::getName).collect(Collectors.toList()); |
| | | record.setSiteNames(collect); |
| | | } |
| | | } |
| | | return AjaxResult.success(page); |
| | | } |
| | |
| | | @PostMapping("/addSysUser") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R addSysUser(@RequestBody SysUser user){ |
| | | user.setUserName(user.getPhonenumber()); |
| | | if(StringUtils.isEmpty(user.getUserName())){ |
| | | user.setUserName(user.getPhonenumber()); |
| | | } |
| | | if(!org.springframework.util.StringUtils.hasLength(user.getNickName())){ |
| | | user.setNickName(user.getPhonenumber()); |
| | | } |
| | |
| | | } |
| | | user.setCreateBy(SecurityUtils.getUsername()); |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | user.setRoleType(1); |
| | | if(null == user.getRoleType()){ |
| | | user.setRoleType(1); |
| | | } |
| | | userService.insertUser(user); |
| | | SysUserRole sysUserRole = new SysUserRole(); |
| | | sysUserRole.setRoleId(user.getRoleId()); |
| | |
| | | package com.ruoyi.system.mapper; |
| | | |
| | | import java.util.List; |
| | | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.ruoyi.system.api.domain.SysOperLog; |
| | | |
| | | /** |
| | | * 操作日志 数据层 |
| | | * |
| | | * |
| | | * @author ruoyi |
| | | */ |
| | | public interface SysOperLogMapper |
| | | { |
| | | public interface SysOperLogMapper extends BaseMapper<SysOperLog> { |
| | | /** |
| | | * 新增操作日志 |
| | | * |
| | | * |
| | | * @param operLog 操作日志对象 |
| | | */ |
| | | public int insertOperlog(SysOperLog operLog); |
| | | |
| | | /** |
| | | * 查询系统操作日志集合 |
| | | * |
| | | * |
| | | * @param operLog 操作日志对象 |
| | | * @return 操作日志集合 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 批量删除系统操作日志 |
| | | * |
| | | * |
| | | * @param operIds 需要删除的操作日志ID |
| | | * @return 结果 |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 查询操作日志详细 |
| | | * |
| | | * |
| | | * @param operId 操作ID |
| | | * @return 操作日志对象 |
| | | */ |
| | |
| | | public List<Long> selectDeptListByRoleId(Long roleId) |
| | | { |
| | | SysRole role = roleMapper.selectRoleById(roleId); |
| | | return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); |
| | | return deptMapper.selectDeptListByRoleId(roleId, false); |
| | | } |
| | | |
| | | /** |
| | |
| | | public List<Long> selectMenuListByRoleId(Long roleId) |
| | | { |
| | | SysRole role = roleMapper.selectRoleById(roleId); |
| | | return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly()); |
| | | return menuMapper.selectMenuListByRoleId(roleId, false); |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.system.mapper.SysOperLogMapper; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.system.api.domain.SysOperLog; |
| | | import com.ruoyi.system.service.ISysOperLogService; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * 操作日志 服务层处理 |
| | |
| | | * @author ruoyi |
| | | */ |
| | | @Service |
| | | public class SysOperLogServiceImpl implements ISysOperLogService { |
| | | @Autowired |
| | | public class SysOperLogServiceImpl extends ServiceImpl<SysOperLogMapper, SysOperLog> implements ISysOperLogService { |
| | | |
| | | |
| | | @Resource |
| | | private SysOperLogMapper operLogMapper; |
| | | |
| | | /** |
| | |
| | | @Override |
| | | public void cleanOperLog() { |
| | | operLogMapper.cleanOperLog(); |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveBatch(Collection<SysOperLog> entityList, int batchSize) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveOrUpdateBatch(Collection<SysOperLog> entityList, int batchSize) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean updateBatchById(Collection<SysOperLog> entityList, int batchSize) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public boolean saveOrUpdate(SysOperLog entity) { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public SysOperLog getOne(Wrapper<SysOperLog> queryWrapper, boolean throwEx) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> getMap(Wrapper<SysOperLog> queryWrapper) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public <V> V getObj(Wrapper<SysOperLog> queryWrapper, Function<? super Object, V> mapper) { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public BaseMapper<SysOperLog> getBaseMapper() { |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public Class<SysOperLog> getEntityClass() { |
| | | return null; |
| | | } |
| | | } |
| | |
| | | enabled: true |
| | | application-id: ${spring.application.name} |
| | | tx-service-group: seata_tx_group #此处配置自定义的seata事务分组名称 |
| | | enable-auto-data-source-proxy: true #开启数据库代理 |
| | | enable-auto-data-source-proxy: false #关闭数据库代理 |
| | | service: |
| | | vgroup-mapping: |
| | | seata_tx_group: default |
| | |
| | | <select id="getSysRoleByIds" resultMap="SysRoleResult"> |
| | | <include refid="selectRoleVo"/> |
| | | <if test="null != ids and ids.size() > 0"> |
| | | where r.id in |
| | | where r.role_id in |
| | | <foreach collection="ids" item="item" index="index" separator="," open="(" close=")"> |
| | | #{item} |
| | | </foreach> |
| | |
| | | <scope>compile</scope> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alipay.sdk</groupId> |
| | | <artifactId>alipay-sdk-java</artifactId> |
| | | <version>4.38.10.ALL</version> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | <build> |
New file |
| | |
| | | package com.ruoyi.account.ali.Constant; |
| | | |
| | | public class AliConstant { |
| | | |
| | | /** |
| | | * 支付宝配置 |
| | | */ |
| | | public static final String GRANT_TYPE = "authorization_code"; |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.account.ali.model; |
| | | |
| | | import lombok.ToString; |
| | | import org.springframework.boot.context.properties.ConfigurationProperties; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | /** |
| | | * @author xiaochen |
| | | * @ClassName ALiProperties |
| | | * @Description |
| | | * @date 2024-08-14 13:55 |
| | | */ |
| | | @ToString |
| | | @Component |
| | | @ConfigurationProperties(prefix = "ali.conf") |
| | | public class AliProperties { |
| | | |
| | | |
| | | /** |
| | | * 商户私钥,您的PKCS8格式RSA2私钥 |
| | | */ |
| | | private String privateKey; |
| | | /** |
| | | * 支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。 |
| | | */ |
| | | private String alipayPublicKey; |
| | | /** |
| | | * 应用ID,您的APPID。 |
| | | */ |
| | | private String appId; |
| | | |
| | | /** |
| | | * HTTP(S) 连接超时时间,单位毫秒 |
| | | * |
| | | */ |
| | | public int getHttpConnectTimeoutMs() { |
| | | return 6 * 1000; |
| | | } |
| | | |
| | | /** |
| | | * HTTP(S) 读数据超时时间,单位毫秒 |
| | | */ |
| | | public int getHttpReadTimeoutMs() { |
| | | return 8 * 1000; |
| | | } |
| | | |
| | | public String getPrivateKey() { |
| | | return privateKey; |
| | | } |
| | | |
| | | public void setPrivateKey(String privateKey) { |
| | | this.privateKey = privateKey; |
| | | } |
| | | |
| | | public String getAlipayPublicKey() { |
| | | return alipayPublicKey; |
| | | } |
| | | |
| | | public void setAlipayPublicKey(String alipayPublicKey) { |
| | | this.alipayPublicKey = alipayPublicKey; |
| | | } |
| | | |
| | | public String getAppId() { |
| | | return appId; |
| | | } |
| | | |
| | | public void setAppId(String appId) { |
| | | this.appId = appId; |
| | | } |
| | | } |
New file |
| | |
| | | package com.ruoyi.account.ali.tools; |
| | | |
| | | import com.alipay.api.AlipayConfig; |
| | | import com.ruoyi.account.ali.model.AliProperties; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * @author xiaochen |
| | | * @ClassName WxAppletTools |
| | | * @Description |
| | | * @date 2024-8-04 13:55 |
| | | */ |
| | | @Slf4j |
| | | public class AliAppletTools { |
| | | |
| | | private static final String SERVER_URL = "https://openapi.alipay.com/gateway.do"; |
| | | |
| | | private AliProperties aliProperties; |
| | | |
| | | public AliAppletTools(AliProperties aliProperties) { |
| | | this.aliProperties = aliProperties; |
| | | } |
| | | |
| | | /** |
| | | * 初始化支付宝配置 |
| | | * @return |
| | | */ |
| | | public AlipayConfig getAlipayConfig() { |
| | | AlipayConfig alipayConfig = new AlipayConfig(); |
| | | alipayConfig.setServerUrl(SERVER_URL); |
| | | alipayConfig.setAppId(aliProperties.getAppId()); |
| | | alipayConfig.setPrivateKey(aliProperties.getPrivateKey()); |
| | | alipayConfig.setAlipayPublicKey(aliProperties.getAlipayPublicKey()); |
| | | return alipayConfig; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.alipay.api.AlipayApiException; |
| | | import com.alipay.api.AlipayClient; |
| | | import com.alipay.api.AlipayConfig; |
| | | import com.alipay.api.DefaultAlipayClient; |
| | | import com.alipay.api.diagnosis.DiagnosisUtils; |
| | | import com.alipay.api.request.AlipaySystemOauthTokenRequest; |
| | | import com.alipay.api.response.AlipaySystemOauthTokenResponse; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.account.ali.Constant.AliConstant; |
| | | import com.ruoyi.account.ali.model.AliProperties; |
| | | import com.ruoyi.account.ali.tools.AliAppletTools; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.service.TAppUserService; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUserApplet; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | | * 支付宝小程序登录 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author xiaochen |
| | | * @since 2024-08-06 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/aliLogin") |
| | | public class AliLoginController { |
| | | |
| | | @Autowired |
| | | private AliProperties aliProperties; |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @ApiOperation(value = "通过code获得openid",tags = {"支付宝小程序登录"}) |
| | | @GetMapping("/openIdByJsCode") |
| | | public AjaxResult<Map<String, Object>> openIdByJsCode(@RequestParam(name = "code")@ApiParam(value = "code", required = true) String code) throws AlipayApiException { |
| | | log.info("<<<<<<<<换取openid开始<<<<<<<<:{}", code); |
| | | // 初始化SDK |
| | | AlipayClient alipayClient = new DefaultAlipayClient(new AliAppletTools(aliProperties).getAlipayConfig()); |
| | | // 构造请求参数以调用接口 |
| | | AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest(); |
| | | // 设置授权码 |
| | | request.setCode(code); |
| | | // 设置授权方式 |
| | | request.setGrantType(AliConstant.GRANT_TYPE); |
| | | AlipaySystemOauthTokenResponse response = alipayClient.execute(request); |
| | | TAppUser appUser = null; |
| | | if (response.isSuccess()) { |
| | | String openId = response.getOpenId(); |
| | | appUser = appUserService.getOne(Wrappers.lambdaQuery(TAppUser.class).eq(TAppUser::getAliOpenid, openId).last("limit 1")); |
| | | if (Objects.isNull(appUser)) { |
| | | appUser = new TAppUser(); |
| | | appUser.setWxOpenid(openId); |
| | | appUserService.save(appUser); |
| | | } |
| | | log.info("支付宝小程序登录调用成功"); |
| | | } else { |
| | | String diagnosisUrl = DiagnosisUtils.getDiagnosisUrl(response); |
| | | log.warn("诊断结果:{}",diagnosisUrl); |
| | | throw new ServiceException("支付宝小程序登录失败"); |
| | | } |
| | | LoginUserApplet loginUserApplet = new LoginUserApplet(); |
| | | if(ObjectUtils.isNotNull(appUser)){ |
| | | loginUserApplet.setUserId(appUser.getId()); |
| | | } |
| | | HashMap<String, Object> tokenInfos = new HashMap<>(); |
| | | tokenInfos.put("token",tokenService.createTokenApplet(loginUserApplet)); |
| | | tokenInfos.put("info",loginUserApplet); |
| | | return AjaxResult.ok(tokenInfos); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.ruoyi.account.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.service.TAppUserService; |
| | | import com.ruoyi.account.wx.body.resp.Code2SessionRespBody; |
| | | import com.ruoyi.account.wx.body.resq.Code2SessionResqBody; |
| | | import com.ruoyi.account.wx.model.WeixinProperties; |
| | | import com.ruoyi.account.wx.pojo.AppletUserDecodeData; |
| | | import com.ruoyi.account.wx.pojo.AppletUserEncrypteData; |
| | | import com.ruoyi.account.wx.tools.WxAppletTools; |
| | | import com.ruoyi.account.wx.tools.WxUtils; |
| | | import com.ruoyi.common.core.exception.ServiceException; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUserApplet; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | /** |
| | | * <p> |
| | | * 微信小程序登录 前端控制器 |
| | | * </p> |
| | | * |
| | | * @author xiaochen |
| | | * @since 2024-08-06 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/wxLogin") |
| | | public class WxLoginController { |
| | | @Autowired |
| | | private TAppUserService appUserService; |
| | | @Autowired |
| | | private WeixinProperties wxConfig; |
| | | @Autowired |
| | | private RestTemplate wxRestTemplate; |
| | | @ApiOperation(value = "通过code获得openid,获取用户信息",tags = {"微信小程序登录"}) |
| | | @PostMapping("/openIdByJsCode") |
| | | public AjaxResult<Map<String, Object>> openIdByJsCode(@RequestBody AppletUserEncrypteData data) { |
| | | log.info("<<<<<<<<换取openid开始<<<<<<<<:{}", data.getCode()); |
| | | WxAppletTools appletTools = new WxAppletTools(wxRestTemplate, wxConfig); |
| | | Code2SessionRespBody body = appletTools.getOpenIdByJscode2session(new Code2SessionResqBody().build(data.getCode())); |
| | | String openid = body.getOpenid(); |
| | | String sessionKey = body.getSessionKey(); |
| | | // 用户信息解密 数据验签 |
| | | if (StringUtils.isNotBlank(data.getSignature())) { |
| | | WxUtils.verifySignature(data.getRawData(), sessionKey, data.getSignature()); |
| | | } |
| | | AppletUserDecodeData appletUserDecodeData = WxUtils.encryptedData(data.getEncryptedData(), sessionKey, data.getIv()); |
| | | appletUserDecodeData.setOpenId(openid); |
| | | return AjaxResult.ok(appUserService.login(appletUserDecodeData)); |
| | | } |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.wx.pojo.AppletUserDecodeData; |
| | | |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | public interface TAppUserService extends IService<TAppUser> { |
| | | |
| | | /** |
| | | * 微信小程序登录用户封装 |
| | | * @param appletUserDecodeData |
| | | * @return |
| | | */ |
| | | Map<String, Object> login(AppletUserDecodeData appletUserDecodeData); |
| | | |
| | | } |
| | |
| | | package com.ruoyi.account.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.model.TAppUser; |
| | | import com.ruoyi.account.mapper.TAppUserMapper; |
| | | import com.ruoyi.account.service.TAppUserService; |
| | | import com.ruoyi.account.wx.model.WeixinProperties; |
| | | import com.ruoyi.account.wx.pojo.AppletUserDecodeData; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUserApplet; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.client.RestTemplate; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | */ |
| | | @Service |
| | | public class TAppUserServiceImpl extends ServiceImpl<TAppUserMapper, TAppUser> implements TAppUserService { |
| | | |
| | | @Autowired |
| | | private TokenService tokenService; |
| | | @Override |
| | | public Map<String, Object> login(AppletUserDecodeData appletUserDecodeData) { |
| | | // 通过手机号查询用户,是否已存在手动导入用户 |
| | | TAppUser appUser = this.getOne(Wrappers.lambdaQuery(TAppUser.class) |
| | | .eq(TAppUser::getPhone, appletUserDecodeData.getPhoneNumber()) |
| | | .isNull(TAppUser::getWxOpenid) |
| | | .last("LIMIT 1")); |
| | | LambdaQueryWrapper<TAppUser> wrapper = Wrappers.lambdaQuery(TAppUser.class) |
| | | .eq(TAppUser::getWxOpenid, appletUserDecodeData.getOpenId()); |
| | | if(Objects.isNull(appUser)){ |
| | | // 先使用openId和当前手机号进行查询 |
| | | wrapper.eq(TAppUser::getPhone, appletUserDecodeData.getPhoneNumber()) |
| | | .last("LIMIT 1"); |
| | | appUser = this.getOne(wrapper); |
| | | if(Objects.isNull(appUser)){ |
| | | appUser = new TAppUser(); |
| | | appUser.setPhone(appletUserDecodeData.getPhoneNumber()); |
| | | } |
| | | }else { |
| | | wrapper.last("LIMIT 1"); |
| | | // 删除小程序原有授权用户 |
| | | this.remove(wrapper); |
| | | } |
| | | appUser.setAvatar(appletUserDecodeData.getAvatarUrl()); |
| | | appUser.setCity(appletUserDecodeData.getCity()); |
| | | appUser.setName(appletUserDecodeData.getNickName()); |
| | | appUser.setProvince(appletUserDecodeData.getProvince()); |
| | | appUser.setWxOpenid(appletUserDecodeData.getOpenId()); |
| | | this.saveOrUpdate(appUser); |
| | | LoginUserApplet loginUserApplet = new LoginUserApplet(); |
| | | if(ObjectUtils.isNotNull(appUser)){ |
| | | loginUserApplet.setUserId(appUser.getId()); |
| | | loginUserApplet.setName(appUser.getName()); |
| | | loginUserApplet.setPhone(appUser.getPhone()); |
| | | loginUserApplet.setAvatar(appUser.getAvatar()); |
| | | loginUserApplet.setAddress(appUser.getProvince()+appUser.getCity()); |
| | | } |
| | | Map<String, Object> tokenInfos = new HashMap<>(); |
| | | tokenInfos.put("token",tokenService.createTokenApplet(loginUserApplet)); |
| | | tokenInfos.put("info",loginUserApplet); |
| | | return tokenInfos; |
| | | } |
| | | } |
| | |
| | | /** |
| | | * AccessToken 全局唯一 |
| | | * |
| | | * @author liheng |
| | | * @author xiaochen |
| | | */ |
| | | @Data |
| | | public class AccessTokenRespBody extends RespBody implements Serializable { |
| | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author liheng |
| | | * @author xiaochen |
| | | * @ClassName Code2SessionRespBody |
| | | * @Description |
| | | * @date 2021-07-28 12:35 |
| | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author liheng |
| | | * @author xiaochen |
| | | * @ClassName RespBody |
| | | * @Description |
| | | * @date 2021-07-28 11:44 |
| | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author liheng |
| | | * @author xiaochen |
| | | * @ClassName Code2SessionResqBody |
| | | * @Description |
| | | * @date 2021-07-28 11:47 |
| | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author liheng |
| | | * @author xiaochen |
| | | * @ClassName AppletUserDecodeData |
| | | * @Description |
| | | * @date 2021-08-13 17:46 |
| | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author liheng |
| | | * @author xiaochen |
| | | * @ClassName AppletUserDecodeData |
| | | * @Description |
| | | * @date 2021-08-13 17:46 |
| | | * 用户主体信息部分 |
| | | * { |
| | | * "openId": "OPENID", |
| | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * @author liheng |
| | | * @author xiaochen |
| | | * @ClassName AppletUserDecodeData |
| | | * @Description |
| | | * @date 2021-08-13 17:46 |
| | | * 小程序加密数据体 |
| | | * |
| | | */ |
| | |
| | | public class AppletUserEncrypteData extends AppletPhoneEncrypteData { |
| | | private String rawData; |
| | | private String signature; |
| | | private String code; |
| | | } |
| | |
| | | import javax.servlet.http.HttpSession; |
| | | |
| | | /** |
| | | * @Author liheng |
| | | * @Author xiaochen |
| | | * @Date 2019/08/26 10:28 AM |
| | | * @Description |
| | | */ |
| | |
| | | /** |
| | | * 缓存 |
| | | * |
| | | * @author liheng |
| | | * @author xiaochen |
| | | */ |
| | | class WxCache { |
| | | /** |
| | |
| | | package com.ruoyi.account.wx.tools; |
| | | |
| | | /** |
| | | * @author liheng |
| | | * @author xiaochen |
| | | * @ClassName WxCacheTemplate |
| | | * @Description |
| | | * @date 2021-01-11 11:27 |
| | |
| | | import java.util.concurrent.TimeUnit; |
| | | |
| | | /** |
| | | * @author liheng |
| | | * @author xiaochen |
| | | * @ClassName AbstractCaffineCache |
| | | * @Description |
| | | * @date 2021-01-11 11:27 |
New file |
| | |
| | | package com.ruoyi.account.wx.tools; |
| | | |
| | | import com.ruoyi.account.wx.pojo.AppletUserDecodeData; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.codec.CharEncoding; |
| | | import org.bouncycastle.jce.provider.BouncyCastleProvider; |
| | | import org.bouncycastle.util.encoders.Base64; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | |
| | | import javax.crypto.Cipher; |
| | | import javax.crypto.spec.IvParameterSpec; |
| | | import javax.crypto.spec.SecretKeySpec; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.io.BufferedReader; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.security.AlgorithmParameters; |
| | | import java.security.Security; |
| | | import java.util.Arrays; |
| | | |
| | | /** |
| | | * @Description 获取用户信息工具类 |
| | | * @Author xiaochen |
| | | * @Date 2021/8/12 15:45 |
| | | */ |
| | | @Slf4j |
| | | public class WxUtils { |
| | | |
| | | /** |
| | | * 微信小程序API 用户数据的解密 |
| | | * |
| | | * @param encryptedData |
| | | * @param sessionKey |
| | | * @param iv |
| | | * @return |
| | | */ |
| | | public static AppletUserDecodeData encryptedData(String encryptedData, String sessionKey, String iv) { |
| | | // 被加密的数据 |
| | | byte[] dataByte = Base64.decode(encryptedData); |
| | | // 加密秘钥 |
| | | byte[] keyByte = Base64.decode(sessionKey); |
| | | // 偏移量 |
| | | byte[] ivByte = Base64.decode(iv); |
| | | try { |
| | | // 如果密钥不足16位,那么就补足. 这个if 中的内容很重要 |
| | | int base = 16; |
| | | if (keyByte.length % base != 0) { |
| | | int groups = keyByte.length / base + (keyByte.length % base != 0 ? 1 : 0); |
| | | byte[] temp = new byte[groups * base]; |
| | | Arrays.fill(temp, (byte) 0); |
| | | System.arraycopy(keyByte, 0, temp, 0, keyByte.length); |
| | | keyByte = temp; |
| | | } |
| | | // 初始化 |
| | | Security.addProvider(new BouncyCastleProvider()); |
| | | Cipher cipher = Cipher.getInstance("AES/CBC/PKCS7Padding", "BC"); |
| | | SecretKeySpec spec = new SecretKeySpec(keyByte, "AES"); |
| | | AlgorithmParameters parameters = AlgorithmParameters.getInstance("AES"); |
| | | parameters.init(new IvParameterSpec(ivByte)); |
| | | cipher.init(Cipher.DECRYPT_MODE, spec, parameters); |
| | | byte[] resultByte = cipher.doFinal(dataByte); |
| | | if (null != resultByte && resultByte.length > 0) { |
| | | String result = new String(resultByte, CharEncoding.UTF_8); |
| | | log.info("解密原串:{}", result); |
| | | return WxJsonUtils.parseObject(result, AppletUserDecodeData.class); |
| | | } |
| | | throw new RuntimeException("解密的数据为空"); |
| | | } catch (Exception e) { |
| | | log.error("解密失败. error = {}", e.getMessage(), e); |
| | | throw new RuntimeException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 微信小程序API 用户数据的签名验证 |
| | | * signature = sha1( rawData + session_key ) |
| | | * |
| | | * @param rawData 不包括敏感信息的原始数据字符串,用于计算签名。 |
| | | * @param sessionKey |
| | | */ |
| | | public static void verifySignature(String rawData, String sessionKey, String signature) { |
| | | String serverSignature = SHA1.getSHA1(rawData + sessionKey); |
| | | log.info(rawData + ">>>>>>:" + sessionKey + " === " + serverSignature + " ======" + signature); |
| | | if (!signature.equals(serverSignature)) { |
| | | throw new RuntimeException("数据验签不通过"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据流接收请求数据 |
| | | * |
| | | * @param request |
| | | * @return |
| | | */ |
| | | public static String streamBodyByReceive(HttpServletRequest request) throws IOException { |
| | | log.info("微信异步回调地址:{}", request.getRequestURL()); |
| | | StringBuffer buffer = new StringBuffer(); |
| | | InputStream inputStream = request.getInputStream(); |
| | | InputStreamReader reader = new InputStreamReader(inputStream); |
| | | BufferedReader bufferedReader = new BufferedReader(reader); |
| | | String body = null; |
| | | while ((body = bufferedReader.readLine()) != null) { |
| | | buffer.append(body); |
| | | } |
| | | String data = buffer.toString(); |
| | | reader.close(); |
| | | inputStream.close(); |
| | | log.info("微信异步回调数据:{}", data); |
| | | return data; |
| | | } |
| | | |
| | | /** |
| | | * 日志 |
| | | * |
| | | * @return |
| | | */ |
| | | public static Logger getLogger() { |
| | | Logger logger = LoggerFactory.getLogger("wxpay java sdk"); |
| | | return logger; |
| | | } |
| | | |
| | | /** |
| | | * debug |
| | | * |
| | | * @param msg |
| | | * @param args |
| | | */ |
| | | public static void debug(String msg, Object... args) { |
| | | Logger log = getLogger(); |
| | | if (log.isDebugEnabled()) { |
| | | log.debug(msg, args); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * info |
| | | * |
| | | * @param msg |
| | | * @param args |
| | | */ |
| | | public static void info(String msg, Object... args) { |
| | | Logger log = getLogger(); |
| | | if (log.isInfoEnabled()) { |
| | | log.info(msg, args); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * warn |
| | | * |
| | | * @param msg |
| | | * @param args |
| | | */ |
| | | public static void warn(String msg, Object... args) { |
| | | Logger log = getLogger(); |
| | | if (log.isWarnEnabled()) { |
| | | log.warn(msg, args); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * error |
| | | * |
| | | * @param msg |
| | | * @param args |
| | | */ |
| | | public static void error(String msg, Object... args) { |
| | | Logger log = getLogger(); |
| | | if (log.isErrorEnabled()) { |
| | | log.error(msg, args); |
| | | } |
| | | } |
| | | } |
| | |
| | | enabled: true |
| | | application-id: ${spring.application.name} |
| | | tx-service-group: seata_tx_group #此处配置自定义的seata事务分组名称 |
| | | enable-auto-data-source-proxy: true #开启数据库代理 |
| | | enable-auto-data-source-proxy: false #关闭数据库代理 |
| | | service: |
| | | vgroup-mapping: |
| | | seata_tx_group: default |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Configuration; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.Date; |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public void insertFill(MetaObject metaObject) { |
| | | this.setFieldValByName("createTime", new Date(), metaObject); |
| | | this.setFieldValByName("updateTime", new Date(), metaObject); |
| | | this.setFieldValByName("createTime", LocalDateTime.now(), metaObject); |
| | | this.setFieldValByName("updateTime", LocalDateTime.now(), metaObject); |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | @Override |
| | | public void updateFill(MetaObject metaObject) { |
| | | this.setFieldValByName("updateTime", new Date(), metaObject); |
| | | this.setFieldValByName("updateTime", LocalDateTime.now(), metaObject); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @DeleteMapping("/delPartner/{id}") |
| | | @DeleteMapping("/delPartner") |
| | | @ApiOperation(value = "删除合作商", tags = {"管理后台-合作商管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "合作商id", name = "id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | public AjaxResult delPartner(@PathVariable("id") Integer[] id){ |
| | | public AjaxResult delPartner(@RequestParam("id") List<Integer> id){ |
| | | return partnerService.delPartner(id); |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | @ResponseBody |
| | | @DeleteMapping("/delSite/{id}") |
| | | @DeleteMapping("/delSite") |
| | | @ApiOperation(value = "删除站点", tags = {"管理后台-站点管理"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "站点id", name = "id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | public AjaxResult delSite(@PathVariable Integer[] id){ |
| | | public AjaxResult delSite(@RequestParam("id") Integer[] id){ |
| | | return siteService.delSite(id); |
| | | } |
| | | |
| | |
| | | @DeleteMapping(value = "/deleteById") |
| | | public AjaxResult<Boolean> deleteById(@RequestParam("id") Integer id) { |
| | | TChargingGun chargingGun = chargingGunService.getById(id); |
| | | chargingGun.setDelFlag(true); |
| | | chargingGunService.updateById(chargingGun); |
| | | chargingGunService.removeById(chargingGun); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @DeleteMapping("/delChargingPile/{id}") |
| | | @DeleteMapping("/delChargingPile") |
| | | @Log(title = "删除充电桩", businessType = BusinessType.DELETE,operatorType = OperatorType.MANAGE) |
| | | @ApiOperation(value = "删除充电桩", tags = {"管理后台-充电桩信息"}) |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "充电桩id", name = "id", dataTypeClass = Integer.class, required = true) |
| | | }) |
| | | public AjaxResult delChargingPile(@PathVariable Integer[] id){ |
| | | public AjaxResult delChargingPile(@RequestParam("id") Integer[] id){ |
| | | return chargingPileService.delChargingPile(id); |
| | | } |
| | | |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @DeleteMapping("/delChargingPileNotification/{id}") |
| | | @DeleteMapping("/delChargingPileNotification") |
| | | @ApiOperation(value = "删除系统通知", tags = {"管理后台-系统通知"}) |
| | | public AjaxResult delChargingPileNotification(@PathVariable Long id){ |
| | | public AjaxResult delChargingPileNotification(@RequestParam("id") Long id){ |
| | | TChargingPileNotification chargingPileNotification = chargingPileNotificationService.getById(id); |
| | | chargingPileNotification.setDelFlag(1); |
| | | chargingPileNotificationService.updateById(chargingPileNotification); |
| | |
| | | * 删除合作商 |
| | | * @param id |
| | | */ |
| | | AjaxResult delPartner(Integer[] id); |
| | | AjaxResult delPartner(List<Integer> id); |
| | | |
| | | /** |
| | | * 重置密码 |
| | |
| | | if(StringUtils.isEmpty(partner.getPhoneOne())){ |
| | | return AjaxResult.error("合作商电话1不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(partner.getAccount())){ |
| | | if(null == partner.getId() && StringUtils.isEmpty(partner.getAccount())){ |
| | | return AjaxResult.error("登录账号不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(partner.getPassword())){ |
| | | if(null == partner.getId() && StringUtils.isEmpty(partner.getPassword())){ |
| | | return AjaxResult.error("登录密码不能为空"); |
| | | } |
| | | return AjaxResult.success(); |
| | |
| | | */ |
| | | @Override |
| | | @GlobalTransactional(rollbackFor = Exception.class)//分布式事务 |
| | | public AjaxResult delPartner(Integer[] ids) { |
| | | public AjaxResult delPartner(List<Integer> ids) { |
| | | //查询有无关联数据 |
| | | //站点 |
| | | long count = siteService.count(new LambdaQueryWrapper<Site>().in(Site::getPartnerId, Arrays.asList(ids)).eq(Site::getDelFlag, 0)); |
| | |
| | | if(null == partner){ |
| | | return AjaxResult.error("删除失败"); |
| | | } |
| | | partner.setDelFlag(true); |
| | | this.updateById(partner); |
| | | this.removeById(partner); |
| | | SysUser user = sysUserClient.queryUserByUserName(partner.getAccount()).getData(); |
| | | user.setDelFlag("2"); |
| | | sysUserClient.updateUser(user); |
| | |
| | | } |
| | | for (Integer id : ids) { |
| | | Site site = this.getById(id); |
| | | site.setDelFlag(true); |
| | | this.updateById(site); |
| | | this.removeById(site); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | } |
| | | for (Integer id : ids) { |
| | | TChargingPile chargingPile = this.getById(id); |
| | | chargingPile.setDelFlag(true); |
| | | this.updateById(chargingPile); |
| | | this.removeById(chargingPile); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | enabled: true |
| | | application-id: ${spring.application.name} |
| | | tx-service-group: seata_tx_group #此处配置自定义的seata事务分组名称 |
| | | enable-auto-data-source-proxy: true #开启数据库代理 |
| | | enable-auto-data-source-proxy: false #关闭数据库代理 |
| | | service: |
| | | vgroup-mapping: |
| | | seata_tx_group: default |
| | |
| | | enabled: true |
| | | application-id: ${spring.application.name} |
| | | tx-service-group: seata_tx_group #此处配置自定义的seata事务分组名称 |
| | | enable-auto-data-source-proxy: true #开启数据库代理 |
| | | enable-auto-data-source-proxy: false #关闭数据库代理 |
| | | service: |
| | | vgroup-mapping: |
| | | seata_tx_group: default |
| | |
| | | @ApiOperation(value = "删除充电评价", tags = {"管理后台-充电评价"}) |
| | | public AjaxResult delOrderEvaluate(@PathVariable Long id){ |
| | | TOrderEvaluate orderEvaluate = orderEvaluateService.getById(id); |
| | | orderEvaluate.setDelFlag(true); |
| | | orderEvaluateService.updateById(orderEvaluate); |
| | | orderEvaluateService.removeById(orderEvaluate); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | enabled: true |
| | | application-id: ${spring.application.name} |
| | | tx-service-group: seata_tx_group #此处配置自定义的seata事务分组名称 |
| | | enable-auto-data-source-proxy: true #开启数据库代理 |
| | | enable-auto-data-source-proxy: false #关闭数据库代理 |
| | | service: |
| | | vgroup-mapping: |
| | | seata_tx_group: default |
| | |
| | | <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>com.alibaba.cloud</groupId> |
| | | <artifactId>spring-cloud-starter-alibaba-seata</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- SpringBoot Actuator --> |
| | | <dependency> |
| | | <groupId>org.springframework.boot</groupId> |
New file |
| | |
| | | //package com.ruoyi.other.config; |
| | | // |
| | | //import io.seata.rm.datasource.DataSourceProxy; |
| | | //import org.springframework.context.annotation.Bean; |
| | | //import org.springframework.context.annotation.Configuration; |
| | | // |
| | | //import javax.sql.DataSource; |
| | | // |
| | | ///** |
| | | // * @author zhibing.pu |
| | | // * @date 2024/8/17 11:10 |
| | | // */ |
| | | //@Configuration |
| | | //public class DataSourceProxyConfig { |
| | | // |
| | | // |
| | | // @Bean |
| | | // public DataSource dataSource(DataSource druidDataSource){ |
| | | // return new DataSourceProxy(druidDataSource); |
| | | // } |
| | | //} |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @DeleteMapping("/delEvaluationTag/{id}") |
| | | @DeleteMapping("/delEvaluationTag") |
| | | @ApiOperation(value = "删除评价标签", tags = {"管理后台-评价标签设置"}) |
| | | public AjaxResult<TInvoiceType> delEvaluationTag(@PathVariable Integer[] id){ |
| | | public AjaxResult<TInvoiceType> delEvaluationTag(@RequestParam("id") Integer[] id){ |
| | | List<TEvaluationTag> tEvaluationTags = evaluationTagService.listByIds(Arrays.asList(id)); |
| | | for (TEvaluationTag evaluationTag : tEvaluationTags) { |
| | | evaluationTag.setDelFlag(true); |
| | | evaluationTagService.updateById(evaluationTag); |
| | | evaluationTagService.removeById(evaluationTag); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | |
| | | |
| | | @ResponseBody |
| | | @DeleteMapping("/delInvoiceType/{id}") |
| | | @DeleteMapping("/delInvoiceType") |
| | | @ApiOperation(value = "删除发票类型", tags = {"管理后台-发票类型管理"}) |
| | | public AjaxResult<TInvoiceType> delInvoiceType(@PathVariable Integer[] id){ |
| | | public AjaxResult<TInvoiceType> delInvoiceType(@RequestParam("id") Integer[] id){ |
| | | List<TInvoiceType> tInvoiceTypes = invoiceTypeService.listByIds(Arrays.asList(id)); |
| | | for (TInvoiceType invoiceType : tInvoiceTypes) { |
| | | invoiceType.setDelFlag(true); |
| | | invoiceTypeService.updateById(invoiceType); |
| | | invoiceTypeService.removeById(invoiceType); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | # 共享配置 |
| | | shared-configs: |
| | | - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension} |
| | | |
| | | |
| | | --- |
| | | seata: |
| | | enabled: true |
| | | application-id: ${spring.application.name} |
| | | tx-service-group: seata_tx_group #此处配置自定义的seata事务分组名称 |
| | | enable-auto-data-source-proxy: true #开启数据库代理 |
| | | enable-auto-data-source-proxy: true #关闭数据库代理 |
| | | service: |
| | | vgroup-mapping: |
| | | seata_tx_group: default |
| | |
| | | enabled: true |
| | | application-id: ${spring.application.name} |
| | | tx-service-group: seata_tx_group #此处配置自定义的seata事务分组名称 |
| | | enable-auto-data-source-proxy: true #开启数据库代理 |
| | | enable-auto-data-source-proxy: false #关闭数据库代理 |
| | | service: |
| | | vgroup-mapping: |
| | | seata_tx_group: default |