最近搜索

springboot service 方法 弄成同步

浏览:25
管理员 2025-08-18 18:13


实现类写上关键字即可。  最好加上事务。



接口文件 不用管

public interface JifenRecordService extends IService<JifenRecord> {


    /**
     * @param map
     * @param page  默认1
     * @param limit
     *   Long total = userPage.getTotal();
     *   List<Menu> menuList = userPage.getRecords();
     */
    Page<JifenRecord> list(Map<String, Object> map, Integer page, Integer limit);


    void zhuan(JifenRecord jifenRecord);

}



import org.springframework.transaction.annotation.Transactional;

@Transactional
@Override
public  synchronized  void zhuan(JifenRecord jifenRecord) {
    XcxUser duifang = xcxUserService.findByPhone(jifenRecord.getPhone());
    XcxUser xcxUser = xcxUserService.getById(jifenRecord.getXcxUserId());

    jifenRecord.setState(1);//1转出  2转入
    jifenRecord.setType(1);//收到的积分 是什么类型,  1用户交易   2推广人消费积分  3商品销售  4其他
    jifenRecord.setTitle("积分转出");
    jifenRecord.setCreateDateTime(new Date());


联系站长

站长微信:xiaomao0055

站长QQ:14496453