Browse Source

压缩图片问题

qzy 11 months ago
parent
commit
c94b4267c4

+ 3 - 3
sp-core/sp-base/src/main/java/com/pj/utils/ht/AESUtil.java

@@ -353,10 +353,10 @@ CkB9nBTgtwQYyW+/luLX0P7AN7AG9vhXlSNzkpfp33/HoZX6MjrrBrQnRJkKy1nOeahRTV90bkIZYymu
         System.out.println("aes_cbc加密结果:" + cbcResult);
         System.out.println();
 
-        /*System.out.println("---------解密CBC---------");
-        String cbcDecrypt = decryptCBC(cbcResult, "klfksd78974s1d4f");// RabbitmQ.ACC_KEY
+        System.out.println("---------解密CBC---------");
+        String cbcDecrypt = decryptCBC("zo5yvhKGlGI4DFIbdwOa2eDjupWkiKvfWDGdNIbpX3WbDq4LsUhnTYh6aLPdj+w4l6OmVzLEjgh2/FC8MVmkYqCT6MZ401A8I8h7JYNXr+FpBg7dvZ/DgFpZ5u6uhYGwpJW65Sq21L1ulf4u8gwqB5DsKhhplzpPgO5D/RAgTM7JtCeP8r14b8rMG0Ux5FDjD3Beg+84XgA38PCZaSH++TONfN3iUkhei6MHrCumncofsTP8TxXxK+qMuZDacD8BBx+boScXqFFG/SEJM0vcruq5ozw16Trg+bUHv5ZZsWVt7el1NySpx6LF49ajSUIFVfTNAtIEa1WZ78Yq+81V/u97PVXGBu52PssOm1vZFkYEBtobYJzoUEKvA9veNKPpQ85cl57HaXA9cLWjydoQItxyetmxAWLNDE2HKR5Q1+w=", "klfksd78974s1d4f");// RabbitmQ.ACC_KEY
         System.out.println("aes解密结果:" + cbcDecrypt);
-        System.out.println();*/
+        System.out.println();
     }
 
 

+ 4 - 4
sp-generate/src/main/java/com/pj/SpGenerateApplication.java

@@ -23,7 +23,7 @@ public class SpGenerateApplication {
 		// ===================================  设置连接信息  ===================================
         FlyConfig config = new FlyConfig();
         config.setDriverClassName("com.mysql.cj.jdbc.Driver");
-        config.setUrl("jdbc:mysql://106.15.1.216:3006/sp-admin?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC");
+        config.setUrl("jdbc:mysql://106.15.1.216:3006/ht-sync?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC");
         config.setUsername("yun_user");
         config.setPassword("yun_Root@1123");
         config.setPrintSql(true);		// 是否打印sql
@@ -64,7 +64,7 @@ public class SpGenerateApplication {
 			.setOutFC(false)					// 是否输出FC.java工厂类
 			.setDefaultMeunIcon("el-icon-folder-opened")	// 生成后台管理页面时,默认的菜单图标
 			.setWebLibImportWay(2) 			// 前端js库导入方式(1=cdn导入, 2=本地导入[需将sa-admin附带js包复制到kj文件夹])
-			 .addTableName("tb_app")	// 添加要生成的表 (单个添加)
+			 .addTableName("ht_byte")	// 添加要生成的表 (单个添加)
 //			.addTableAll()		// 添加要生成的表 (一次性添加所有表)
 //          .removeTableName("sp_role", "sp_role_permission", "sp_admin", "sp_apilog", "sp_cfg")	// 移除这些内置的表,不必生成代码
             ;
@@ -74,8 +74,8 @@ public class SpGenerateApplication {
 
 		// ===================================  开始读取并输出   ===================================
 		GenUtil.doRead();	// 从数据库读取数据
-		GenUtil.doOutMyBatis();	// 输出java代码 (mybatis版本)
-		GenUtil.doOutMyBatisService();	// 输出java代码 - 追加service层
+		//GenUtil.doOutMyBatis();	// 输出java代码 (mybatis版本)
+		//GenUtil.doOutMyBatisService();	// 输出java代码 - 追加service层
 		GenUtil.doOutAdminHtml();	// 输出 admin后台管理页面
 //		GenUtil.doOutApidoc();	// 输出 接口文档页面
 

+ 4 - 3
sp-service/async-server/src/main/java/com/pj/feign/AmqpTemplateFeign.java

@@ -1,5 +1,6 @@
 package com.pj.feign;
 
+import cn.hutool.log.StaticLog;
 import com.alibaba.fastjson.JSON;
 import com.pj.api.dto.OrderDto;
 import com.pj.api.dto.OrdersDto;
@@ -34,7 +35,7 @@ public class AmqpTemplateFeign {
      * @param dataType
      */
     public <T> void sendObject(T t, String dataType) {
-        log.info("send data to ht:{},{}", dataType,JSON.toJSONString(t));
+        StaticLog.info("send data to ht:{},{}", dataType,JSON.toJSONString(t));
         //todo: 数据暂时定死
         DataDto dataDto = new DataDto();
         //msgId
@@ -60,8 +61,8 @@ public class AmqpTemplateFeign {
         dataDto.setSign(sign);
         //mq发送信息
         amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE, dataDto);
-        log.info("send mq msg finish:{},{}", dataType,JSON.toJSONString(dataDto));
-        log.info("send mq msg finish:{},{}", dataType,JSON.toJSONString(t));
+        StaticLog.info("send mq msg finish:{},{}", dataType,JSON.toJSONString(dataDto));
+        StaticLog.info("send mq msg finish:{},{}", dataType,JSON.toJSONString(t));
     }
 
     /**

+ 5 - 1
sp-service/async-server/src/main/java/com/pj/ht_byte/HtByte.java

@@ -9,6 +9,7 @@ import lombok.AllArgsConstructor;
 import lombok.EqualsAndHashCode;
 
 import lombok.Data;
+import lombok.NoArgsConstructor;
 import lombok.experimental.Accessors;
 import org.springframework.format.annotation.DateTimeFormat;
 
@@ -21,6 +22,7 @@ import org.springframework.format.annotation.DateTimeFormat;
 @TableName(HtByte.TABLE_NAME)
 @EqualsAndHashCode(callSuper = false)
 @AllArgsConstructor
+@NoArgsConstructor
 public class HtByte extends Model<HtByte> implements Serializable {
 	public HtByte(String messageId, String dataType, String body, String queueName, Integer finishStatus, Date createTime) {
 		this.messageId = messageId;
@@ -92,10 +94,12 @@ public class HtByte extends Model<HtByte> implements Serializable {
 	/**
 	 * 创建时间 
 	 */
-	@DateTimeFormat(pattern = "yyyy-MM-dd")
 	private Date createTime;
 
 
+	@TableField(exist = false)
+	private String details;
+
 
 
 

+ 1 - 31
sp-service/async-server/src/main/java/com/pj/ht_byte/HtByteController.java

@@ -25,39 +25,9 @@ public class HtByteController {
 	@Autowired
 	HtByteService htByteService;
 
-	/** 增 */  
-	@RequestMapping("add")
-	@SaCheckPermission(HtByte.PERMISSION_CODE_ADD)
-	public AjaxJson add(HtByte h){
-		htByteService.add(h);
-		h = htByteService.getById(SP.publicMapper.getPrimarykey());
-		return AjaxJson.getSuccessData(h);
-	}
 
-	/** 删 */  
-	@RequestMapping("delete")
-	@SaCheckPermission(HtByte.PERMISSION_CODE_DEL)
-	public AjaxJson delete(Integer id){
-		 htByteService.delete(Long.valueOf(id));
-		return AjaxJson.getSuccess();
-	}
 	
-	/** 删 - 根据id列表 */  
-	@RequestMapping("deleteByIds")
-	@SaCheckPermission(HtByte.PERMISSION_CODE_DEL)
-	public AjaxJson deleteByIds(){
-		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class); 
-		int line = SP.publicMapper.deleteByIds(HtByte.TABLE_NAME, ids);
-		return AjaxJson.getByLine(line);
-	}
-	
-	/** 改 */  
-	@RequestMapping("update")
-	@SaCheckPermission(HtByte.PERMISSION_CODE_EDIT)
-	public AjaxJson update(HtByte h){
-		htByteService.update(h);
-		return AjaxJson.getSuccess();
-	}
+
 
 	/** 查 - 根据id */  
 	@RequestMapping("getById")

+ 1 - 10
sp-service/async-server/src/main/java/com/pj/ht_byte/HtByteMapper.xml

@@ -30,16 +30,7 @@
 			<if test=' this.has("finishStatus") '> and finish_status = #{finishStatus} </if>
 			<if test=' this.has("createTime") '> and create_time = #{createTime} </if>
 		</where>
-		order by
-		<choose>
-			<when test='sortType == 1'> id desc </when>
-			<when test='sortType == 2'> message_id desc </when>
-			<when test='sortType == 3'> body desc </when>
-			<when test='sortType == 4'> queue_name desc </when>
-			<when test='sortType == 5'> finish_status desc </when>
-			<when test='sortType == 6'> create_time desc </when>
-			<otherwise> id desc </otherwise>
-		</choose>
+		order by create_time desc
 	</select>
 	
 	

+ 61 - 33
sp-service/async-server/src/main/java/com/pj/ht_byte/HtByteService.java

@@ -1,6 +1,11 @@
 package com.pj.ht_byte;
 
 import java.util.List;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.pj.dto.DataDto;
+import com.pj.rabbitmq.RabbitMQ;
+import com.pj.utils.ht.AESUtil;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -11,41 +16,64 @@ import com.pj.utils.sg.*;
 
 /**
  * Service: ht_byte -- 航通基础信息字节码表
- * @author yzs 
+ *
+ * @author yzs
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class HtByteService extends ServiceImpl<HtByteMapper, HtByte> implements IService<HtByte>{
-
-	/** 底层 Mapper 对象 */
-	@Autowired
-	HtByteMapper htByteMapper;
-
-	/** 增 */
-	void add(HtByte h){
-		save(h);
-	}
-
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
-
-	/** 改 */
-	void update(HtByte h){
-		updateById(h);
-
-	}
-
-	/** 查 */
-	HtByte getById(Integer id){
-		return super.getById(id);
-	}
-
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	List<HtByte> getList(SoMap so) { 
-		return htByteMapper.getList(so);	
-	}
-	
+public class HtByteService extends ServiceImpl<HtByteMapper, HtByte> implements IService<HtByte> {
+
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    HtByteMapper htByteMapper;
+
+    /**
+     * 增
+     */
+    void add(HtByte h) {
+        save(h);
+    }
+
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
+
+    /**
+     * 改
+     */
+    void update(HtByte h) {
+        updateById(h);
+
+    }
+
+    /**
+     * 查
+     */
+    HtByte getById(Integer id) {
+        HtByte htByte = super.getById(id);
+        DataDto dataDto = JSONObject.parseObject(htByte.getBody(), DataDto.class);
+        String body = AESUtil.decryptCBC(dataDto.getData(), RabbitMQ.ACC_KEY);
+        htByte.setDetails(body);
+        return htByte;
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<HtByte> getList(SoMap so) {
+        List<HtByte> list = htByteMapper.getList(so);
+        list.forEach(htByte -> {
+            DataDto dataDto = JSONObject.parseObject(htByte.getBody(), DataDto.class);
+            String body = AESUtil.decryptCBC(dataDto.getData(), RabbitMQ.ACC_KEY);
+            htByte.setDetails(body);
+        });
+        return list;
+    }
+
 
 }

+ 2 - 2
sp-service/async-server/src/main/java/com/pj/listen/BaseInfoListen.java

@@ -1,6 +1,7 @@
 package com.pj.listen;
 
 import cn.hutool.core.util.RandomUtil;
+import cn.hutool.log.StaticLog;
 import com.alibaba.fastjson2.JSONObject;
 import com.pj.api.dto.OrderDto;
 import com.pj.dto.DataDto;
@@ -37,12 +38,11 @@ public class BaseInfoListen {
      */
     @RabbitListener(queuesToDeclare = @Queue(RabbitMQ.TEST_ACCEPT_QUEUE))
     public void accept(Message json){
-        System.out.println("\n接收:信息同步\n");
         byte[] content = json.getBody();
         //保存到数据库
         String jsonString = new String(content);
+        StaticLog.info("\n接收:信息同步:{}",jsonString);
         htByteMapper.insert(new HtByte(RandomUtil.randomString(64),null,jsonString,RabbitMQ.TEST_ACCEPT_QUEUE, FinishStatus.FINISH_STATUS_ZERO.getCode(),new Date()));
-        System.out.println("\n消息同步完成。\n");
 
     }
 

+ 16 - 35
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserApiController.java

@@ -1,5 +1,6 @@
 package com.pj.project.app_user;
 
+import cn.hutool.core.codec.Base64;
 import cn.hutool.core.thread.ThreadUtil;
 import cn.hutool.core.util.RandomUtil;
 import cn.hutool.core.util.StrUtil;
@@ -33,6 +34,7 @@ import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.io.InputStream;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -205,41 +207,20 @@ public class AppUserApiController {
 
     @RequestMapping("find")
     public AjaxJson find(@RequestBody String img) {
-        img=ImageUtils.compressPic(img);
-//        LambdaQueryWrapper<AppUser>ew=new LambdaQueryWrapper<>();
-//        ew.isNotNull(AppUser::getFaceId);
-//        List<AppUser> appUserList = appUserService.list(ew);
-//        appUserList.stream().filter(appUser -> StrUtil.isNotEmpty(appUser.getFaceId()))
-//                .forEach(appUser -> {
-//                    String faceId = appUser.getFaceId();
-//                    Credential cred = new Credential("AKIDtmacfdOH97likhhaL971xywwhRH7saCt", "1DOSWWYcl2FWhw7BLOII6zz65ylOzTpS");
-//                    // 实例化一个http选项,可选的,没有特殊需求可以跳过
-//                    HttpProfile httpProfile = new HttpProfile();
-//                    httpProfile.setEndpoint("iai.tencentcloudapi.com");
-//                    // 实例化一个client选项,可选的,没有特殊需求可以跳过
-//                    ClientProfile clientProfile = new ClientProfile();
-//                    clientProfile.setHttpProfile(httpProfile);
-//                    // 实例化要请求产品的client对象,clientProfile是可选的
-//                    IaiClient client = new IaiClient(cred, "ap-chongqing", clientProfile);
-//                    VerifyPersonRequest req = new VerifyPersonRequest();
-//                    req.setImage(img);
-//                    req.setPersonId(faceId);
-//                    // 返回的resp是一个VerifyPersonResponse的实例,与请求对象对应
-//                    VerifyPersonResponse resp=null;
-//                    try {
-//                        resp = client.VerifyPerson(req);
-//                    } catch (TencentCloudSDKException e) {
-//                        if (e.getMessage().contains("人员ID不存在")){
-//                            appUser.setFaceId("1111");
-//                            appUserService.updateById(appUser);
-//                        }
-//                        log.error("VerifyPerson:{},{},{},{}",faceId,appUser.getName(),appUser.getId(),e.getMessage());
-//                    }
-//                    if (resp!= null) {
-//                        log.info("VerifyPerson:{},{},{},{},{}",faceId,appUser.getName(),appUser.getId(),resp.getIsMatch(),resp.getScore());
-//                    }
-//                    ThreadUtil.sleep(RandomUtil.randomLong(1000,2000));
-//                });
+        img = ImageUtils.compressPic(img);
+
+        return AjaxJson.getSuccess();
+    }
+
+    @RequestMapping("file")
+    public AjaxJson file(MultipartFile file) {
+        try (InputStream is = file.getInputStream()) {
+            String img = Base64.encode(is);
+            img = ImageUtils.compressPic(img);
+        } catch (Exception e) {
+
+        }
+
         return AjaxJson.getSuccess();
     }
 

+ 188 - 154
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserController.java

@@ -24,164 +24,198 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 
 /**
  * Controller: app_user -- 移动端账号
+ *
  * @author qzy
  */
 @RestController
 @RequestMapping("/AppUser/")
 public class AppUserController {
 
-	/** 底层 Service 对象 */
-	@Autowired
-	AppUserService appUserService;
-
-	/** 增 */
-	@RequestMapping("add")
-	@SaCheckPermission(AppUser.PERMISSION_CODE_ADD)
-	public AjaxJson add(AppUser a){
-		appUserService.add(a);
-		a = appUserService.getById(SP.publicMapper.getPrimarykey());
-		return AjaxJson.getSuccessData(a);
-	}
-
-	/** 删 */
-	@RequestMapping("delete")
-	@SaCheckPermission(AppUser.PERMISSION_CODE_DEL)
-	public AjaxJson delete(Long id){
-		 appUserService.delete(id);
-		return AjaxJson.getSuccess();
-	}
-
-	/** 删 - 根据id列表 */
-	@RequestMapping("deleteByIds")
-	@SaCheckPermission(AppUser.PERMISSION_CODE_DEL)
-	public AjaxJson deleteByIds(){
-		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
-		int line = SP.publicMapper.deleteByIds(AppUser.TABLE_NAME, ids);
-		return AjaxJson.getByLine(line);
-	}
-
-	/** 改 */
-	@RequestMapping("update")
-	@SaCheckPermission(AppUser.PERMISSION_CODE_EDIT)
-	public AjaxJson update(AppUser a){
-		appUserService.update(a);
-		return AjaxJson.getSuccess();
-	}
-
-	/** 修改密码 */
-	@RequestMapping("pass")
-	@SaCheckPermission( AppUser.PERMISSION_CODE_EDIT)
-	public AjaxJson pass(@Validated PassDto dto){
-		StaticLog.info("dto:", JSONUtil.toJsonStr(dto.getPassword()));
-		return AjaxJson.toAjax(appUserService.pass(dto));
-	}
-
-	/** 查 - 根据id */
-	@RequestMapping("getById")
-		@SaCheckPermission(AppUser.PERMISSION_CODE)
-	public AjaxJson getById(Long id){
-		AppUser a = appUserService.getById(id);
-		return AjaxJson.getSuccessData(a);
-	}
-
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
-	@RequestMapping("getList")
-		@SaCheckPermission(AppUser.PERMISSION_CODE)
-	public AjaxJson getList() {
-		SoMap so = SoMap.getRequestSoMap();
-		List<AppUser> list = appUserService.getList(so.startPage());
-		return AjaxJson.getPageData(so.getDataCount(), list);
-	}
-
-	/**
-	 * 更换角色
-	 *
-	 * 当前用户已登录,app点击该按钮时,从缓存获取用户类型与选择要更换的角色id做对比,相同则进入此方法,故在此不做用户角色权限过滤
-	 * @param appRoleId
-	 * @return
-	 */
-	@RequestMapping("updateRole")
-	AjaxJson updateRole(@RequestParam("appRoleId")String appRoleId) {
-		return appUserService.updateRole(appRoleId);
-	}
-
-	/*-----               正常业务接口👆👆    不越界     rpc远程调用 👇👇                     -----*/
-
-
-	/** 启/停边民的app账号登陆限制 */
-	@PostMapping("rpc/isLock")
-	public int isLock(@RequestParam("id") String id,
-						   @RequestParam("type") Integer type,
-						   @RequestParam("status") Integer status) {
-		int lock = appUserService.isLock(id,type,status);
-		return lock;
-	}
-
-	/** 查单个app有效用户 - 根据id */
-	@RequestMapping("rpc/getById")
-	public AppUserDto getAppUserById(@RequestParam("id") Long id){
-		AppUserDto appUser = appUserService.getUserById(id);
-		return appUser;
-	}
-	/** 商户认证 */
-	@PostMapping("rpc/audit")
-	public boolean audit(@RequestBody EnterpriseAuditDto dto){
-		LambdaUpdateWrapper<AppUser> updateWrapper = new LambdaUpdateWrapper<>();
-		updateWrapper.set(AppUser::getAuth, dto.getAuth()).set(AppUser::getAuthTime, new Date()).eq(AppUser::getFkId, dto.getFkId());
-		boolean update = appUserService.update(updateWrapper);
-		return update;
-	}
-
-	/**
-	 * 收购商认证
-	 */
-	@PostMapping("rpc/saveAppUserInfo")
-	public Boolean saveAppUserInfo(@RequestBody AppUserDto appUser) {
-		boolean info = appUserService.saveAppUserInfo(appUser);
-		return info;
-	}
-
-
-
-	/**
-	 * 用户数量统计
-	 * @return
-	 */
-	@RequestMapping("selectUsers")
-	public AjaxJson selectUsers(){
-		return AjaxJson.getSuccessData(appUserService.selectUsers());
-	}
-
-
-	/**
-	 * 创建账号
-	 * @param createDTO
-	 */
-	@PostMapping("rpc/createAppAccount")
-	public boolean createAccount(@RequestBody AppUserCreateDTO createDTO){
-		return appUserService.createUser(createDTO);
-	}
-	@PostMapping("rpc/changeBindShopStatus")
-	public void changeBindShopStatus(@RequestBody BindShopDTO bindShopDTO){
-		appUserService.changeBindShopStatus(bindShopDTO);
-	}
-
-	/** 根据fkId查app用户 */
-	@PostMapping("rpc/getByFkId")
-	public AppUserDto getAppUserByFkId(@RequestParam("fkId") Long fkId){
-		return appUserService.getAppUserByFkId(fkId);
-	}
-
-	@RequestMapping("rpc/findUserByPhone")
-	public AppUserDto findUserByPhone(@RequestParam("phone") String phone) {
-		return appUserService.findUserByPhone(phone);
-	}
-	@RequestMapping("rpc/bindFkId")
-	public boolean bindFkId(@RequestParam("appUserId") Long appUserId,@RequestParam("fkId")  Long fkId){
-		return appUserService.bindFkId(appUserId,fkId);
-	}
-	@PostMapping("rpc/updateAccount")
-	public int updateAccount(@RequestBody UpdateAccountDTO phone) {
-		return appUserService.updateAccount(phone);
-	}
+    /**
+     * 底层 Service 对象
+     */
+    @Autowired
+    AppUserService appUserService;
+
+    /**
+     * 增
+     */
+    @RequestMapping("add")
+    @SaCheckPermission(AppUser.PERMISSION_CODE_ADD)
+    public AjaxJson add(AppUser a) {
+        appUserService.add(a);
+        a = appUserService.getById(SP.publicMapper.getPrimarykey());
+        return AjaxJson.getSuccessData(a);
+    }
+
+    /**
+     * 删
+     */
+    @RequestMapping("delete")
+    @SaCheckPermission(AppUser.PERMISSION_CODE_DEL)
+    public AjaxJson delete(Long id) {
+        appUserService.delete(id);
+        return AjaxJson.getSuccess();
+    }
+
+    /**
+     * 删 - 根据id列表
+     */
+    @RequestMapping("deleteByIds")
+    @SaCheckPermission(AppUser.PERMISSION_CODE_DEL)
+    public AjaxJson deleteByIds() {
+        List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
+        int line = SP.publicMapper.deleteByIds(AppUser.TABLE_NAME, ids);
+        return AjaxJson.getByLine(line);
+    }
+
+    /**
+     * 改
+     */
+    @RequestMapping("update")
+    @SaCheckPermission(AppUser.PERMISSION_CODE_EDIT)
+    public AjaxJson update(AppUser a) {
+        appUserService.update(a);
+        return AjaxJson.getSuccess();
+    }
+
+    /**
+     * 修改密码
+     */
+    @RequestMapping("pass")
+    @SaCheckPermission(AppUser.PERMISSION_CODE_EDIT)
+    public AjaxJson pass(@Validated PassDto dto) {
+        StaticLog.info("dto:", JSONUtil.toJsonStr(dto.getPassword()));
+        return AjaxJson.toAjax(appUserService.pass(dto));
+    }
+
+    /**
+     * 查 - 根据id
+     */
+    @RequestMapping("getById")
+    @SaCheckPermission(AppUser.PERMISSION_CODE)
+    public AjaxJson getById(Long id) {
+        AppUser a = appUserService.getById(id);
+        return AjaxJson.getSuccessData(a);
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    @RequestMapping("getList")
+    @SaCheckPermission(AppUser.PERMISSION_CODE)
+    public AjaxJson getList() {
+        SoMap so = SoMap.getRequestSoMap();
+        List<AppUser> list = appUserService.getList(so.startPage());
+        return AjaxJson.getPageData(so.getDataCount(), list);
+    }
+
+    /**
+     * 更换角色
+     * <p>
+     * 当前用户已登录,app点击该按钮时,从缓存获取用户类型与选择要更换的角色id做对比,相同则进入此方法,故在此不做用户角色权限过滤
+     *
+     * @param appRoleId
+     * @return
+     */
+    @RequestMapping("updateRole")
+    AjaxJson updateRole(@RequestParam("appRoleId") String appRoleId) {
+        return appUserService.updateRole(appRoleId);
+    }
+
+    /*-----               正常业务接口👆👆    不越界     rpc远程调用 👇👇                     -----*/
+
+
+    /**
+     * 启/停边民的app账号登陆限制
+     */
+    @PostMapping("rpc/isLock")
+    public int isLock(@RequestParam("id") String id,
+                      @RequestParam("type") Integer type,
+                      @RequestParam("status") Integer status) {
+        int lock = appUserService.isLock(id, type, status);
+        return lock;
+    }
+
+    /**
+     * 查单个app有效用户 - 根据id
+     */
+    @RequestMapping("rpc/getById")
+    public AppUserDto getAppUserById(@RequestParam("id") Long id) {
+        AppUserDto appUser = appUserService.getUserById(id);
+        return appUser;
+    }
+
+    /**
+     * 商户认证
+     */
+    @PostMapping("rpc/audit")
+    public boolean audit(@RequestBody EnterpriseAuditDto dto) {
+        LambdaUpdateWrapper<AppUser> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.set(AppUser::getAuth, dto.getAuth()).set(AppUser::getAuthTime, new Date()).eq(AppUser::getFkId, dto.getFkId());
+        boolean update = appUserService.update(updateWrapper);
+        return update;
+    }
+
+    /**
+     * 收购商认证
+     */
+    @PostMapping("rpc/saveAppUserInfo")
+    public Boolean saveAppUserInfo(@RequestBody AppUserDto appUser) {
+        boolean info = appUserService.saveAppUserInfo(appUser);
+        return info;
+    }
+
+
+    /**
+     * 用户数量统计
+     *
+     * @return
+     */
+    @RequestMapping("selectUsers")
+    public AjaxJson selectUsers() {
+        return AjaxJson.getSuccessData(appUserService.selectUsers());
+    }
+
+
+    /**
+     * 创建账号
+     *
+     * @param createDTO
+     */
+    @PostMapping("rpc/createAppAccount")
+    public boolean createAccount(@RequestBody AppUserCreateDTO createDTO) {
+        return appUserService.createUser(createDTO);
+    }
+
+    @PostMapping("rpc/changeBindShopStatus")
+    public void changeBindShopStatus(@RequestBody BindShopDTO bindShopDTO) {
+        appUserService.changeBindShopStatus(bindShopDTO);
+    }
+
+    /**
+     * 根据fkId查app用户
+     */
+    @PostMapping("rpc/getByFkId")
+    public AppUserDto getAppUserByFkId(@RequestParam("fkId") Long fkId) {
+        return appUserService.getAppUserByFkId(fkId);
+    }
+
+    @RequestMapping("rpc/findUserByPhone")
+    public AppUserDto findUserByPhone(@RequestParam("phone") String phone) {
+        return appUserService.findUserByPhone(phone);
+    }
+
+    @RequestMapping("rpc/bindFkId")
+    public boolean bindFkId(@RequestParam("appUserId") Long appUserId, @RequestParam("fkId") Long fkId) {
+        return appUserService.bindFkId(appUserId, fkId);
+    }
+
+    @PostMapping("rpc/updateAccount")
+    public int updateAccount(@RequestBody UpdateAccountDTO phone) {
+        return appUserService.updateAccount(phone);
+    }
+
+
+
 }

+ 52 - 65
sp-service/sp-admin/src/main/java/com/pj/project4sp/utils/ImageUtils.java

@@ -5,90 +5,77 @@ import net.coobird.thumbnailator.Thumbnails;
 import sun.misc.BASE64Decoder;
 import sun.misc.BASE64Encoder;
 
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
+import java.util.Base64;
 
 public class ImageUtils {
 
     private static final Integer KB = 1024;
+
+
+
+
+    // 将Base64字符串解码为BufferedImage
+    public static BufferedImage base64ToBufferedImage(String base64Image) throws IOException {
+        byte[] imageBytes = Base64.getDecoder().decode(base64Image);
+        ByteArrayInputStream bais = new ByteArrayInputStream(imageBytes);
+        return ImageIO.read(bais);
+    }
+
+    // 将BufferedImage转回Base64字符串
+    public static String bufferedImageToBase64(BufferedImage image, String format) throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ImageIO.write(image, format, baos);
+        byte[] imageBytes = baos.toByteArray();
+        return Base64.getEncoder().encodeToString(imageBytes);
+    }
     /**
      * 图片压缩指定长宽处理
-     * @param origPicContent
+     *
+     * @param base64Image
      * @return
      */
-    public static String compressPic(String origPicContent) {
-        ByteArrayInputStream in = null;
-        ByteArrayOutputStream out = null;
+    // 压缩图片至指定大小
+    public static String compressPic(String base64Image) {
+        BufferedImage originalImage = null;
         try {
-            byte[] bytes = new BASE64Decoder().decodeBuffer(origPicContent);
-            in = new ByteArrayInputStream(bytes);
-            out = new ByteArrayOutputStream();
-            Thumbnails.of(in).size(600,400).outputQuality(0.6).toOutputStream(out);
-            return new BASE64Encoder().encode(bytes).replaceAll("\\r\\n","");
+            originalImage = base64ToBufferedImage(base64Image);
         } catch (IOException e) {
-            StaticLog.error ("decode buffer fail, message:{}", e.getMessage (), e);
-        } finally {
-            if (in != null) {
-                try {
-                    in.close ();
-                } catch (IOException e) {
-                    StaticLog.error ("ByteArrayInputStream close fail, message:{}", e.getMessage (), e);
-                }
-            }
-            if (out != null) {
-                try {
-                    out.close ();
-                } catch (IOException e) {
-                    StaticLog.error ("ByteArrayOutputStream close fail, message:{}", e.getMessage (), e);
-                }
-            }
+           return base64Image;
         }
-        return origPicContent;
-    }
 
-    /**
-     * 图片压缩到指定大小
-     * @param origPicContent
-     * @param desFileSize
-     * @return
-     */
-    public static String compressPic(String origPicContent, Integer desFileSize) {
-        ByteArrayInputStream in = null;
-        ByteArrayOutputStream out = null;
-        try {
-            byte[] bytes = new BASE64Decoder().decodeBuffer(origPicContent);
-            while (bytes.length > desFileSize * KB) {
-                in = new ByteArrayInputStream(bytes);
-                out = new ByteArrayOutputStream();
-                Thumbnails.of(in)
-                        .scale(0.8f)
-//                        .outputQuality(accuracy)
-                        .toOutputStream(out);
-                bytes = out.toByteArray();
-            }
-            return new BASE64Encoder().encode(bytes).replaceAll("\\r\\n","");
-        } catch (IOException e) {
-            StaticLog.error ("decode buffer fail, message:{}", e.getMessage (), e);
-        } finally {
-            if (in != null) {
-                try {
-                    in.close ();
-                } catch (IOException e) {
-                    StaticLog.error ("ByteArrayInputStream close fail, message:{}", e.getMessage (), e);
-                }
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        double quality = 1.0; // 初始质量
+        long imageSizeBytes = Long.MAX_VALUE;
+
+        // 使用缩放和调整图片质量的循环,直到图片小于指定大小
+        while (imageSizeBytes / (1024 * 1024) >= 5) {
+
+            baos.reset(); // 重置输出流
+            try {
+                Thumbnails.of(originalImage)
+                        .scale(1.0) // 保持原始尺寸,可以根据需要调整
+                        .outputQuality(quality) // 调整图片质量
+                        .outputFormat("jpg") // 输出格式
+                        .toOutputStream(baos);
+            } catch (IOException e) {
+                return base64Image;
             }
-            if (out != null) {
-                try {
-                    out.close ();
-                } catch (IOException e) {
-                    StaticLog.error ("ByteArrayOutputStream close fail, message:{}", e.getMessage (), e);
-                }
+            imageSizeBytes = baos.size();
+            // 递减图片质量
+            quality -= 0.05;
+            if (quality < 0.05) { // 避免质量过低
+                return base64Image;
             }
         }
-        return origPicContent;
+        // 压缩成功,将图片转为Base64
+        byte[] compressedImageBytes = baos.toByteArray();
+        return Base64.getEncoder().encodeToString(compressedImageBytes);
     }
 
-
 }